Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / property / TraceProbeEventPropertySource.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.Arrays;
16 import java.util.List;
17
18 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages;
19 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
20 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProbeEventComponent;
21 import org.eclipse.ui.views.properties.IPropertyDescriptor;
22 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
23
24 /**
25 * <b><u>TraceEventPropertySource</u></b>
26 * <p>
27 * Property source implementation for the trace probe event component.
28 * </p>
29 */
30 public class TraceProbeEventPropertySource extends TraceEventPropertySource {
31
32 // ------------------------------------------------------------------------
33 // Constants
34 // ------------------------------------------------------------------------
35 /**
36 * The trace event 'probe address' property ID.
37 */
38 public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID = "trace.event.probe.address"; //$NON-NLS-1$
39 /**
40 * The trace event 'probe offset' property ID.
41 */
42 public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID = "trace.event.probe.offset"; //$NON-NLS-1$
43 /**
44 * The trace event 'probe symbol' property ID.
45 */
46 public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID = "trace.event.probe.symbol"; //$NON-NLS-1$
47 /**
48 * The trace event 'probe address' property name.
49 */
50 public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME = Messages.TraceControl_ProbeAddressPropertyName;
51 /**
52 * The trace event 'probe offset' property ID.
53 */
54 public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME = Messages.TraceControl_ProbeOffsetPropertyName;
55 /**
56 * The trace event 'probe symbol' property ID.
57 */
58 public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME = Messages.TraceControl_ProbeSymbolPropertyName;
59
60 // ------------------------------------------------------------------------
61 // Attributes
62 // ------------------------------------------------------------------------
63
64 // ------------------------------------------------------------------------
65 // Constructors
66 // ------------------------------------------------------------------------
67 public TraceProbeEventPropertySource(TraceEventComponent component) {
68 super(component);
69 if (component.getClass() != TraceProbeEventComponent.class) {
70 throw new IllegalArgumentException("Invalid type passed. Only class of type TraceProbeEventComponent allowed:\n" + component.getClass()); //$NON-NLS-1$
71 }
72 }
73
74 // ------------------------------------------------------------------------
75 // Operations
76 // ------------------------------------------------------------------------
77 /*
78 * (non-Javadoc)
79 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
80 */
81 @Override
82 public IPropertyDescriptor[] getPropertyDescriptors() {
83 IPropertyDescriptor[] superProperties = super.getPropertyDescriptors();
84
85 List<IPropertyDescriptor> superList = Arrays.asList(superProperties);
86 ArrayList<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>();
87 list.addAll(superList);
88
89 if (fEvent instanceof TraceProbeEventComponent) {
90 TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent;
91 if (event.getAddress() != null) {
92 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME));
93 }
94
95 if (event.getOffset() != null) {
96 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME));
97 }
98
99 if (event.getSymbol() != null) {
100 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME));
101 }
102 }
103 return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
104 }
105
106 /*
107 * (non-Javadoc)
108 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
109 */
110 @Override
111 public Object getPropertyValue(Object id) {
112 if(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID.equals(id)) {
113 return ((TraceProbeEventComponent)fEvent).getAddress();
114 }
115 if (TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID.equals(id)) {
116 return ((TraceProbeEventComponent)fEvent).getOffset();
117 }
118 if (TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID.equals(id)) {
119 return ((TraceProbeEventComponent)fEvent).getSymbol();
120 }
121 return super.getPropertyValue(id);
122 }
123 }
This page took 0.036597 seconds and 6 git commands to generate.