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