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