Update internal packages export in LTTng 2.0 control + update java doc
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / property / TraceProbeEventPropertySource.java
CommitLineData
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 **********************************************************************/
115b4a01 12package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
d132bcc7
BH
13
14import java.util.ArrayList;
c56972bb 15import java.util.Arrays;
d132bcc7
BH
16import java.util.List;
17
9315aeee 18import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
115b4a01
BH
19import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceEventComponent;
20import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProbeEventComponent;
d132bcc7
BH
21import org.eclipse.ui.views.properties.IPropertyDescriptor;
22import org.eclipse.ui.views.properties.TextPropertyDescriptor;
23
24/**
d132bcc7
BH
25 * <p>
26 * Property source implementation for the trace probe event component.
27 * </p>
dbd4432d
BH
28 *
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 // ------------------------------------------------------------------------
64
65 // ------------------------------------------------------------------------
66 // Constructors
67 // ------------------------------------------------------------------------
68 public TraceProbeEventPropertySource(TraceEventComponent component) {
69 super(component);
70 if (component.getClass() != TraceProbeEventComponent.class) {
71 throw new IllegalArgumentException("Invalid type passed. Only class of type TraceProbeEventComponent allowed:\n" + component.getClass()); //$NON-NLS-1$
72 }
73 }
74
75 // ------------------------------------------------------------------------
76 // Operations
77 // ------------------------------------------------------------------------
78 /*
79 * (non-Javadoc)
115b4a01 80 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
d132bcc7
BH
81 */
82 @Override
83 public IPropertyDescriptor[] getPropertyDescriptors() {
84 IPropertyDescriptor[] superProperties = super.getPropertyDescriptors();
c56972bb
BH
85
86 List<IPropertyDescriptor> superList = Arrays.asList(superProperties);
87 ArrayList<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>();
88 list.addAll(superList);
89
d132bcc7
BH
90 if (fEvent instanceof TraceProbeEventComponent) {
91 TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent;
92 if (event.getAddress() != null) {
93 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME));
94 }
95
96 if (event.getOffset() != null) {
97 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME));
98 }
99
100 if (event.getSymbol() != null) {
101 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME));
102 }
103 }
104 return (IPropertyDescriptor [])list.toArray(new IPropertyDescriptor[list.size()]);
105 }
106
107 /*
108 * (non-Javadoc)
115b4a01 109 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
d132bcc7
BH
110 */
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.032337 seconds and 5 git commands to generate.