gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / property / TraceProbeEventPropertySource.java
CommitLineData
d132bcc7 1/**********************************************************************
60ae41e1 2 * Copyright (c) 2012, 2014 Ericsson
cfdb727a 3 *
d132bcc7
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:
080600d9 10 * Bernd Hufmann - Initial API and implementation
d132bcc7 11 **********************************************************************/
8e8c0226 12package org.eclipse.linuxtools.internal.lttng2.control.ui.views.property;
d132bcc7
BH
13
14import java.util.ArrayList;
c56972bb 15import java.util.Arrays;
d132bcc7
BH
16import java.util.List;
17
8e8c0226
AM
18import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages;
19import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceEventComponent;
20import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceProbeEventComponent;
080600d9 21import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
d132bcc7 22import org.eclipse.ui.views.properties.IPropertyDescriptor;
d132bcc7
BH
23
24/**
d132bcc7
BH
25 * <p>
26 * Property source implementation for the trace probe event component.
27 * </p>
cfdb727a 28 *
dbd4432d 29 * @author Bernd Hufmann
d132bcc7
BH
30 */
31public 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 // ------------------------------------------------------------------------
cfdb727a 64
d132bcc7
BH
65 // ------------------------------------------------------------------------
66 // Constructors
67 // ------------------------------------------------------------------------
cfdb727a
AM
68
69 /**
70 * Constructor
71 *
72 * @param component
73 * A trace event component
74 */
d132bcc7
BH
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 }
cfdb727a 81
d132bcc7
BH
82 // ------------------------------------------------------------------------
83 // Operations
84 // ------------------------------------------------------------------------
11252342 85
d132bcc7
BH
86 @Override
87 public IPropertyDescriptor[] getPropertyDescriptors() {
88 IPropertyDescriptor[] superProperties = super.getPropertyDescriptors();
c56972bb
BH
89
90 List<IPropertyDescriptor> superList = Arrays.asList(superProperties);
e0838ca1 91 ArrayList<IPropertyDescriptor> list = new ArrayList<>();
c56972bb
BH
92 list.addAll(superList);
93
d132bcc7
BH
94 if (fEvent instanceof TraceProbeEventComponent) {
95 TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent;
96 if (event.getAddress() != null) {
5a7326dc 97 list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME));
d132bcc7
BH
98 }
99
100 if (event.getOffset() != null) {
5a7326dc 101 list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME));
d132bcc7
BH
102 }
103
104 if (event.getSymbol() != null) {
5a7326dc 105 list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME));
d132bcc7
BH
106 }
107 }
cfdb727a 108 return list.toArray(new IPropertyDescriptor[list.size()]);
d132bcc7
BH
109 }
110
d132bcc7
BH
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.05162 seconds and 5 git commands to generate.