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