1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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
.control
.ui
.views
.property
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
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
;
27 * Property source implementation for the trace event component.
30 * @author Bernd Hufmann
32 public class TraceEventPropertySource
extends BasePropertySource
{
34 // ------------------------------------------------------------------------
36 // ------------------------------------------------------------------------
38 * The trace event 'name' property ID.
40 public static final String TRACE_EVENT_NAME_PROPERTY_ID
= "trace.event.name"; //$NON-NLS-1$
42 * The trace event 'type' property ID.
44 public static final String TRACE_EVENT_TYPE_PROPERTY_ID
= "trace.event.type"; //$NON-NLS-1$
46 * The trace event 'log level' property ID.
48 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_ID
= "trace.event.loglevel"; //$NON-NLS-1$
50 * The trace event 'state' property ID.
52 public static final String TRACE_EVENT_STATE_PROPERTY_ID
= "trace.event.state"; //$NON-NLS-1$
54 * The trace event 'filter' property ID.
56 public static final String TRACE_EVENT_FILTER_PROPERTY_ID
= "trace.event.filter"; //$NON-NLS-1$
59 * The trace event 'name' property name.
61 public static final String TRACE_EVENT_NAME_PROPERTY_NAME
= Messages
.TraceControl_EventNamePropertyName
;
63 * The trace event 'type' property name.
65 public static final String TRACE_EVENT_TYPE_PROPERTY_NAME
= Messages
.TraceControl_EventTypePropertyName
;
67 * The trace event 'log level' property name.
69 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME
= Messages
.TraceControl_LogLevelPropertyName
;
71 * The trace event 'state' property name.
73 public static final String TRACE_EVENT_STATE_PROPERTY_NAME
= Messages
.TraceControl_StatePropertyName
;
75 * The trace event 'filter' property name.
77 public static final String TRACE_EVENT_FILTER_PROPERTY_NAME
= Messages
.TraceControl_FilterPropertyName
;
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 * The event component which this property source is for.
86 protected final TraceEventComponent fEvent
;
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
94 * @param component - the base event component
96 public TraceEventPropertySource(TraceEventComponent component
) {
100 // ------------------------------------------------------------------------
102 // ------------------------------------------------------------------------
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
));
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()]);
120 public Object
getPropertyValue(Object id
) {
121 if(TRACE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
122 return fEvent
.getName();
124 if (TRACE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
125 return fEvent
.getEventType().name();
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(' ');
132 buffer
.append(fEvent
.getLogLevel().name());
133 return buffer
.toString();
135 if (TRACE_EVENT_STATE_PROPERTY_ID
.equals(id
)) {
136 return fEvent
.getState().name();
138 if (TRACE_EVENT_FILTER_PROPERTY_ID
.equals(id
)) {
139 return fEvent
.getFilterExpression();