1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
;
14 import java
.util
.ArrayList
;
15 import java
.util
.List
;
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
;
25 * Property source implementation for the trace event component.
28 * @author Bernd Hufmann
30 public class TraceEventPropertySource
extends BasePropertySource
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 * The trace event 'name' property ID.
38 public static final String TRACE_EVENT_NAME_PROPERTY_ID
= "trace.event.name"; //$NON-NLS-1$
40 * The trace event 'type' property ID.
42 public static final String TRACE_EVENT_TYPE_PROPERTY_ID
= "trace.event.type"; //$NON-NLS-1$
44 * The trace event 'log level' property ID.
46 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_ID
= "trace.event.loglevel"; //$NON-NLS-1$
48 * The trace event 'state' property ID.
50 public static final String TRACE_EVENT_STATE_PROPERTY_ID
= "trace.event.state"; //$NON-NLS-1$
52 * The trace event 'name' property name.
54 public static final String TRACE_EVENT_NAME_PROPERTY_NAME
= Messages
.TraceControl_EventNamePropertyName
;
56 * The trace event 'type' property name.
58 public static final String TRACE_EVENT_TYPE_PROPERTY_NAME
= Messages
.TraceControl_EventTypePropertyName
;
60 * The trace event 'log level' property name.
62 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME
= Messages
.TraceControl_LogLevelPropertyName
;
64 * The trace event 'state' property name.
66 public static final String TRACE_EVENT_STATE_PROPERTY_NAME
= Messages
.TraceControl_StatePropertyName
;
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
72 * The event component which this property source is for.
74 protected final TraceEventComponent fEvent
;
76 // ------------------------------------------------------------------------
78 // ------------------------------------------------------------------------
81 * @param component - the base event component
83 public TraceEventPropertySource(TraceEventComponent component
) {
87 // ------------------------------------------------------------------------
89 // ------------------------------------------------------------------------
92 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
95 public IPropertyDescriptor
[] getPropertyDescriptors() {
96 List
<IPropertyDescriptor
> list
= new ArrayList
<IPropertyDescriptor
> ();
97 list
.add(new TextPropertyDescriptor(TRACE_EVENT_NAME_PROPERTY_ID
, TRACE_EVENT_NAME_PROPERTY_NAME
));
98 list
.add(new TextPropertyDescriptor(TRACE_EVENT_TYPE_PROPERTY_ID
, TRACE_EVENT_TYPE_PROPERTY_NAME
));
99 list
.add( new TextPropertyDescriptor(TRACE_EVENT_STATE_PROPERTY_ID
, TRACE_EVENT_STATE_PROPERTY_NAME
));
100 if (fEvent
.getLogLevel() != TraceLogLevel
.LEVEL_UNKNOWN
) {
101 list
.add(new TextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID
, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME
));
103 return (IPropertyDescriptor
[])list
.toArray(new IPropertyDescriptor
[list
.size()]);
108 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
111 public Object
getPropertyValue(Object id
) {
112 if(TRACE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
113 return fEvent
.getName();
115 if (TRACE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
116 return fEvent
.getEventType().name();
118 if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID
.equals(id
)) {
119 return fEvent
.getLogLevel().name();
121 if (TRACE_EVENT_STATE_PROPERTY_ID
.equals(id
)) {
122 return fEvent
.getState().name();