f38d09afd1ea34daded9d05adab90b36fe8e4fbd
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / property / TraceEventPropertySource.java
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 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
18 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
19 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
20 import org.eclipse.ui.views.properties.IPropertyDescriptor;
21 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
22
23 /**
24 * <p>
25 * Property source implementation for the trace event component.
26 * </p>
27 *
28 * @author Bernd Hufmann
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 'filter' property ID.
53 */
54 public static final String TRACE_EVENT_FILTER_PROPERTY_ID = "trace.event.filter"; //$NON-NLS-1$
55
56 /**
57 * The trace event 'name' property name.
58 */
59 public static final String TRACE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName;
60 /**
61 * The trace event 'type' property name.
62 */
63 public static final String TRACE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName;
64 /**
65 * The trace event 'log level' property name.
66 */
67 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName;
68 /**
69 * The trace event 'state' property name.
70 */
71 public static final String TRACE_EVENT_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
72 /**
73 * The trace event 'filter' property name.
74 */
75 public static final String TRACE_EVENT_FILTER_PROPERTY_NAME = Messages.TraceControl_FilterPropertyName;
76
77 // ------------------------------------------------------------------------
78 // Attributes
79 // ------------------------------------------------------------------------
80 /**
81 * The event component which this property source is for.
82 */
83 protected final TraceEventComponent fEvent;
84
85 // ------------------------------------------------------------------------
86 // Constructors
87 // ------------------------------------------------------------------------
88 /**
89 * Constructor
90 * @param component - the base event component
91 */
92 public TraceEventPropertySource(TraceEventComponent component) {
93 fEvent = component;
94 }
95
96 // ------------------------------------------------------------------------
97 // Operations
98 // ------------------------------------------------------------------------
99 /*
100 * (non-Javadoc)
101 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
102 */
103 @Override
104 public IPropertyDescriptor[] getPropertyDescriptors() {
105 List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> ();
106 list.add(new TextPropertyDescriptor(TRACE_EVENT_NAME_PROPERTY_ID, TRACE_EVENT_NAME_PROPERTY_NAME));
107 list.add(new TextPropertyDescriptor(TRACE_EVENT_TYPE_PROPERTY_ID, TRACE_EVENT_TYPE_PROPERTY_NAME));
108 list.add( new TextPropertyDescriptor(TRACE_EVENT_STATE_PROPERTY_ID, TRACE_EVENT_STATE_PROPERTY_NAME));
109 if (fEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
110 list.add(new TextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME));
111 }
112 if (fEvent.getFilterExpression() != null) {
113 list.add(new TextPropertyDescriptor(TRACE_EVENT_FILTER_PROPERTY_ID, TRACE_EVENT_FILTER_PROPERTY_NAME));
114 }
115 return list.toArray(new IPropertyDescriptor[list.size()]);
116 }
117
118 /*
119 * (non-Javadoc)
120 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
121 */
122 @Override
123 public Object getPropertyValue(Object id) {
124 if(TRACE_EVENT_NAME_PROPERTY_ID.equals(id)) {
125 return fEvent.getName();
126 }
127 if (TRACE_EVENT_TYPE_PROPERTY_ID.equals(id)) {
128 return fEvent.getEventType().name();
129 }
130 if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
131 return fEvent.getLogLevel().name();
132 }
133 if (TRACE_EVENT_STATE_PROPERTY_ID.equals(id)) {
134 return fEvent.getState().name();
135 }
136 if (TRACE_EVENT_FILTER_PROPERTY_ID.equals(id)) {
137 return fEvent.getFilterExpression();
138 }
139
140 return null;
141 }
142
143 }
This page took 0.032936 seconds and 5 git commands to generate.