1 /**********************************************************************
2 * Copyright (c) 2012 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
.core
.util
.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 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
90 public IPropertyDescriptor
[] getPropertyDescriptors() {
91 IPropertyDescriptor
[] superProperties
= super.getPropertyDescriptors();
93 List
<IPropertyDescriptor
> superList
= Arrays
.asList(superProperties
);
94 ArrayList
<IPropertyDescriptor
> list
= new ArrayList
<IPropertyDescriptor
>();
95 list
.addAll(superList
);
97 if (fEvent
instanceof TraceProbeEventComponent
) {
98 TraceProbeEventComponent event
= (TraceProbeEventComponent
) fEvent
;
99 if (event
.getAddress() != null) {
100 list
.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID
, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME
));
103 if (event
.getOffset() != null) {
104 list
.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID
, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME
));
107 if (event
.getSymbol() != null) {
108 list
.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID
, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME
));
111 return list
.toArray(new IPropertyDescriptor
[list
.size()]);
116 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
119 public Object
getPropertyValue(Object id
) {
120 if(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID
.equals(id
)) {
121 return ((TraceProbeEventComponent
)fEvent
).getAddress();
123 if (TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID
.equals(id
)) {
124 return ((TraceProbeEventComponent
)fEvent
).getOffset();
126 if (TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID
.equals(id
)) {
127 return ((TraceProbeEventComponent
)fEvent
).getSymbol();
129 return super.getPropertyValue(id
);