lttng: Fix Javadoc and formatting in lttng2.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / property / TraceProbeEventPropertySource.java
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 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.property;
13
14 import java.util.ArrayList;
15 import java.util.Arrays;
16 import java.util.List;
17
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.ui.views.properties.IPropertyDescriptor;
22 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
23
24 /**
25 * <p>
26 * Property source implementation for the trace probe event component.
27 * </p>
28 *
29 * @author Bernd Hufmann
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 // ------------------------------------------------------------------------
64
65 // ------------------------------------------------------------------------
66 // Constructors
67 // ------------------------------------------------------------------------
68
69 /**
70 * Constructor
71 *
72 * @param component
73 * A trace event component
74 */
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 }
81
82 // ------------------------------------------------------------------------
83 // Operations
84 // ------------------------------------------------------------------------
85 /*
86 * (non-Javadoc)
87 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyDescriptors()
88 */
89 @Override
90 public IPropertyDescriptor[] getPropertyDescriptors() {
91 IPropertyDescriptor[] superProperties = super.getPropertyDescriptors();
92
93 List<IPropertyDescriptor> superList = Arrays.asList(superProperties);
94 ArrayList<IPropertyDescriptor> list = new ArrayList<IPropertyDescriptor>();
95 list.addAll(superList);
96
97 if (fEvent instanceof TraceProbeEventComponent) {
98 TraceProbeEventComponent event = (TraceProbeEventComponent) fEvent;
99 if (event.getAddress() != null) {
100 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_ADDRESS_PROPERTY_ID, TRACE_EVENT_PROBE_ADDRESS_PROPERTY_NAME));
101 }
102
103 if (event.getOffset() != null) {
104 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID, TRACE_EVENT_PROBE_OFFSET_PROPERTY_NAME));
105 }
106
107 if (event.getSymbol() != null) {
108 list.add(new TextPropertyDescriptor(TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID, TRACE_EVENT_PROBE_SYMBOL_PROPERTY_NAME));
109 }
110 }
111 return list.toArray(new IPropertyDescriptor[list.size()]);
112 }
113
114 /*
115 * (non-Javadoc)
116 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.BasePropertySource#getPropertyValue(java.lang.Object)
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 }
This page took 0.046607 seconds and 6 git commands to generate.