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