Update usage of IAdaptable#getAdapter
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / model / impl / TraceProbeEventComponent.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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.tracecompass.internal.lttng2.control.ui.views.model.impl;
13
14 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IEventInfo;
15 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.ProbeEventInfo;
16 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
17 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.TraceProbeEventPropertySource;
18 import org.eclipse.ui.views.properties.IPropertySource;
19
20
21 /**
22 * <p>
23 * Implementation of the trace channel component.
24 * </p>
25 *
26 * @author Bernd Hufmann
27 */
28 public class TraceProbeEventComponent extends TraceEventComponent {
29 // ------------------------------------------------------------------------
30 // Constants
31 // ------------------------------------------------------------------------
32
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36
37 // ------------------------------------------------------------------------
38 // Constructors
39 // ------------------------------------------------------------------------
40 /**
41 * Constructor
42 * @param name - the name of the component.
43 * @param parent - the parent of this component.
44 */
45 public TraceProbeEventComponent(String name, ITraceControlComponent parent) {
46 super(name, parent);
47 fEventInfo = new ProbeEventInfo(name);
48 }
49
50 // ------------------------------------------------------------------------
51 // Accessors
52 // ------------------------------------------------------------------------
53
54 /**
55 * Sets the event information.
56 * @param eventInfo - the event information to set.
57 */
58 @Override
59 public void setEventInfo(IEventInfo eventInfo) {
60 if (eventInfo instanceof ProbeEventInfo) {
61 fEventInfo = eventInfo;
62 return;
63 }
64 throw new IllegalArgumentException("Invalid type passed. Only class of type ProbeEventInfo allowed:\n" + eventInfo.getClass()); //$NON-NLS-1$
65 }
66
67 @Override
68 public <T> T getAdapter(Class<T> adapter) {
69 if (adapter == IPropertySource.class) {
70 return adapter.cast(new TraceProbeEventPropertySource(this));
71 }
72 return null;
73 }
74 /**
75 * @return the address of the probe. (null if Symbol is used)
76 */
77 public String getAddress() {
78 return getEventInfo().getAddress();
79 }
80 /**
81 * Sets the address of the probe.
82 * @param address - a address
83 */
84 public void setAddress(String address) {
85 getEventInfo().setAddress(address);
86 }
87 /**
88 * @return the offset applied to the symbol.
89 */
90 public String getOffset() {
91 return getEventInfo().getOffset();
92 }
93 /**
94 * Sets the offset applied to the symbol. (valid if symbol is used)
95 * @param offset - a offset
96 */
97 public void setOffset(String offset) {
98 getEventInfo().setOffset(offset);
99 }
100 /**
101 * @return the symbol name. (null if address is used)
102 */
103 public String getSymbol() {
104 return getEventInfo().getSymbol();
105 }
106 /**
107 * Sets the symbol name.
108 * @param symbol - a symbol name (null if address is used)
109 */
110 public void setSymbol(String symbol) {
111 getEventInfo().setSymbol(symbol);
112 }
113
114 // ------------------------------------------------------------------------
115 // Helper methods
116 // ------------------------------------------------------------------------
117 private ProbeEventInfo getEventInfo() {
118 return (ProbeEventInfo) fEventInfo;
119 }
120
121 }
This page took 0.033181 seconds and 5 git commands to generate.