Commit | Line | Data |
---|---|---|
06b9339e | 1 | /********************************************************************** |
60ae41e1 | 2 | * Copyright (c) 2012, 2014 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: | |
080600d9 MAL |
10 | * Bernd Hufmann - Initial API and implementation |
11 | * Bernd Hufmann - Updated for support of LTTng Tools 2.1 | |
06b9339e | 12 | **********************************************************************/ |
8e8c0226 | 13 | package org.eclipse.linuxtools.internal.lttng2.control.ui.views.property; |
06b9339e | 14 | |
ccc66d01 BH |
15 | import java.util.ArrayList; |
16 | import java.util.List; | |
17 | ||
8e8c0226 AM |
18 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel; |
19 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages; | |
20 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceEventComponent; | |
080600d9 | 21 | import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor; |
06b9339e | 22 | import org.eclipse.ui.views.properties.IPropertyDescriptor; |
06b9339e BH |
23 | |
24 | /** | |
06b9339e BH |
25 | * <p> |
26 | * Property source implementation for the trace event component. | |
27 | * </p> | |
cfdb727a | 28 | * |
dbd4432d | 29 | * @author Bernd Hufmann |
06b9339e BH |
30 | */ |
31 | public class TraceEventPropertySource extends BasePropertySource { | |
32 | ||
33 | // ------------------------------------------------------------------------ | |
34 | // Constants | |
35 | // ------------------------------------------------------------------------ | |
36 | /** | |
37 | * The trace event 'name' property ID. | |
38 | */ | |
39 | public static final String TRACE_EVENT_NAME_PROPERTY_ID = "trace.event.name"; //$NON-NLS-1$ | |
40 | /** | |
41 | * The trace event 'type' property ID. | |
42 | */ | |
43 | public static final String TRACE_EVENT_TYPE_PROPERTY_ID = "trace.event.type"; //$NON-NLS-1$ | |
44 | /** | |
45 | * The trace event 'log level' property ID. | |
46 | */ | |
47 | public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_ID = "trace.event.loglevel"; //$NON-NLS-1$ | |
48 | /** | |
49 | * The trace event 'state' property ID. | |
50 | */ | |
51 | public static final String TRACE_EVENT_STATE_PROPERTY_ID = "trace.event.state"; //$NON-NLS-1$ | |
d4514365 BH |
52 | /** |
53 | * The trace event 'filter' property ID. | |
54 | */ | |
55 | public static final String TRACE_EVENT_FILTER_PROPERTY_ID = "trace.event.filter"; //$NON-NLS-1$ | |
56 | ||
06b9339e | 57 | /** |
cfdb727a | 58 | * The trace event 'name' property name. |
06b9339e BH |
59 | */ |
60 | public static final String TRACE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName; | |
61 | /** | |
62 | * The trace event 'type' property name. | |
63 | */ | |
64 | public static final String TRACE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName; | |
65 | /** | |
66 | * The trace event 'log level' property name. | |
67 | */ | |
68 | public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName; | |
69 | /** | |
70 | * The trace event 'state' property name. | |
71 | */ | |
72 | public static final String TRACE_EVENT_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; | |
d4514365 BH |
73 | /** |
74 | * The trace event 'filter' property name. | |
75 | */ | |
76 | public static final String TRACE_EVENT_FILTER_PROPERTY_NAME = Messages.TraceControl_FilterPropertyName; | |
06b9339e BH |
77 | |
78 | // ------------------------------------------------------------------------ | |
79 | // Attributes | |
80 | // ------------------------------------------------------------------------ | |
11252342 | 81 | |
06b9339e | 82 | /** |
cfdb727a | 83 | * The event component which this property source is for. |
06b9339e | 84 | */ |
d132bcc7 | 85 | protected final TraceEventComponent fEvent; |
cfdb727a | 86 | |
06b9339e BH |
87 | // ------------------------------------------------------------------------ |
88 | // Constructors | |
89 | // ------------------------------------------------------------------------ | |
11252342 | 90 | |
06b9339e BH |
91 | /** |
92 | * Constructor | |
93 | * @param component - the base event component | |
94 | */ | |
95 | public TraceEventPropertySource(TraceEventComponent component) { | |
96 | fEvent = component; | |
97 | } | |
cfdb727a | 98 | |
06b9339e BH |
99 | // ------------------------------------------------------------------------ |
100 | // Operations | |
101 | // ------------------------------------------------------------------------ | |
11252342 | 102 | |
06b9339e BH |
103 | @Override |
104 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
e0838ca1 | 105 | List<IPropertyDescriptor> list = new ArrayList<> (); |
5a7326dc BH |
106 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_NAME_PROPERTY_ID, TRACE_EVENT_NAME_PROPERTY_NAME)); |
107 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_TYPE_PROPERTY_ID, TRACE_EVENT_TYPE_PROPERTY_NAME)); | |
108 | list.add( new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_STATE_PROPERTY_ID, TRACE_EVENT_STATE_PROPERTY_NAME)); | |
ccc66d01 | 109 | if (fEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) { |
5a7326dc | 110 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME)); |
ccc66d01 | 111 | } |
d4514365 | 112 | if (fEvent.getFilterExpression() != null) { |
5a7326dc | 113 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_FILTER_PROPERTY_ID, TRACE_EVENT_FILTER_PROPERTY_NAME)); |
d4514365 | 114 | } |
cfdb727a | 115 | return list.toArray(new IPropertyDescriptor[list.size()]); |
06b9339e BH |
116 | } |
117 | ||
06b9339e BH |
118 | @Override |
119 | public Object getPropertyValue(Object id) { | |
120 | if(TRACE_EVENT_NAME_PROPERTY_ID.equals(id)) { | |
121 | return fEvent.getName(); | |
122 | } | |
123 | if (TRACE_EVENT_TYPE_PROPERTY_ID.equals(id)) { | |
124 | return fEvent.getEventType().name(); | |
125 | } | |
126 | if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) { | |
127 | return fEvent.getLogLevel().name(); | |
128 | } | |
129 | if (TRACE_EVENT_STATE_PROPERTY_ID.equals(id)) { | |
130 | return fEvent.getState().name(); | |
131 | } | |
d4514365 BH |
132 | if (TRACE_EVENT_FILTER_PROPERTY_ID.equals(id)) { |
133 | return fEvent.getFilterExpression(); | |
134 | } | |
135 | ||
06b9339e BH |
136 | return null; |
137 | } | |
138 | ||
139 | } |