tmf: use ReadOnlyTextPropertyDescriptor in project model
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / property / TraceEventPropertySource.java
CommitLineData
06b9339e 1/**********************************************************************
ba3a9bd2 2 * Copyright (c) 2012, 2013 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 10 * Bernd Hufmann - Initial API and implementation
ba3a9bd2 11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
06b9339e 12 **********************************************************************/
115b4a01 13package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
06b9339e 14
ccc66d01
BH
15import java.util.ArrayList;
16import java.util.List;
17
9315aeee
BH
18import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
19import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
115b4a01 20import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
06b9339e
BH
21import org.eclipse.ui.views.properties.IPropertyDescriptor;
22import org.eclipse.ui.views.properties.TextPropertyDescriptor;
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 */
31public 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 // ------------------------------------------------------------------------
81 /**
cfdb727a 82 * The event component which this property source is for.
06b9339e 83 */
d132bcc7 84 protected final TraceEventComponent fEvent;
cfdb727a 85
06b9339e
BH
86 // ------------------------------------------------------------------------
87 // Constructors
88 // ------------------------------------------------------------------------
89 /**
90 * Constructor
91 * @param component - the base event component
92 */
93 public TraceEventPropertySource(TraceEventComponent component) {
94 fEvent = component;
95 }
cfdb727a 96
06b9339e
BH
97 // ------------------------------------------------------------------------
98 // Operations
99 // ------------------------------------------------------------------------
100 /*
101 * (non-Javadoc)
115b4a01 102 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
06b9339e
BH
103 */
104 @Override
105 public IPropertyDescriptor[] getPropertyDescriptors() {
ccc66d01
BH
106 List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> ();
107 list.add(new TextPropertyDescriptor(TRACE_EVENT_NAME_PROPERTY_ID, TRACE_EVENT_NAME_PROPERTY_NAME));
108 list.add(new TextPropertyDescriptor(TRACE_EVENT_TYPE_PROPERTY_ID, TRACE_EVENT_TYPE_PROPERTY_NAME));
109 list.add( new TextPropertyDescriptor(TRACE_EVENT_STATE_PROPERTY_ID, TRACE_EVENT_STATE_PROPERTY_NAME));
110 if (fEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
111 list.add(new TextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME));
112 }
d4514365
BH
113 if (fEvent.getFilterExpression() != null) {
114 list.add(new TextPropertyDescriptor(TRACE_EVENT_FILTER_PROPERTY_ID, TRACE_EVENT_FILTER_PROPERTY_NAME));
115 }
cfdb727a 116 return list.toArray(new IPropertyDescriptor[list.size()]);
06b9339e
BH
117 }
118
119 /*
120 * (non-Javadoc)
115b4a01 121 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
06b9339e
BH
122 */
123 @Override
124 public Object getPropertyValue(Object id) {
125 if(TRACE_EVENT_NAME_PROPERTY_ID.equals(id)) {
126 return fEvent.getName();
127 }
128 if (TRACE_EVENT_TYPE_PROPERTY_ID.equals(id)) {
129 return fEvent.getEventType().name();
130 }
131 if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
132 return fEvent.getLogLevel().name();
133 }
134 if (TRACE_EVENT_STATE_PROPERTY_ID.equals(id)) {
135 return fEvent.getState().name();
136 }
d4514365
BH
137 if (TRACE_EVENT_FILTER_PROPERTY_ID.equals(id)) {
138 return fEvent.getFilterExpression();
139 }
140
06b9339e
BH
141 return null;
142 }
143
144}
This page took 0.041159 seconds and 5 git commands to generate.