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 'name' property name.
51 public static final String BASE_EVENT_NAME_PROPERTY_NAME
= Messages
.TraceControl_EventNamePropertyName
;
53 * The base event 'type' property name.
55 public static final String BASE_EVENT_TYPE_PROPERTY_NAME
= Messages
.TraceControl_EventTypePropertyName
;
57 * The base event 'log level' property name.
59 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME
= Messages
.TraceControl_LogLevelPropertyName
;
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
65 * The base event component which this property source is for.
67 private final BaseEventComponent fBaseEvent
;
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
74 * @param component - the base event component
76 public BaseEventPropertySource(BaseEventComponent component
) {
77 fBaseEvent
= component
;
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
85 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
88 public IPropertyDescriptor
[] getPropertyDescriptors() {
89 List
<IPropertyDescriptor
> list
= new ArrayList
<IPropertyDescriptor
> ();
90 list
.add(new TextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID
, BASE_EVENT_NAME_PROPERTY_NAME
));
91 list
.add(new TextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID
, BASE_EVENT_TYPE_PROPERTY_NAME
));
92 if (fBaseEvent
.getLogLevel() != TraceLogLevel
.LEVEL_UNKNOWN
) {
93 list
.add(new TextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID
, BASE_EVENT_LOGLEVEL_PROPERTY_NAME
));
95 return list
.toArray(new IPropertyDescriptor
[list
.size()]);
100 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
103 public Object
getPropertyValue(Object id
) {
104 if(BASE_EVENT_NAME_PROPERTY_ID
.equals(id
)) {
105 return fBaseEvent
.getName();
107 if (BASE_EVENT_TYPE_PROPERTY_ID
.equals(id
)) {
108 return fBaseEvent
.getEventType().name();
110 if (BASE_EVENT_LOGLEVEL_PROPERTY_ID
.equals(id
)) {
111 return fBaseEvent
.getLogLevel().name();