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
.tracecompass
.internal
.lttng2
.control
.ui
.views
.property
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
19 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
20 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.BaseEventComponent
;
21 import org
.eclipse
.tracecompass
.tmf
.ui
.properties
.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 public IPropertyDescriptor
[] getPropertyDescriptors() {
95 List
<IPropertyDescriptor
> list
= new ArrayList
<> ();
96 list
.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID
, BASE_EVENT_NAME_PROPERTY_NAME
));
97 list
.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID
, BASE_EVENT_TYPE_PROPERTY_NAME
));
98 if (fBaseEvent
.getLogLevel() != TraceLogLevel
.LEVEL_UNKNOWN
) {
99 list
.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID
, BASE_EVENT_LOGLEVEL_PROPERTY_NAME
));
101 if (fBaseEvent
.getFieldString() != null) {
102 list
.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_FIELDS_PROPERTY_ID
, BASE_EVENT_FIELDS_PROPERTY_NAME
));
104 return list
.toArray(new IPropertyDescriptor
[list
.size()]);
108 public Object
getPropertyValue(Object id
) {
109 if(BASE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
110 return fBaseEvent
.getName();
112 if (BASE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
113 return fBaseEvent
.getEventType().name();
115 if (BASE_EVENT_LOGLEVEL_PROPERTY_ID
.equals(id
)) {
116 return fBaseEvent
.getLogLevel().name();
118 if (BASE_EVENT_FIELDS_PROPERTY_ID
.equals(id
)) {
119 return fBaseEvent
.getFieldString();