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
1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
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;
22
23 /**
24 * <p>
25 * Property source implementation for the base event component.
26 * </p>
27 *
28 * @author Bernd Hufmann
29 */
30 public 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$
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$
52 /**
53 * The base event 'name' property name.
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;
64 /**
65 * The base event 'fields' property name.
66 */
67 public static final String BASE_EVENT_FIELDS_PROPERTY_NAME = Messages.TraceControl_FieldsPropertyName;
68
69 // ------------------------------------------------------------------------
70 // Attributes
71 // ------------------------------------------------------------------------
72 /**
73 * The base event component which this property source is for.
74 */
75 private final BaseEventComponent fBaseEvent;
76
77 // ------------------------------------------------------------------------
78 // Constructors
79 // ------------------------------------------------------------------------
80 /**
81 * Constructor
82 * @param component - the base event component
83 */
84 public BaseEventPropertySource(BaseEventComponent component) {
85 fBaseEvent = component;
86 }
87
88 // ------------------------------------------------------------------------
89 // Operations
90 // ------------------------------------------------------------------------
91 /*
92 * (non-Javadoc)
93 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
94 */
95 @Override
96 public IPropertyDescriptor[] getPropertyDescriptors() {
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 }
103 if (fBaseEvent.getFieldString() != null) {
104 list.add(new TextPropertyDescriptor(BASE_EVENT_FIELDS_PROPERTY_ID, BASE_EVENT_FIELDS_PROPERTY_NAME));
105 }
106 return list.toArray(new IPropertyDescriptor[list.size()]);
107 }
108
109 /*
110 * (non-Javadoc)
111 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
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 }
124 if (BASE_EVENT_FIELDS_PROPERTY_ID.equals(id)) {
125 return fBaseEvent.getFieldString();
126 }
127 return null;
128 }
129
130 }
This page took 0.033217 seconds and 5 git commands to generate.