Update file headers in LTTng Control feature
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / property / BaseEventPropertySource.java
CommitLineData
06b9339e 1/**********************************************************************
ba3a9bd2 2 * Copyright (c) 2012, 2013 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:
06b9339e 10 * Bernd Hufmann - Initial API and implementation
ba3a9bd2 11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
06b9339e 12 **********************************************************************/
115b4a01 13package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
06b9339e 14
ccc66d01
BH
15import java.util.ArrayList;
16import java.util.List;
17
9315aeee
BH
18import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
19import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
115b4a01 20import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent;
06b9339e
BH
21import org.eclipse.ui.views.properties.IPropertyDescriptor;
22import org.eclipse.ui.views.properties.TextPropertyDescriptor;
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 // ------------------------------------------------------------------------
92 /*
93 * (non-Javadoc)
115b4a01 94 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
06b9339e
BH
95 */
96 @Override
97 public IPropertyDescriptor[] getPropertyDescriptors() {
ccc66d01
BH
98 List<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor> ();
99 list.add(new TextPropertyDescriptor(BASE_EVENT_NAME_PROPERTY_ID, BASE_EVENT_NAME_PROPERTY_NAME));
100 list.add(new TextPropertyDescriptor(BASE_EVENT_TYPE_PROPERTY_ID, BASE_EVENT_TYPE_PROPERTY_NAME));
101 if (fBaseEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
102 list.add(new TextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID, BASE_EVENT_LOGLEVEL_PROPERTY_NAME));
103 }
d4514365
BH
104 if (fBaseEvent.getFieldString() != null) {
105 list.add(new TextPropertyDescriptor(BASE_EVENT_FIELDS_PROPERTY_ID, BASE_EVENT_FIELDS_PROPERTY_NAME));
106 }
cfdb727a 107 return list.toArray(new IPropertyDescriptor[list.size()]);
06b9339e
BH
108 }
109
110 /*
111 * (non-Javadoc)
115b4a01 112 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
06b9339e
BH
113 */
114 @Override
115 public Object getPropertyValue(Object id) {
116 if(BASE_EVENT_NAME_PROPERTY_ID.equals(id)) {
117 return fBaseEvent.getName();
118 }
119 if (BASE_EVENT_TYPE_PROPERTY_ID.equals(id)) {
120 return fBaseEvent.getEventType().name();
121 }
122 if (BASE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
123 return fBaseEvent.getLogLevel().name();
124 }
d4514365
BH
125 if (BASE_EVENT_FIELDS_PROPERTY_ID.equals(id)) {
126 return fBaseEvent.getFieldString();
127 }
06b9339e
BH
128 return null;
129 }
130
131}
This page took 0.036808 seconds and 5 git commands to generate.