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