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
.lttng
.ui
.views
.control
.property
;
14 import java
.util
.ArrayList
;
15 import java
.util
.List
;
17 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.Messages
;
18 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceLogLevel
;
19 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
.TraceEventComponent
;
20 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
21 import org
.eclipse
.ui
.views
.properties
.TextPropertyDescriptor
;
24 * <b><u>TraceEventPropertySource</u></b>
26 * Property source implementation for the trace event component.
29 public class TraceEventPropertySource
extends BasePropertySource
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * The trace event 'name' property ID.
37 public static final String TRACE_EVENT_NAME_PROPERTY_ID
= "trace.event.name"; //$NON-NLS-1$
39 * The trace event 'type' property ID.
41 public static final String TRACE_EVENT_TYPE_PROPERTY_ID
= "trace.event.type"; //$NON-NLS-1$
43 * The trace event 'log level' property ID.
45 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_ID
= "trace.event.loglevel"; //$NON-NLS-1$
47 * The trace event 'state' property ID.
49 public static final String TRACE_EVENT_STATE_PROPERTY_ID
= "trace.event.state"; //$NON-NLS-1$
51 * The trace event 'name' property name.
53 public static final String TRACE_EVENT_NAME_PROPERTY_NAME
= Messages
.TraceControl_EventNamePropertyName
;
55 * The trace event 'type' property name.
57 public static final String TRACE_EVENT_TYPE_PROPERTY_NAME
= Messages
.TraceControl_EventTypePropertyName
;
59 * The trace event 'log level' property name.
61 public static final String TRACE_EVENT_LOGLEVEL_PROPERTY_NAME
= Messages
.TraceControl_LogLevelPropertyName
;
63 * The trace event 'state' property name.
65 public static final String TRACE_EVENT_STATE_PROPERTY_NAME
= Messages
.TraceControl_StatePropertyName
;
67 // ------------------------------------------------------------------------
69 // ------------------------------------------------------------------------
71 * The event component which this property source is for.
73 private final TraceEventComponent fEvent
;
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
80 * @param component - the base event component
82 public TraceEventPropertySource(TraceEventComponent component
) {
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 * @see org.eclipse.linuxtools.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
94 public IPropertyDescriptor
[] getPropertyDescriptors() {
95 List
<IPropertyDescriptor
> list
= new ArrayList
<IPropertyDescriptor
> ();
96 list
.add(new TextPropertyDescriptor(TRACE_EVENT_NAME_PROPERTY_ID
, TRACE_EVENT_NAME_PROPERTY_NAME
));
97 list
.add(new TextPropertyDescriptor(TRACE_EVENT_TYPE_PROPERTY_ID
, TRACE_EVENT_TYPE_PROPERTY_NAME
));
98 list
.add( new TextPropertyDescriptor(TRACE_EVENT_STATE_PROPERTY_ID
, TRACE_EVENT_STATE_PROPERTY_NAME
));
99 if (fEvent
.getLogLevel() != TraceLogLevel
.LEVEL_UNKNOWN
) {
100 list
.add(new TextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID
, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME
));
102 return (IPropertyDescriptor
[])list
.toArray(new IPropertyDescriptor
[list
.size()]);
107 * @see org.eclipse.linuxtools.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
110 public Object
getPropertyValue(Object id
) {
111 if(TRACE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
112 return fEvent
.getName();
114 if (TRACE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
115 return fEvent
.getEventType().name();
117 if (TRACE_EVENT_LOGLEVEL_PROPERTY_ID
.equals(id
)) {
118 return fEvent
.getLogLevel().name();
120 if (TRACE_EVENT_STATE_PROPERTY_ID
.equals(id
)) {
121 return fEvent
.getState().name();