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
.BaseEventComponent
;
20 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
21 import org
.eclipse
.ui
.views
.properties
.TextPropertyDescriptor
;
25 * Property source implementation for the base event component.
28 * @author Bernd Hufmann
30 public class BaseEventPropertySource
extends BasePropertySource
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
37 * The base event 'name' property ID.
39 public static final String BASE_EVENT_NAME_PROPERTY_ID
= "base.event.name"; //$NON-NLS-1$
41 * The base event 'type' property ID.
43 public static final String BASE_EVENT_TYPE_PROPERTY_ID
= "base.event.type"; //$NON-NLS-1$
45 * The base event 'log level' property ID.
47 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_ID
= "base.event.loglevel"; //$NON-NLS-1$
49 * The base event 'fields' property ID.
51 public static final String BASE_EVENT_FIELDS_PROPERTY_ID
= "base.event.fields"; //$NON-NLS-1$
53 * The base event 'name' property name.
55 public static final String BASE_EVENT_NAME_PROPERTY_NAME
= Messages
.TraceControl_EventNamePropertyName
;
57 * The base event 'type' property name.
59 public static final String BASE_EVENT_TYPE_PROPERTY_NAME
= Messages
.TraceControl_EventTypePropertyName
;
61 * The base event 'log level' property name.
63 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME
= Messages
.TraceControl_LogLevelPropertyName
;
65 * The base event 'fields' property name.
67 public static final String BASE_EVENT_FIELDS_PROPERTY_NAME
= Messages
.TraceControl_FieldsPropertyName
;
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
73 * The base event component which this property source is for.
75 private final BaseEventComponent fBaseEvent
;
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
82 * @param component - the base event component
84 public BaseEventPropertySource(BaseEventComponent component
) {
85 fBaseEvent
= component
;
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
93 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
96 public IPropertyDescriptor
[] getPropertyDescriptors() {
97 List
<IPropertyDescriptor
> list
= new ArrayList
<IPropertyDescriptor
> ();
98 list
.add(new TextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID
, BASE_EVENT_NAME_PROPERTY_NAME
));
99 list
.add(new TextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID
, BASE_EVENT_TYPE_PROPERTY_NAME
));
100 if (fBaseEvent
.getLogLevel() != TraceLogLevel
.LEVEL_UNKNOWN
) {
101 list
.add(new TextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID
, BASE_EVENT_LOGLEVEL_PROPERTY_NAME
));
103 if (fBaseEvent
.getFieldString() != null) {
104 list
.add(new TextPropertyDescriptor(BASE_EVENT_FIELDS_PROPERTY_ID
, BASE_EVENT_FIELDS_PROPERTY_NAME
));
106 return list
.toArray(new IPropertyDescriptor
[list
.size()]);
111 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
114 public Object
getPropertyValue(Object id
) {
115 if(BASE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
116 return fBaseEvent
.getName();
118 if (BASE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
119 return fBaseEvent
.getEventType().name();
121 if (BASE_EVENT_LOGLEVEL_PROPERTY_ID
.equals(id
)) {
122 return fBaseEvent
.getLogLevel().name();
124 if (BASE_EVENT_FIELDS_PROPERTY_ID
.equals(id
)) {
125 return fBaseEvent
.getFieldString();