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
.BaseEventComponent
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.util
.ReadOnlyTextPropertyDescriptor
;
22 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
26 * Property source implementation for the base event component.
29 * @author Bernd Hufmann
31 public class BaseEventPropertySource
extends BasePropertySource
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
38 * The base event 'name' property ID.
40 public static final String BASE_EVENT_NAME_PROPERTY_ID
= "base.event.name"; //$NON-NLS-1$
42 * The base event 'type' property ID.
44 public static final String BASE_EVENT_TYPE_PROPERTY_ID
= "base.event.type"; //$NON-NLS-1$
46 * The base event 'log level' property ID.
48 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_ID
= "base.event.loglevel"; //$NON-NLS-1$
50 * The base event 'fields' property ID.
52 public static final String BASE_EVENT_FIELDS_PROPERTY_ID
= "base.event.fields"; //$NON-NLS-1$
54 * The base event 'name' property name.
56 public static final String BASE_EVENT_NAME_PROPERTY_NAME
= Messages
.TraceControl_EventNamePropertyName
;
58 * The base event 'type' property name.
60 public static final String BASE_EVENT_TYPE_PROPERTY_NAME
= Messages
.TraceControl_EventTypePropertyName
;
62 * The base event 'log level' property name.
64 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME
= Messages
.TraceControl_LogLevelPropertyName
;
66 * The base event 'fields' property name.
68 public static final String BASE_EVENT_FIELDS_PROPERTY_NAME
= Messages
.TraceControl_FieldsPropertyName
;
70 // ------------------------------------------------------------------------
72 // ------------------------------------------------------------------------
74 * The base event component which this property source is for.
76 private final BaseEventComponent fBaseEvent
;
78 // ------------------------------------------------------------------------
80 // ------------------------------------------------------------------------
83 * @param component - the base event component
85 public BaseEventPropertySource(BaseEventComponent component
) {
86 fBaseEvent
= component
;
89 // ------------------------------------------------------------------------
91 // ------------------------------------------------------------------------
94 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
97 public IPropertyDescriptor
[] getPropertyDescriptors() {
98 List
<IPropertyDescriptor
> list
= new ArrayList
<IPropertyDescriptor
> ();
99 list
.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID
, BASE_EVENT_NAME_PROPERTY_NAME
));
100 list
.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID
, BASE_EVENT_TYPE_PROPERTY_NAME
));
101 if (fBaseEvent
.getLogLevel() != TraceLogLevel
.LEVEL_UNKNOWN
) {
102 list
.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID
, BASE_EVENT_LOGLEVEL_PROPERTY_NAME
));
104 if (fBaseEvent
.getFieldString() != null) {
105 list
.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_FIELDS_PROPERTY_ID
, BASE_EVENT_FIELDS_PROPERTY_NAME
));
107 return list
.toArray(new IPropertyDescriptor
[list
.size()]);
112 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
115 public Object
getPropertyValue(Object id
) {
116 if(BASE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
117 return fBaseEvent
.getName();
119 if (BASE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
120 return fBaseEvent
.getEventType().name();
122 if (BASE_EVENT_LOGLEVEL_PROPERTY_ID
.equals(id
)) {
123 return fBaseEvent
.getLogLevel().name();
125 if (BASE_EVENT_FIELDS_PROPERTY_ID
.equals(id
)) {
126 return fBaseEvent
.getFieldString();