1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
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
.ui
.views
.control
.property
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceEventComponent
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.util
.ReadOnlyTextPropertyDescriptor
;
22 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
26 * Property source implementation for the trace event component.
29 * @author Bernd Hufmann
31 public class TraceEventPropertySource
extends BasePropertySource
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 * The trace event 'name' property ID.
39 public static final String TRACE_EVENT_NAME_PROPERTY_ID
= "trace.event.name"; //$NON-NLS-1$
41 * The trace event 'type' property ID.
43 public static final String TRACE_EVENT_TYPE_PROPERTY_ID
= "trace.event.type"; //$NON-NLS-1$
45 * The trace event 'log level' property ID.
47 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_ID
= "trace.event.loglevel"; //$NON-NLS-1$
49 * The trace event 'state' property ID.
51 public static final String TRACE_EVENT_STATE_PROPERTY_ID
= "trace.event.state"; //$NON-NLS-1$
53 * The trace event 'filter' property ID.
55 public static final String TRACE_EVENT_FILTER_PROPERTY_ID
= "trace.event.filter"; //$NON-NLS-1$
58 * The trace event 'name' property name.
60 public static final String TRACE_EVENT_NAME_PROPERTY_NAME
= Messages
.TraceControl_EventNamePropertyName
;
62 * The trace event 'type' property name.
64 public static final String TRACE_EVENT_TYPE_PROPERTY_NAME
= Messages
.TraceControl_EventTypePropertyName
;
66 * The trace event 'log level' property name.
68 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME
= Messages
.TraceControl_LogLevelPropertyName
;
70 * The trace event 'state' property name.
72 public static final String TRACE_EVENT_STATE_PROPERTY_NAME
= Messages
.TraceControl_StatePropertyName
;
74 * The trace event 'filter' property name.
76 public static final String TRACE_EVENT_FILTER_PROPERTY_NAME
= Messages
.TraceControl_FilterPropertyName
;
78 // ------------------------------------------------------------------------
80 // ------------------------------------------------------------------------
82 * The event component which this property source is for.
84 protected final TraceEventComponent fEvent
;
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 * @param component - the base event component
93 public TraceEventPropertySource(TraceEventComponent component
) {
97 // ------------------------------------------------------------------------
99 // ------------------------------------------------------------------------
102 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
105 public IPropertyDescriptor
[] getPropertyDescriptors() {
106 List
<IPropertyDescriptor
> list
= new ArrayList
<IPropertyDescriptor
> ();
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
));
113 if (fEvent
.getFilterExpression() != null) {
114 list
.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_FILTER_PROPERTY_ID
, TRACE_EVENT_FILTER_PROPERTY_NAME
));
116 return list
.toArray(new IPropertyDescriptor
[list
.size()]);
121 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
124 public Object
getPropertyValue(Object id
) {
125 if(TRACE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
126 return fEvent
.getName();
128 if (TRACE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
129 return fEvent
.getEventType().name();
131 if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID
.equals(id
)) {
132 return fEvent
.getLogLevel().name();
134 if (TRACE_EVENT_STATE_PROPERTY_ID
.equals(id
)) {
135 return fEvent
.getState().name();
137 if (TRACE_EVENT_FILTER_PROPERTY_ID
.equals(id
)) {
138 return fEvent
.getFilterExpression();