Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
ba3a9bd2 | 2 | * Copyright (c) 2012, 2013 Ericsson |
cfdb727a | 3 | * |
eb1bab5b 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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b | 10 | * Bernd Hufmann - Initial API and implementation |
ba3a9bd2 | 11 | * Bernd Hufmann - Updated for support of LTTng Tools 2.1 |
eb1bab5b | 12 | **********************************************************************/ |
115b4a01 | 13 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
eb1bab5b | 14 | |
b957fb8c | 15 | import java.util.ArrayList; |
6503ae0f BH |
16 | import java.util.List; |
17 | ||
18 | import org.eclipse.core.commands.ExecutionException; | |
19 | import org.eclipse.core.runtime.IProgressMonitor; | |
20 | import org.eclipse.core.runtime.NullProgressMonitor; | |
9315aeee BH |
21 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; |
22 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo; | |
23 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType; | |
24 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement; | |
25 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel; | |
26 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo; | |
27 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo; | |
115b4a01 | 28 | import org.eclipse.linuxtools.internal.lttng2.ui.Activator; |
9315aeee | 29 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
115b4a01 | 30 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
115b4a01 | 31 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceChannelPropertySource; |
eb1bab5b | 32 | import org.eclipse.swt.graphics.Image; |
06b9339e | 33 | import org.eclipse.ui.views.properties.IPropertySource; |
eb1bab5b BH |
34 | |
35 | ||
36 | /** | |
eb1bab5b BH |
37 | * <p> |
38 | * Implementation of the trace channel component. | |
39 | * </p> | |
cfdb727a | 40 | * |
dbd4432d | 41 | * @author Bernd Hufmann |
eb1bab5b BH |
42 | */ |
43 | public class TraceChannelComponent extends TraceControlComponent { | |
44 | // ------------------------------------------------------------------------ | |
45 | // Constants | |
46 | // ------------------------------------------------------------------------ | |
47 | /** | |
48 | * Path to icon file for this component (state enabled). | |
49 | */ | |
50 | public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$ | |
51 | /** | |
52 | * Path to icon file for this component (state disabled). | |
53 | */ | |
54 | public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$ | |
cfdb727a | 55 | |
eb1bab5b BH |
56 | // ------------------------------------------------------------------------ |
57 | // Attributes | |
58 | // ------------------------------------------------------------------------ | |
59 | /** | |
60 | * The channel information. | |
61 | */ | |
62 | private IChannelInfo fChannelInfo = null; | |
63 | /** | |
64 | * The image to be displayed in disabled state. | |
65 | */ | |
66 | private Image fDisabledImage = null; | |
cfdb727a | 67 | |
eb1bab5b BH |
68 | // ------------------------------------------------------------------------ |
69 | // Constructors | |
70 | // ------------------------------------------------------------------------ | |
71 | /** | |
cfdb727a | 72 | * Constructor |
eb1bab5b BH |
73 | * @param name - the name of the component. |
74 | * @param parent - the parent of this component. | |
75 | */ | |
76 | public TraceChannelComponent(String name, ITraceControlComponent parent) { | |
77 | super(name, parent); | |
78 | setImage(TRACE_CHANNEL_ICON_FILE_ENABLED); | |
79 | setToolTip(Messages.TraceControl_ChannelDisplayName); | |
80 | fChannelInfo = new ChannelInfo(name); | |
31a6a4e4 | 81 | fDisabledImage = Activator.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED); |
eb1bab5b | 82 | } |
cfdb727a | 83 | |
eb1bab5b BH |
84 | // ------------------------------------------------------------------------ |
85 | // Accessors | |
86 | // ------------------------------------------------------------------------ | |
87 | /* | |
88 | * (non-Javadoc) | |
115b4a01 | 89 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage() |
eb1bab5b BH |
90 | */ |
91 | @Override | |
92 | public Image getImage() { | |
93 | if (fChannelInfo.getState() == TraceEnablement.DISABLED) { | |
94 | return fDisabledImage; | |
95 | } | |
96 | return super.getImage(); | |
97 | } | |
98 | ||
99 | /** | |
100 | * Sets the channel information. | |
cfdb727a | 101 | * |
eb1bab5b | 102 | * @param channelInfo |
cfdb727a | 103 | * The channel info to assign to this component |
eb1bab5b BH |
104 | */ |
105 | public void setChannelInfo(IChannelInfo channelInfo) { | |
106 | fChannelInfo = channelInfo; | |
107 | IEventInfo[] events = fChannelInfo.getEvents(); | |
b957fb8c | 108 | List<ITraceControlComponent> eventComponents = new ArrayList<ITraceControlComponent>(); |
eb1bab5b | 109 | for (int i = 0; i < events.length; i++) { |
d132bcc7 BH |
110 | TraceEventComponent event = null; |
111 | if (events[i].getClass() == ProbeEventInfo.class) { | |
112 | event = new TraceProbeEventComponent(events[i].getName(), this); | |
113 | } else { | |
114 | event = new TraceEventComponent(events[i].getName(), this); | |
115 | } | |
116 | ||
b957fb8c | 117 | eventComponents.add(event); |
eb1bab5b | 118 | event.setEventInfo(events[i]); |
b957fb8c BH |
119 | // addChild(event); |
120 | } | |
121 | if (!eventComponents.isEmpty()) { | |
122 | setChildren(eventComponents); | |
eb1bab5b BH |
123 | } |
124 | } | |
125 | ||
126 | /** | |
127 | * @return the overwrite mode value. | |
128 | */ | |
129 | public boolean isOverwriteMode() { | |
130 | return fChannelInfo.isOverwriteMode(); | |
131 | } | |
132 | /** | |
133 | * Sets the overwrite mode value to the given mode. | |
134 | * @param mode - mode to set. | |
135 | */ | |
136 | public void setOverwriteMode(boolean mode){ | |
137 | fChannelInfo.setOverwriteMode(mode); | |
138 | } | |
139 | /** | |
140 | * @return the sub-buffer size. | |
141 | */ | |
142 | public long getSubBufferSize() { | |
143 | return fChannelInfo.getSubBufferSize(); | |
144 | } | |
145 | /** | |
146 | * Sets the sub-buffer size to the given value. | |
147 | * @param bufferSize - size to set to set. | |
148 | */ | |
149 | public void setSubBufferSize(long bufferSize) { | |
150 | fChannelInfo.setSubBufferSize(bufferSize); | |
151 | } | |
152 | /** | |
153 | * @return the number of sub-buffers. | |
154 | */ | |
155 | public int getNumberOfSubBuffers() { | |
156 | return fChannelInfo.getNumberOfSubBuffers(); | |
157 | } | |
158 | /** | |
159 | * Sets the number of sub-buffers to the given value. | |
160 | * @param numberOfSubBuffers - value to set. | |
161 | */ | |
162 | public void setNumberOfSubBuffers(int numberOfSubBuffers) { | |
163 | fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers); | |
164 | } | |
165 | /** | |
166 | * @return the switch timer interval. | |
167 | */ | |
168 | public long getSwitchTimer() { | |
169 | return fChannelInfo.getSwitchTimer(); | |
170 | } | |
171 | /** | |
172 | * Sets the switch timer interval to the given value. | |
173 | * @param timer - timer value to set. | |
174 | */ | |
175 | public void setSwitchTimer(long timer) { | |
176 | fChannelInfo.setSwitchTimer(timer); | |
177 | } | |
178 | /** | |
179 | * @return the read timer interval. | |
180 | */ | |
181 | public long getReadTimer() { | |
cfdb727a | 182 | return fChannelInfo.getReadTimer(); |
eb1bab5b BH |
183 | } |
184 | /** | |
185 | * Sets the read timer interval to the given value. | |
186 | * @param timer - timer value to set.. | |
187 | */ | |
188 | public void setReadTimer(long timer) { | |
189 | fChannelInfo.setReadTimer(timer); | |
190 | } | |
191 | /** | |
192 | * @return the output type. | |
193 | */ | |
194 | public String getOutputType() { | |
195 | return fChannelInfo.getOutputType(); | |
196 | } | |
197 | /** | |
198 | * Sets the output type to the given value. | |
199 | * @param type - type to set. | |
200 | */ | |
201 | public void setOutputType(String type) { | |
202 | fChannelInfo.setOutputType(type); | |
203 | } | |
204 | /** | |
205 | * @return the channel state (enabled or disabled). | |
206 | */ | |
207 | public TraceEnablement getState() { | |
208 | return fChannelInfo.getState(); | |
209 | } | |
210 | /** | |
211 | * Sets the channel state (enablement) to the given value. | |
212 | * @param state - state to set. | |
213 | */ | |
214 | public void setState(TraceEnablement state) { | |
215 | fChannelInfo.setState(state); | |
216 | } | |
217 | /** | |
218 | * Sets the channel state (enablement) to the value specified by the given name. | |
219 | * @param stateName - state to set. | |
220 | */ | |
221 | public void setState(String stateName) { | |
222 | fChannelInfo.setState(stateName); | |
223 | } | |
06b9339e BH |
224 | /* |
225 | * (non-Javadoc) | |
115b4a01 | 226 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class) |
06b9339e | 227 | */ |
06b9339e BH |
228 | @Override |
229 | public Object getAdapter(Class adapter) { | |
230 | if (adapter == IPropertySource.class) { | |
231 | return new TraceChannelPropertySource(this); | |
232 | } | |
233 | return null; | |
cfdb727a | 234 | } |
bbb3538a BH |
235 | |
236 | /** | |
237 | * @return session name from parent | |
238 | */ | |
239 | public String getSessionName() { | |
cfdb727a | 240 | return ((TraceDomainComponent)getParent()).getSessionName(); |
bbb3538a BH |
241 | } |
242 | ||
6503ae0f BH |
243 | /** |
244 | * @return session from parent | |
245 | */ | |
246 | public TraceSessionComponent getSession() { | |
cfdb727a | 247 | return ((TraceDomainComponent)getParent()).getSession(); |
6503ae0f BH |
248 | } |
249 | ||
bbb3538a BH |
250 | /** |
251 | * @return if domain is kernel or UST | |
252 | */ | |
253 | public boolean isKernel() { | |
254 | return ((TraceDomainComponent)getParent()).isKernel(); | |
255 | } | |
cfdb727a | 256 | |
498704b3 BH |
257 | /** |
258 | * @return the parent target node | |
259 | */ | |
260 | public TargetNodeComponent getTargetNode() { | |
261 | return ((TraceDomainComponent)getParent()).getTargetNode(); | |
262 | } | |
cfdb727a | 263 | |
eb1bab5b BH |
264 | // ------------------------------------------------------------------------ |
265 | // Operations | |
266 | // ------------------------------------------------------------------------ | |
6503ae0f BH |
267 | /** |
268 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
269 | * |
270 | * @param eventNames | |
271 | * - a list of event names to enabled. | |
6503ae0f | 272 | * @throws ExecutionException |
cfdb727a | 273 | * If the command fails |
6503ae0f | 274 | */ |
498704b3 BH |
275 | public void enableEvents(List<String> eventNames) throws ExecutionException { |
276 | enableEvents(eventNames, new NullProgressMonitor()); | |
6503ae0f BH |
277 | } |
278 | ||
279 | /** | |
280 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
281 | * |
282 | * @param eventNames | |
283 | * - a list of event names to enabled. | |
284 | * @param monitor | |
285 | * - a progress monitor | |
6503ae0f | 286 | * @throws ExecutionException |
cfdb727a | 287 | * If the command fails |
6503ae0f | 288 | */ |
498704b3 | 289 | public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException { |
d4514365 BH |
290 | enableEvents(eventNames, null, monitor); |
291 | } | |
292 | ||
293 | /** | |
294 | * Enables a list of events with no additional parameters. | |
295 | * | |
296 | * @param eventNames | |
297 | * - a list of event names to enabled. | |
298 | * @param filterExpression | |
299 | * - a filter expression | |
300 | * @param monitor | |
301 | * - a progress monitor | |
302 | * @throws ExecutionException | |
303 | * If the command fails | |
304 | */ | |
305 | public void enableEvents(List<String> eventNames, String filterExpression, IProgressMonitor monitor) throws ExecutionException { | |
306 | getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), filterExpression, monitor); | |
498704b3 | 307 | } |
cfdb727a | 308 | |
498704b3 BH |
309 | /** |
310 | * Enables all syscalls (for kernel domain) | |
cfdb727a | 311 | * |
498704b3 | 312 | * @throws ExecutionException |
cfdb727a | 313 | * If the command fails |
498704b3 BH |
314 | */ |
315 | public void enableSyscalls() throws ExecutionException { | |
316 | enableSyscalls(new NullProgressMonitor()); | |
317 | } | |
318 | ||
319 | /** | |
320 | * Enables all syscalls (for kernel domain) | |
cfdb727a AM |
321 | * |
322 | * @param monitor | |
323 | * - a progress monitor | |
498704b3 | 324 | * @throws ExecutionException |
cfdb727a | 325 | * If the command fails |
498704b3 BH |
326 | */ |
327 | public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException { | |
328 | getControlService().enableSyscalls(getSessionName(), getName(), monitor); | |
329 | } | |
330 | ||
331 | /** | |
332 | * Enables a dynamic probe (for kernel domain) | |
cfdb727a AM |
333 | * |
334 | * @param eventName | |
335 | * - event name for probe | |
336 | * @param isFunction | |
337 | * - true for dynamic function entry/return probe else false | |
338 | * @param probe | |
339 | * - the actual probe | |
498704b3 | 340 | * @throws ExecutionException |
cfdb727a | 341 | * If the command fails |
498704b3 | 342 | */ |
cfdb727a AM |
343 | public void enableProbe(String eventName, boolean isFunction, String probe) |
344 | throws ExecutionException { | |
d132bcc7 | 345 | enableProbe(eventName, isFunction, probe, new NullProgressMonitor()); |
498704b3 BH |
346 | } |
347 | ||
348 | /** | |
349 | * Enables a dynamic probe (for kernel domain) | |
cfdb727a AM |
350 | * |
351 | * @param eventName | |
352 | * - event name for probe | |
353 | * @param isFunction | |
354 | * - true for dynamic function entry/return probe else false | |
355 | * @param probe | |
356 | * - the actual probe | |
357 | * @param monitor | |
358 | * - a progress monitor | |
498704b3 | 359 | * @throws ExecutionException |
cfdb727a | 360 | * If the command fails |
498704b3 | 361 | */ |
cfdb727a AM |
362 | public void enableProbe(String eventName, boolean isFunction, String probe, |
363 | IProgressMonitor monitor) throws ExecutionException { | |
d132bcc7 | 364 | getControlService().enableProbe(getSessionName(), getName(), eventName, isFunction, probe, monitor); |
498704b3 BH |
365 | } |
366 | ||
ccc66d01 BH |
367 | /** |
368 | * Enables events using log level. | |
cfdb727a AM |
369 | * |
370 | * @param eventName | |
371 | * - a event name | |
372 | * @param logLevelType | |
373 | * - a log level type | |
374 | * @param level | |
375 | * - a log level | |
d4514365 BH |
376 | * @param filterExpression |
377 | * - a filter expression | |
ccc66d01 | 378 | * @throws ExecutionException |
cfdb727a | 379 | * If the command fails |
ccc66d01 | 380 | */ |
cfdb727a | 381 | public void enableLogLevel(String eventName, LogLevelType logLevelType, |
d4514365 BH |
382 | TraceLogLevel level, String filterExpression) throws ExecutionException { |
383 | enableLogLevel(eventName, logLevelType, level, filterExpression, new NullProgressMonitor()); | |
ccc66d01 BH |
384 | } |
385 | ||
386 | /** | |
387 | * Enables events using log level. | |
cfdb727a AM |
388 | * |
389 | * @param eventName | |
390 | * - a event name | |
391 | * @param logLevelType | |
392 | * - a log level type | |
393 | * @param level | |
394 | * - a log level | |
d4514365 BH |
395 | * @param filterExpression |
396 | * - a filter expression | |
cfdb727a AM |
397 | * @param monitor |
398 | * - a progress monitor | |
ccc66d01 | 399 | * @throws ExecutionException |
cfdb727a | 400 | * If the command fails |
ccc66d01 | 401 | */ |
cfdb727a | 402 | public void enableLogLevel(String eventName, LogLevelType logLevelType, |
d4514365 | 403 | TraceLogLevel level, String filterExpression, IProgressMonitor monitor) |
cfdb727a | 404 | throws ExecutionException { |
d4514365 | 405 | getControlService().enableLogLevel(getSessionName(), getName(), eventName, logLevelType, level, filterExpression, monitor); |
ccc66d01 BH |
406 | } |
407 | ||
6503ae0f BH |
408 | /** |
409 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
410 | * |
411 | * @param eventNames | |
412 | * - a list of event names to enabled. | |
6503ae0f | 413 | * @throws ExecutionException |
cfdb727a | 414 | * If the command fails |
6503ae0f BH |
415 | */ |
416 | public void disableEvent(List<String> eventNames) throws ExecutionException { | |
417 | disableEvent(eventNames, new NullProgressMonitor()); | |
418 | } | |
419 | ||
420 | /** | |
421 | * Enables a list of events with no additional parameters. | |
cfdb727a AM |
422 | * |
423 | * @param eventNames | |
424 | * - a list of event names to enabled. | |
425 | * @param monitor | |
426 | * - a progress monitor | |
6503ae0f | 427 | * @throws ExecutionException |
cfdb727a | 428 | * If the command fails |
6503ae0f | 429 | */ |
cfdb727a AM |
430 | public void disableEvent(List<String> eventNames, IProgressMonitor monitor) |
431 | throws ExecutionException { | |
432 | getControlService().disableEvent(getParent().getParent().getName(), | |
433 | getName(), eventNames, isKernel(), monitor); | |
6503ae0f | 434 | } |
cfdb727a | 435 | |
b793fbe1 BH |
436 | /** |
437 | * Add contexts to given channels and or events | |
cfdb727a AM |
438 | * |
439 | * @param contexts | |
440 | * - a list of contexts to add | |
b793fbe1 | 441 | * @throws ExecutionException |
cfdb727a | 442 | * If the command fails |
b793fbe1 BH |
443 | */ |
444 | public void addContexts(List<String> contexts) throws ExecutionException { | |
445 | addContexts(contexts, new NullProgressMonitor()); | |
446 | } | |
447 | ||
448 | /** | |
449 | * Add contexts to given channels and or events | |
cfdb727a AM |
450 | * |
451 | * @param contexts | |
452 | * - a list of contexts to add | |
453 | * @param monitor | |
454 | * - a progress monitor | |
b793fbe1 | 455 | * @throws ExecutionException |
cfdb727a | 456 | * If the command fails |
b793fbe1 | 457 | */ |
cfdb727a AM |
458 | public void addContexts(List<String> contexts, IProgressMonitor monitor) |
459 | throws ExecutionException { | |
460 | getControlService().addContexts(getSessionName(), getName(), null, | |
461 | isKernel(), contexts, monitor); | |
b793fbe1 | 462 | } |
eb1bab5b | 463 | } |