gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / property / BaseEventPropertySource.java
CommitLineData
06b9339e 1/**********************************************************************
60ae41e1 2 * Copyright (c) 2012, 2014 Ericsson
cfdb727a 3 *
06b9339e
BH
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
cfdb727a
AM
8 *
9 * Contributors:
080600d9
MAL
10 * Bernd Hufmann - Initial API and implementation
11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
06b9339e 12 **********************************************************************/
8e8c0226 13package org.eclipse.linuxtools.internal.lttng2.control.ui.views.property;
06b9339e 14
ccc66d01
BH
15import java.util.ArrayList;
16import java.util.List;
17
8e8c0226
AM
18import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel;
19import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages;
20import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.BaseEventComponent;
080600d9 21import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
06b9339e 22import org.eclipse.ui.views.properties.IPropertyDescriptor;
06b9339e
BH
23
24/**
06b9339e
BH
25 * <p>
26 * Property source implementation for the base event component.
27 * </p>
cfdb727a 28 *
dbd4432d 29 * @author Bernd Hufmann
06b9339e
BH
30 */
31public class BaseEventPropertySource extends BasePropertySource {
32
33 // ------------------------------------------------------------------------
34 // Constants
35 // ------------------------------------------------------------------------
36
37 /**
38 * The base event 'name' property ID.
39 */
40 public static final String BASE_EVENT_NAME_PROPERTY_ID = "base.event.name"; //$NON-NLS-1$
41 /**
42 * The base event 'type' property ID.
43 */
44 public static final String BASE_EVENT_TYPE_PROPERTY_ID = "base.event.type"; //$NON-NLS-1$
45 /**
46 * The base event 'log level' property ID.
47 */
48 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_ID = "base.event.loglevel"; //$NON-NLS-1$
d4514365
BH
49 /**
50 * The base event 'fields' property ID.
51 */
52 public static final String BASE_EVENT_FIELDS_PROPERTY_ID = "base.event.fields"; //$NON-NLS-1$
06b9339e 53 /**
cfdb727a 54 * The base event 'name' property name.
06b9339e
BH
55 */
56 public static final String BASE_EVENT_NAME_PROPERTY_NAME = Messages.TraceControl_EventNamePropertyName;
57 /**
58 * The base event 'type' property name.
59 */
60 public static final String BASE_EVENT_TYPE_PROPERTY_NAME = Messages.TraceControl_EventTypePropertyName;
61 /**
62 * The base event 'log level' property name.
63 */
64 public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName;
d4514365
BH
65 /**
66 * The base event 'fields' property name.
67 */
68 public static final String BASE_EVENT_FIELDS_PROPERTY_NAME = Messages.TraceControl_FieldsPropertyName;
cfdb727a 69
06b9339e
BH
70 // ------------------------------------------------------------------------
71 // Attributes
72 // ------------------------------------------------------------------------
73 /**
cfdb727a 74 * The base event component which this property source is for.
06b9339e
BH
75 */
76 private final BaseEventComponent fBaseEvent;
cfdb727a 77
06b9339e
BH
78 // ------------------------------------------------------------------------
79 // Constructors
80 // ------------------------------------------------------------------------
81 /**
82 * Constructor
83 * @param component - the base event component
84 */
85 public BaseEventPropertySource(BaseEventComponent component) {
86 fBaseEvent = component;
87 }
cfdb727a 88
06b9339e
BH
89 // ------------------------------------------------------------------------
90 // Operations
91 // ------------------------------------------------------------------------
11252342 92
06b9339e
BH
93 @Override
94 public IPropertyDescriptor[] getPropertyDescriptors() {
e0838ca1 95 List<IPropertyDescriptor> list = new ArrayList<> ();
5a7326dc
BH
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));
ccc66d01 98 if (fBaseEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
5a7326dc 99 list.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID, BASE_EVENT_LOGLEVEL_PROPERTY_NAME));
ccc66d01 100 }
d4514365 101 if (fBaseEvent.getFieldString() != null) {
5a7326dc 102 list.add(new ReadOnlyTextPropertyDescriptor(BASE_EVENT_FIELDS_PROPERTY_ID, BASE_EVENT_FIELDS_PROPERTY_NAME));
d4514365 103 }
cfdb727a 104 return list.toArray(new IPropertyDescriptor[list.size()]);
06b9339e
BH
105 }
106
06b9339e
BH
107 @Override
108 public Object getPropertyValue(Object id) {
109 if(BASE_EVENT_NAME_PROPERTY_ID.equals(id)) {
110 return fBaseEvent.getName();
111 }
112 if (BASE_EVENT_TYPE_PROPERTY_ID.equals(id)) {
113 return fBaseEvent.getEventType().name();
114 }
115 if (BASE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
116 return fBaseEvent.getLogLevel().name();
117 }
d4514365
BH
118 if (BASE_EVENT_FIELDS_PROPERTY_ID.equals(id)) {
119 return fBaseEvent.getFieldString();
120 }
06b9339e
BH
121 return null;
122 }
123
124}
This page took 0.062049 seconds and 5 git commands to generate.