Commit | Line | Data |
---|---|---|
d132bcc7 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 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: | |
d132bcc7 BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property; |
d132bcc7 BH |
13 | |
14 | import java.util.ArrayList; | |
c56972bb | 15 | import java.util.Arrays; |
d132bcc7 BH |
16 | import java.util.List; |
17 | ||
9315aeee | 18 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
115b4a01 BH |
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; | |
5a7326dc | 21 | import org.eclipse.linuxtools.tmf.core.util.ReadOnlyTextPropertyDescriptor; |
d132bcc7 | 22 | import 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 | */ |
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 | // ------------------------------------------------------------------------ | |
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 | // ------------------------------------------------------------------------ | |
85 | /* | |
86 | * (non-Javadoc) | |
115b4a01 | 87 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors() |
d132bcc7 BH |
88 | */ |
89 | @Override | |
90 | public IPropertyDescriptor[] getPropertyDescriptors() { | |
91 | IPropertyDescriptor[] superProperties = super.getPropertyDescriptors(); | |
c56972bb BH |
92 | |
93 | List<IPropertyDescriptor> superList = Arrays.asList(superProperties); | |
94 | ArrayList<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>(); | |
95 | list.addAll(superList); | |
96 | ||
d132bcc7 BH |
97 | if (fEvent instanceof TraceProbeEventComponent) { |
98 | TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent; | |
99 | if (event.getAddress() != null) { | |
5a7326dc | 100 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME)); |
d132bcc7 BH |
101 | } |
102 | ||
103 | if (event.getOffset() != null) { | |
5a7326dc | 104 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME)); |
d132bcc7 BH |
105 | } |
106 | ||
107 | if (event.getSymbol() != null) { | |
5a7326dc | 108 | list.add(new ReadOnlyTextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME)); |
d132bcc7 BH |
109 | } |
110 | } | |
cfdb727a | 111 | return list.toArray(new IPropertyDescriptor[list.size()]); |
d132bcc7 BH |
112 | } |
113 | ||
114 | /* | |
115 | * (non-Javadoc) | |
115b4a01 | 116 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object) |
d132bcc7 BH |
117 | */ |
118 | @Override | |
119 | public Object getPropertyValue(Object id) { | |
120 | if(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID.equals(id)) { | |
121 | return ((TraceProbeEventComponent)fEvent).getAddress(); | |
122 | } | |
123 | if (TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID.equals(id)) { | |
124 | return ((TraceProbeEventComponent)fEvent).getOffset(); | |
125 | } | |
126 | if (TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID.equals(id)) { | |
127 | return ((TraceProbeEventComponent)fEvent).getSymbol(); | |
128 | } | |
129 | return super.getPropertyValue(id); | |
130 | } | |
131 | } |