1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
;
14 import java
.util
.ArrayList
;
15 import java
.util
.Arrays
;
16 import java
.util
.List
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.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
.linuxtools
.tmf
.ui
.properties
.ReadOnlyTextPropertyDescriptor
;
22 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
26 * Property source implementation for the trace probe event component.
29 * @author Bernd Hufmann
31 public class TraceProbeEventPropertySource
extends TraceEventPropertySource
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 * The trace event 'probe address' property ID.
39 public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID
= "trace.event.probe.address"; //$NON-NLS-1$
41 * The trace event 'probe offset' property ID.
43 public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID
= "trace.event.probe.offset"; //$NON-NLS-1$
45 * The trace event 'probe symbol' property ID.
47 public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID
= "trace.event.probe.symbol"; //$NON-NLS-1$
49 * The trace event 'probe address' property name.
51 public static final String TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME
= Messages
.TraceControl_ProbeAddressPropertyName
;
53 * The trace event 'probe offset' property ID.
55 public static final String TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME
= Messages
.TraceControl_ProbeOffsetPropertyName
;
57 * The trace event 'probe symbol' property ID.
59 public static final String TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME
= Messages
.TraceControl_ProbeSymbolPropertyName
;
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
73 * A trace event component
75 public TraceProbeEventPropertySource(TraceEventComponent 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$
82 // ------------------------------------------------------------------------
84 // ------------------------------------------------------------------------
87 public IPropertyDescriptor
[] getPropertyDescriptors() {
88 IPropertyDescriptor
[] superProperties
= super.getPropertyDescriptors();
90 List
<IPropertyDescriptor
> superList
= Arrays
.asList(superProperties
);
91 ArrayList
<IPropertyDescriptor
> list
= new ArrayList
<>();
92 list
.addAll(superList
);
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
));
100 if (event
.getOffset() != null) {
101 list
.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID
, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME
));
104 if (event
.getSymbol() != null) {
105 list
.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID
, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME
));
108 return list
.toArray(new IPropertyDescriptor
[list
.size()]);
112 public Object
getPropertyValue(Object id
) {
113 if(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID
.equals(id
)) {
114 return ((TraceProbeEventComponent
)fEvent
).getAddress();
116 if (TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID
.equals(id
)) {
117 return ((TraceProbeEventComponent
)fEvent
).getOffset();
119 if (TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID
.equals(id
)) {
120 return ((TraceProbeEventComponent
)fEvent
).getSymbol();
122 return super.getPropertyValue(id
);