Commit | Line | Data |
---|---|---|
06b9339e BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Bernd Hufmann - Initial API and implementation | |
11 | **********************************************************************/ | |
31a6a4e4 | 12 | package org.eclipse.linuxtools.internal.lttng.ui.views.control.property; |
06b9339e | 13 | |
ccc66d01 BH |
14 | import java.util.ArrayList; |
15 | import java.util.List; | |
16 | ||
31a6a4e4 BH |
17 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.Messages; |
18 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel; | |
19 | import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.BaseEventComponent; | |
06b9339e BH |
20 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
21 | import org.eclipse.ui.views.properties.TextPropertyDescriptor; | |
22 | ||
23 | /** | |
24 | * <b><u>BaseEventPropertySource</u></b> | |
25 | * <p> | |
26 | * Property source implementation for the base event component. | |
27 | * </p> | |
28 | */ | |
29 | public class BaseEventPropertySource extends BasePropertySource { | |
30 | ||
31 | // ------------------------------------------------------------------------ | |
32 | // Constants | |
33 | // ------------------------------------------------------------------------ | |
34 | ||
35 | /** | |
36 | * The base event 'name' property ID. | |
37 | */ | |
38 | public static final String BASE_EVENT_NAME_PROPERTY_ID = "base.event.name"; //$NON-NLS-1$ | |
39 | /** | |
40 | * The base event 'type' property ID. | |
41 | */ | |
42 | public static final String BASE_EVENT_TYPE_PROPERTY_ID = "base.event.type"; //$NON-NLS-1$ | |
43 | /** | |
44 | * The base event 'log level' property ID. | |
45 | */ | |
46 | public static final String BASE_EVENT_LOGLEVEL_PROPERTY_ID = "base.event.loglevel"; //$NON-NLS-1$ | |
47 | /** | |
48 | * The base event 'name' property name. | |
49 | */ | |
50 | public static final String BASE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName; | |
51 | /** | |
52 | * The base event 'type' property name. | |
53 | */ | |
54 | public static final String BASE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName; | |
55 | /** | |
56 | * The base event 'log level' property name. | |
57 | */ | |
58 | public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName; | |
59 | ||
60 | // ------------------------------------------------------------------------ | |
61 | // Attributes | |
62 | // ------------------------------------------------------------------------ | |
63 | /** | |
64 | * The base event component which this property source is for. | |
65 | */ | |
66 | private final BaseEventComponent fBaseEvent; | |
67 | ||
68 | // ------------------------------------------------------------------------ | |
69 | // Constructors | |
70 | // ------------------------------------------------------------------------ | |
71 | /** | |
72 | * Constructor | |
73 | * @param component - the base event component | |
74 | */ | |
75 | public BaseEventPropertySource(BaseEventComponent component) { | |
76 | fBaseEvent = component; | |
77 | } | |
78 | ||
79 | // ------------------------------------------------------------------------ | |
80 | // Operations | |
81 | // ------------------------------------------------------------------------ | |
82 | /* | |
83 | * (non-Javadoc) | |
31a6a4e4 | 84 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors() |
06b9339e BH |
85 | */ |
86 | @Override | |
87 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
ccc66d01 BH |
88 | List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> (); |
89 | list.add(new TextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID, BASE_EVENT_NAME_PROPERTY_NAME)); | |
90 | list.add(new TextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID, BASE_EVENT_TYPE_PROPERTY_NAME)); | |
91 | if (fBaseEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) { | |
92 | list.add(new TextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID, BASE_EVENT_LOGLEVEL_PROPERTY_NAME)); | |
93 | } | |
94 | return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]); | |
06b9339e BH |
95 | } |
96 | ||
97 | /* | |
98 | * (non-Javadoc) | |
31a6a4e4 | 99 | * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object) |
06b9339e BH |
100 | */ |
101 | @Override | |
102 | public Object getPropertyValue(Object id) { | |
103 | if(BASE_EVENT_NAME_PROPERTY_ID.equals(id)) { | |
104 | return fBaseEvent.getName(); | |
105 | } | |
106 | if (BASE_EVENT_TYPE_PROPERTY_ID.equals(id)) { | |
107 | return fBaseEvent.getEventType().name(); | |
108 | } | |
109 | if (BASE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) { | |
110 | return fBaseEvent.getLogLevel().name(); | |
111 | } | |
112 | return null; | |
113 | } | |
114 | ||
115 | } |