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
.lttng
.ui
.views
.control
.property
;
14 import java
.util
.ArrayList
;
15 import java
.util
.List
;
17 import org
.eclipse
.linuxtools
.internal
.lttng
.ui
.views
.control
.Messages
;
18 import org
.eclipse
.linuxtools
.internal
.lttng
.ui
.views
.control
.model
.TraceLogLevel
;
19 import org
.eclipse
.linuxtools
.internal
.lttng
.ui
.views
.control
.model
.impl
.BaseEventComponent
;
20 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
21 import org
.eclipse
.ui
.views
.properties
.TextPropertyDescriptor
;
24 * <b><u>BaseEventPropertySource</u></b>
26 * Property source implementation for the base event component.
29 public class BaseEventPropertySource
extends BasePropertySource
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
36 * The base event 'name' property ID.
38 public static final String BASE_EVENT_NAME_PROPERTY_ID
= "base.event.name"; //$NON-NLS-1$
40 * The base event 'type' property ID.
42 public static final String BASE_EVENT_TYPE_PROPERTY_ID
= "base.event.type"; //$NON-NLS-1$
44 * The base event 'log level' property ID.
46 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_ID
= "base.event.loglevel"; //$NON-NLS-1$
48 * The base event 'name' property name.
50 public static final String BASE_EVENT_NAME_PROPERTY_NAME
= Messages
.TraceControl_EventNamePropertyName
;
52 * The base event 'type' property name.
54 public static final String BASE_EVENT_TYPE_PROPERTY_NAME
= Messages
.TraceControl_EventTypePropertyName
;
56 * The base event 'log level' property name.
58 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME
= Messages
.TraceControl_LogLevelPropertyName
;
60 // ------------------------------------------------------------------------
62 // ------------------------------------------------------------------------
64 * The base event component which this property source is for.
66 private final BaseEventComponent fBaseEvent
;
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
73 * @param component - the base event component
75 public BaseEventPropertySource(BaseEventComponent component
) {
76 fBaseEvent
= component
;
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
87 public IPropertyDescriptor
[] getPropertyDescriptors() {
88 List
<IPropertyDescriptor
> list
= new ArrayList
<IPropertyDescriptor
> ();
89 list
.add(new TextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID
, BASE_EVENT_NAME_PROPERTY_NAME
));
90 list
.add(new TextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID
, BASE_EVENT_TYPE_PROPERTY_NAME
));
91 if (fBaseEvent
.getLogLevel() != TraceLogLevel
.LEVEL_UNKNOWN
) {
92 list
.add(new TextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID
, BASE_EVENT_LOGLEVEL_PROPERTY_NAME
));
94 return (IPropertyDescriptor
[])list
.toArray(new IPropertyDescriptor
[list
.size()]);
99 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
102 public Object
getPropertyValue(Object id
) {
103 if(BASE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
104 return fBaseEvent
.getName();
106 if (BASE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
107 return fBaseEvent
.getEventType().name();
109 if (BASE_EVENT_LOGLEVEL_PROPERTY_ID
.equals(id
)) {
110 return fBaseEvent
.getLogLevel().name();