Commit | Line | Data |
---|---|---|
d132bcc7 | 1 | /********************************************************************** |
ed902a2b | 2 | * Copyright (c) 2012, 2014 Ericsson |
ea21cd65 | 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 | |
ea21cd65 AM |
8 | * |
9 | * Contributors: | |
d132bcc7 BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
9bc60be7 | 12 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl; |
d132bcc7 | 13 | |
9bc60be7 AM |
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; | |
d132bcc7 BH |
18 | import org.eclipse.ui.views.properties.IPropertySource; |
19 | ||
20 | ||
21 | /** | |
d132bcc7 BH |
22 | * <p> |
23 | * Implementation of the trace channel component. | |
24 | * </p> | |
ea21cd65 | 25 | * |
dbd4432d | 26 | * @author Bernd Hufmann |
d132bcc7 BH |
27 | */ |
28 | public class TraceProbeEventComponent extends TraceEventComponent { | |
29 | // ------------------------------------------------------------------------ | |
30 | // Constants | |
31 | // ------------------------------------------------------------------------ | |
ea21cd65 | 32 | |
d132bcc7 BH |
33 | // ------------------------------------------------------------------------ |
34 | // Attributes | |
35 | // ------------------------------------------------------------------------ | |
ea21cd65 | 36 | |
d132bcc7 BH |
37 | // ------------------------------------------------------------------------ |
38 | // Constructors | |
39 | // ------------------------------------------------------------------------ | |
40 | /** | |
ea21cd65 | 41 | * Constructor |
d132bcc7 BH |
42 | * @param name - the name of the component. |
43 | * @param parent - the parent of this component. | |
ea21cd65 | 44 | */ |
d132bcc7 BH |
45 | public TraceProbeEventComponent(String name, ITraceControlComponent parent) { |
46 | super(name, parent); | |
47 | fEventInfo = new ProbeEventInfo(name); | |
48 | } | |
ea21cd65 | 49 | |
d132bcc7 BH |
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 | } | |
ea21cd65 | 66 | |
d132bcc7 | 67 | @Override |
e58fe1d5 | 68 | public <T> T getAdapter(Class<T> adapter) { |
d132bcc7 | 69 | if (adapter == IPropertySource.class) { |
e58fe1d5 | 70 | return adapter.cast(new TraceProbeEventPropertySource(this)); |
d132bcc7 BH |
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 | } | |
ea21cd65 | 113 | |
951d231e BR |
114 | /** |
115 | * @return the probe string whether it be an address or a symbol and an | |
116 | * offset | |
117 | */ | |
118 | public String getProbeString() { | |
119 | return getEventInfo().getProbeString(); | |
120 | } | |
121 | ||
d132bcc7 BH |
122 | // ------------------------------------------------------------------------ |
123 | // Helper methods | |
124 | // ------------------------------------------------------------------------ | |
125 | private ProbeEventInfo getEventInfo() { | |
126 | return (ProbeEventInfo) fEventInfo; | |
127 | } | |
128 | ||
129 | } |