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 | **********************************************************************/ | |
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.TraceEventComponent; |
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 trace event component. | |
26 | * </p> | |
dbd4432d BH |
27 | * |
28 | * @author Bernd Hufmann | |
06b9339e BH |
29 | */ |
30 | public class TraceEventPropertySource extends BasePropertySource { | |
31 | ||
32 | // ------------------------------------------------------------------------ | |
33 | // Constants | |
34 | // ------------------------------------------------------------------------ | |
35 | /** | |
36 | * The trace event 'name' property ID. | |
37 | */ | |
38 | public static final String TRACE_EVENT_NAME_PROPERTY_ID = "trace.event.name"; //$NON-NLS-1$ | |
39 | /** | |
40 | * The trace event 'type' property ID. | |
41 | */ | |
42 | public static final String TRACE_EVENT_TYPE_PROPERTY_ID = "trace.event.type"; //$NON-NLS-1$ | |
43 | /** | |
44 | * The trace event 'log level' property ID. | |
45 | */ | |
46 | public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_ID = "trace.event.loglevel"; //$NON-NLS-1$ | |
47 | /** | |
48 | * The trace event 'state' property ID. | |
49 | */ | |
50 | public static final String TRACE_EVENT_STATE_PROPERTY_ID = "trace.event.state"; //$NON-NLS-1$ | |
51 | /** | |
52 | * The trace event 'name' property name. | |
53 | */ | |
54 | public static final String TRACE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName; | |
55 | /** | |
56 | * The trace event 'type' property name. | |
57 | */ | |
58 | public static final String TRACE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName; | |
59 | /** | |
60 | * The trace event 'log level' property name. | |
61 | */ | |
62 | public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName; | |
63 | /** | |
64 | * The trace event 'state' property name. | |
65 | */ | |
66 | public static final String TRACE_EVENT_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName; | |
67 | ||
68 | // ------------------------------------------------------------------------ | |
69 | // Attributes | |
70 | // ------------------------------------------------------------------------ | |
71 | /** | |
72 | * The event component which this property source is for. | |
73 | */ | |
d132bcc7 | 74 | protected final TraceEventComponent fEvent; |
06b9339e BH |
75 | |
76 | // ------------------------------------------------------------------------ | |
77 | // Constructors | |
78 | // ------------------------------------------------------------------------ | |
79 | /** | |
80 | * Constructor | |
81 | * @param component - the base event component | |
82 | */ | |
83 | public TraceEventPropertySource(TraceEventComponent component) { | |
84 | fEvent = component; | |
85 | } | |
86 | ||
87 | // ------------------------------------------------------------------------ | |
88 | // Operations | |
89 | // ------------------------------------------------------------------------ | |
90 | /* | |
91 | * (non-Javadoc) | |
115b4a01 | 92 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors() |
06b9339e BH |
93 | */ |
94 | @Override | |
95 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
ccc66d01 BH |
96 | List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> (); |
97 | list.add(new TextPropertyDescriptor(TRACE_EVENT_NAME_PROPERTY_ID, TRACE_EVENT_NAME_PROPERTY_NAME)); | |
98 | list.add(new TextPropertyDescriptor(TRACE_EVENT_TYPE_PROPERTY_ID, TRACE_EVENT_TYPE_PROPERTY_NAME)); | |
99 | list.add( new TextPropertyDescriptor(TRACE_EVENT_STATE_PROPERTY_ID, TRACE_EVENT_STATE_PROPERTY_NAME)); | |
100 | if (fEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) { | |
101 | list.add(new TextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME)); | |
102 | } | |
103 | return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]); | |
06b9339e BH |
104 | } |
105 | ||
106 | /* | |
107 | * (non-Javadoc) | |
115b4a01 | 108 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object) |
06b9339e BH |
109 | */ |
110 | @Override | |
111 | public Object getPropertyValue(Object id) { | |
112 | if(TRACE_EVENT_NAME_PROPERTY_ID.equals(id)) { | |
113 | return fEvent.getName(); | |
114 | } | |
115 | if (TRACE_EVENT_TYPE_PROPERTY_ID.equals(id)) { | |
116 | return fEvent.getEventType().name(); | |
117 | } | |
118 | if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) { | |
119 | return fEvent.getLogLevel().name(); | |
120 | } | |
121 | if (TRACE_EVENT_STATE_PROPERTY_ID.equals(id)) { | |
122 | return fEvent.getState().name(); | |
123 | } | |
124 | return null; | |
125 | } | |
126 | ||
127 | } |