Commit | Line | Data |
---|---|---|
d132bcc7 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 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 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
d132bcc7 | 13 | |
9315aeee BH |
14 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo; |
15 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo; | |
115b4a01 BH |
16 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
17 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.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 BH |
67 | /* |
68 | * (non-Javadoc) | |
115b4a01 | 69 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class) |
d132bcc7 | 70 | */ |
d132bcc7 BH |
71 | @Override |
72 | public Object getAdapter(Class adapter) { | |
73 | if (adapter == IPropertySource.class) { | |
74 | return new TraceProbeEventPropertySource(this); | |
75 | } | |
76 | return null; | |
77 | } | |
78 | /** | |
79 | * @return the address of the probe. (null if Symbol is used) | |
80 | */ | |
81 | public String getAddress() { | |
82 | return getEventInfo().getAddress(); | |
83 | } | |
84 | /** | |
85 | * Sets the address of the probe. | |
86 | * @param address - a address | |
87 | */ | |
88 | public void setAddress(String address) { | |
89 | getEventInfo().setAddress(address); | |
90 | } | |
91 | /** | |
92 | * @return the offset applied to the symbol. | |
93 | */ | |
94 | public String getOffset() { | |
95 | return getEventInfo().getOffset(); | |
96 | } | |
97 | /** | |
98 | * Sets the offset applied to the symbol. (valid if symbol is used) | |
99 | * @param offset - a offset | |
100 | */ | |
101 | public void setOffset(String offset) { | |
102 | getEventInfo().setOffset(offset); | |
103 | } | |
104 | /** | |
105 | * @return the symbol name. (null if address is used) | |
106 | */ | |
107 | public String getSymbol() { | |
108 | return getEventInfo().getSymbol(); | |
109 | } | |
110 | /** | |
111 | * Sets the symbol name. | |
112 | * @param symbol - a symbol name (null if address is used) | |
113 | */ | |
114 | public void setSymbol(String symbol) { | |
115 | getEventInfo().setSymbol(symbol); | |
116 | } | |
ea21cd65 | 117 | |
d132bcc7 BH |
118 | // ------------------------------------------------------------------------ |
119 | // Helper methods | |
120 | // ------------------------------------------------------------------------ | |
121 | private ProbeEventInfo getEventInfo() { | |
122 | return (ProbeEventInfo) fEventInfo; | |
123 | } | |
124 | ||
125 | } |