Commit | Line | Data |
---|---|---|
eb1bab5b 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 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
eb1bab5b | 13 | |
bbb3538a BH |
14 | import java.util.List; |
15 | ||
16 | import org.eclipse.core.commands.ExecutionException; | |
17 | import org.eclipse.core.runtime.IProgressMonitor; | |
18 | import org.eclipse.core.runtime.NullProgressMonitor; | |
9315aeee BH |
19 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; |
20 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo; | |
21 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType; | |
22 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; | |
23 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.DomainInfo; | |
24 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; | |
115b4a01 | 25 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
115b4a01 | 26 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceDomainPropertySource; |
06b9339e | 27 | import org.eclipse.ui.views.properties.IPropertySource; |
eb1bab5b BH |
28 | |
29 | /** | |
30 | * <b><u>TraceDomainComponent</u></b> | |
31 | * <p> | |
32 | * Implementation of the trace domain component. | |
33 | * </p> | |
34 | */ | |
35 | public class TraceDomainComponent extends TraceControlComponent { | |
36 | // ------------------------------------------------------------------------ | |
37 | // Constants | |
38 | // ------------------------------------------------------------------------ | |
39 | /** | |
40 | * Path to icon file for this component. | |
41 | */ | |
42 | public static final String TRACE_DOMAIN_ICON_FILE = "icons/obj16/domain.gif"; //$NON-NLS-1$ | |
43 | ||
44 | // ------------------------------------------------------------------------ | |
45 | // Attributes | |
46 | // ------------------------------------------------------------------------ | |
47 | /** | |
48 | * The domain information. | |
49 | */ | |
bbb3538a | 50 | private IDomainInfo fDomainInfo = null; |
eb1bab5b BH |
51 | |
52 | // ------------------------------------------------------------------------ | |
53 | // Constructors | |
54 | // ------------------------------------------------------------------------ | |
55 | /** | |
56 | * Constructor | |
57 | * @param name - the name of the component. | |
58 | * @param parent - the parent of this component. | |
59 | */ | |
60 | public TraceDomainComponent(String name, ITraceControlComponent parent) { | |
61 | super(name, parent); | |
62 | setImage(TRACE_DOMAIN_ICON_FILE); | |
63 | setToolTip(Messages.TraceControl_DomainDisplayName); | |
64 | fDomainInfo = new DomainInfo(name); | |
65 | } | |
66 | ||
67 | // ------------------------------------------------------------------------ | |
68 | // Accessors | |
69 | // ------------------------------------------------------------------------ | |
70 | /** | |
71 | * Sets the domain information. | |
72 | * @param domainInfo - the domain information to set. | |
73 | */ | |
74 | public void setDomainInfo(IDomainInfo domainInfo) { | |
75 | fDomainInfo = domainInfo; | |
76 | IChannelInfo[] channels = fDomainInfo.getChannels(); | |
77 | for (int i = 0; i < channels.length; i++) { | |
78 | TraceChannelComponent channel = new TraceChannelComponent(channels[i].getName(), this); | |
79 | channel.setChannelInfo(channels[i]); | |
80 | addChild(channel); | |
81 | } | |
82 | } | |
83 | ||
06b9339e BH |
84 | /* |
85 | * (non-Javadoc) | |
115b4a01 | 86 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class) |
06b9339e BH |
87 | */ |
88 | @SuppressWarnings("rawtypes") | |
89 | @Override | |
90 | public Object getAdapter(Class adapter) { | |
91 | if (adapter == IPropertySource.class) { | |
92 | return new TraceDomainPropertySource(this); | |
93 | } | |
94 | return null; | |
bbb3538a BH |
95 | } |
96 | ||
97 | /** | |
98 | * @return session name from parent | |
99 | */ | |
100 | public String getSessionName() { | |
101 | return ((TraceSessionComponent)getParent()).getName(); | |
102 | } | |
103 | ||
6503ae0f BH |
104 | /** |
105 | * @return session from parent | |
106 | */ | |
107 | public TraceSessionComponent getSession() { | |
108 | return (TraceSessionComponent)getParent(); | |
109 | } | |
110 | ||
bbb3538a BH |
111 | /** |
112 | * @return true if domain is kernel, false for UST | |
113 | */ | |
114 | public boolean isKernel() { | |
115 | return fDomainInfo.isKernel(); | |
116 | } | |
117 | ||
118 | /** | |
119 | * Sets whether domain is Kernel domain or UST | |
120 | * @param isKernel true for kernel, false for UST | |
121 | */ | |
122 | public void setIsKernel(boolean isKernel) { | |
123 | fDomainInfo.setIsKernel(isKernel); | |
124 | } | |
6503ae0f BH |
125 | |
126 | /** | |
127 | * @return returns all available channels for this domain. | |
128 | */ | |
129 | public TraceChannelComponent[] getChannels() { | |
130 | List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class); | |
131 | return (TraceChannelComponent[])channels.toArray(new TraceChannelComponent[channels.size()]); | |
132 | } | |
498704b3 BH |
133 | |
134 | /** | |
135 | * @return the parent target node | |
136 | */ | |
137 | public TargetNodeComponent getTargetNode() { | |
138 | return ((TraceSessionComponent)getParent()).getTargetNode(); | |
139 | } | |
bbb3538a | 140 | |
eb1bab5b BH |
141 | // ------------------------------------------------------------------------ |
142 | // Operations | |
143 | // ------------------------------------------------------------------------ | |
bbb3538a BH |
144 | /** |
145 | * Retrieves the session configuration from the node. | |
146 | * @throws ExecutionException | |
147 | */ | |
148 | public void getConfigurationFromNode() throws ExecutionException { | |
149 | getConfigurationFromNode(new NullProgressMonitor()); | |
150 | } | |
151 | /** | |
152 | * Retrieves the session configuration from the node. | |
153 | * @param monitor - a progress monitor | |
154 | * @throws ExecutionException | |
155 | */ | |
156 | public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException { | |
157 | TraceSessionComponent session = (TraceSessionComponent) getParent(); | |
158 | session.getConfigurationFromNode(monitor); | |
159 | } | |
160 | /** | |
161 | * Enables channels with given names which are part of this domain. If a given channel | |
162 | * doesn't exists it creates a new channel with the given parameters (or default values | |
163 | * if given parameter is null). | |
164 | * @param channelNames - a list of channel names to enable on this domain | |
165 | * @param info - channel information to set for the channel (use null for default) | |
166 | * @throws ExecutionException | |
167 | */ | |
168 | public void enableChannels(List<String> channelNames, IChannelInfo info) throws ExecutionException { | |
169 | enableChannels(channelNames, info, new NullProgressMonitor()); | |
170 | } | |
171 | /** | |
172 | * Enables channels with given names which are part of this domain. If a given channel | |
173 | * doesn't exists it creates a new channel with the given parameters (or default values | |
174 | * if given parameter is null). | |
175 | * @param channelNames - a list of channel names to enable on this domain | |
176 | * @param info - channel information to set for the channel (use null for default) | |
177 | * @param monitor - a progress monitor | |
178 | * @throws ExecutionException | |
179 | */ | |
180 | public void enableChannels(List<String> channelNames, IChannelInfo info, IProgressMonitor monitor) throws ExecutionException { | |
498704b3 | 181 | getControlService().enableChannels(getParent().getName(), channelNames, isKernel(), info, monitor); |
bbb3538a BH |
182 | } |
183 | /** | |
184 | * Disables channels with given names which are part of this domain. | |
185 | * @param channelNames - a list of channel names to enable on this domain | |
186 | * @throws ExecutionException | |
187 | */ | |
188 | public void disableChannels(List<String> channelNames) throws ExecutionException { | |
189 | disableChannels(channelNames, new NullProgressMonitor()); | |
190 | } | |
191 | /** | |
192 | * Disables channels with given names which are part of this domain. | |
193 | * @param channelNames - a list of channel names to enable on this domain | |
194 | * @param monitor - a progress monitor | |
195 | * @throws ExecutionException | |
196 | */ | |
197 | public void disableChannels(List<String> channelNames, IProgressMonitor monitor) throws ExecutionException { | |
498704b3 BH |
198 | getControlService().disableChannels(getParent().getName(), channelNames, isKernel(), monitor); |
199 | } | |
200 | ||
201 | /** | |
202 | * Enables a list of events with no additional parameters. | |
203 | * @param eventNames - a list of event names to enabled. | |
204 | * @param monitor - a progress monitor | |
205 | * @throws ExecutionException | |
206 | */ | |
207 | public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException { | |
208 | getControlService().enableEvents(getSessionName(), null, eventNames, isKernel(), monitor); | |
209 | } | |
210 | ||
211 | /** | |
212 | * Enables all syscalls (for kernel domain) | |
213 | * @throws ExecutionException | |
214 | */ | |
215 | public void enableSyscalls() throws ExecutionException { | |
216 | enableSyscalls(new NullProgressMonitor()); | |
217 | } | |
218 | ||
219 | /** | |
220 | * Enables all syscalls (for kernel domain) | |
221 | * @param monitor - a progress monitor | |
222 | * @throws ExecutionException | |
223 | */ | |
224 | ||
225 | public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException { | |
226 | getControlService().enableSyscalls(getSessionName(), null, monitor); | |
227 | } | |
228 | ||
229 | /** | |
230 | * Enables a dynamic probe (for kernel domain) | |
231 | * @param eventName - event name for probe | |
d132bcc7 BH |
232 | * @param isFunction - true for dynamic function entry/return probe else false |
233 | * @param probe - the actual probe | |
498704b3 BH |
234 | * @throws ExecutionException |
235 | */ | |
d132bcc7 BH |
236 | public void enableProbe(String eventName, boolean isFunction, String probe) throws ExecutionException { |
237 | enableProbe(eventName, isFunction, probe, new NullProgressMonitor()); | |
498704b3 BH |
238 | } |
239 | ||
240 | /** | |
241 | * Enables a dynamic probe (for kernel domain) | |
242 | * @param eventName - event name for probe | |
d132bcc7 | 243 | * @param isFunction - true for dynamic function entry/return probe else false |
498704b3 BH |
244 | * @param probe - the actual probe |
245 | * @param monitor - a progress monitor | |
246 | * @throws ExecutionException | |
247 | */ | |
d132bcc7 BH |
248 | public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException { |
249 | getControlService().enableProbe(getSessionName(), null, eventName, isFunction, probe, monitor); | |
498704b3 BH |
250 | } |
251 | ||
ccc66d01 BH |
252 | /** |
253 | * Enables events using log level. | |
254 | * @param eventName - a event name | |
255 | * @param logLevelType - a log level type | |
256 | * @param level - a log level | |
257 | * @throws ExecutionException | |
258 | */ | |
259 | public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level) throws ExecutionException { | |
260 | enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor()); | |
261 | } | |
262 | ||
263 | /** | |
264 | * Enables events using log level. | |
265 | * @param eventName - a event name | |
266 | * @param logLevelType - a log level type | |
267 | * @param level - a log level | |
268 | * @param monitor - a progress monitor | |
269 | * @throws ExecutionException | |
270 | */ | |
271 | public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException { | |
272 | getControlService().enableLogLevel(getSessionName(), null, eventName, logLevelType, level, monitor); | |
273 | } | |
274 | ||
b793fbe1 BH |
275 | /** |
276 | * Add contexts to given channels and or events | |
277 | * @param contexts - a list of contexts to add | |
278 | * @throws ExecutionException | |
279 | */ | |
280 | public void addContexts(List<String> contexts) throws ExecutionException { | |
281 | addContexts(contexts, new NullProgressMonitor()); | |
282 | } | |
283 | ||
284 | /** | |
285 | * Add contexts to given channels and or events | |
286 | * @param contexts - a list of contexts to add | |
287 | * @param monitor - a progress monitor | |
288 | * @throws ExecutionException | |
289 | */ | |
290 | public void addContexts(List<String> contexts, IProgressMonitor monitor) throws ExecutionException { | |
291 | getControlService().addContexts(getSessionName(), null, null, isKernel(), contexts, monitor); | |
292 | } | |
b720ac44 BH |
293 | |
294 | /** | |
295 | * Executes calibrate command to quantify LTTng overhead. | |
296 | * @throws ExecutionException | |
297 | */ | |
298 | public void calibrate() throws ExecutionException { | |
299 | calibrate(new NullProgressMonitor()); | |
300 | } | |
301 | ||
302 | /** | |
303 | * Executes calibrate command to quantify LTTng overhead. | |
304 | * @param monitor - a progress monitor | |
305 | * @throws ExecutionException | |
306 | */ | |
307 | public void calibrate(IProgressMonitor monitor) throws ExecutionException { | |
308 | getControlService().calibrate(isKernel(), monitor); | |
309 | } | |
eb1bab5b | 310 | } |