1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
;
15 import java
.util
.ArrayList
;
16 import java
.util
.List
;
18 import org
.eclipse
.core
.commands
.ExecutionException
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
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
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceChannelPropertySource
;
32 import org
.eclipse
.swt
.graphics
.Image
;
33 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
38 * Implementation of the trace channel component.
41 * @author Bernd Hufmann
43 public class TraceChannelComponent
extends TraceControlComponent
{
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
48 * Path to icon file for this component (state enabled).
50 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED
= "icons/obj16/channel.gif"; //$NON-NLS-1$
52 * Path to icon file for this component (state disabled).
54 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED
= "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
60 * The channel information.
62 private IChannelInfo fChannelInfo
= null;
64 * The image to be displayed in disabled state.
66 private Image fDisabledImage
= null;
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
73 * @param name - the name of the component.
74 * @param parent - the parent of this component.
76 public TraceChannelComponent(String name
, ITraceControlComponent parent
) {
78 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED
);
79 setToolTip(Messages
.TraceControl_ChannelDisplayName
);
80 fChannelInfo
= new ChannelInfo(name
);
81 fDisabledImage
= Activator
.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED
);
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
92 public Image
getImage() {
93 if (fChannelInfo
.getState() == TraceEnablement
.DISABLED
) {
94 return fDisabledImage
;
96 return super.getImage();
100 * Sets the channel information.
103 * The channel info to assign to this component
105 public void setChannelInfo(IChannelInfo channelInfo
) {
106 fChannelInfo
= channelInfo
;
107 IEventInfo
[] events
= fChannelInfo
.getEvents();
108 List
<ITraceControlComponent
> eventComponents
= new ArrayList
<ITraceControlComponent
>();
109 for (int i
= 0; i
< events
.length
; i
++) {
110 TraceEventComponent event
= null;
111 if (events
[i
].getClass() == ProbeEventInfo
.class) {
112 event
= new TraceProbeEventComponent(events
[i
].getName(), this);
114 event
= new TraceEventComponent(events
[i
].getName(), this);
117 eventComponents
.add(event
);
118 event
.setEventInfo(events
[i
]);
121 if (!eventComponents
.isEmpty()) {
122 setChildren(eventComponents
);
127 * @return the overwrite mode value.
129 public boolean isOverwriteMode() {
130 return fChannelInfo
.isOverwriteMode();
133 * Sets the overwrite mode value to the given mode.
134 * @param mode - mode to set.
136 public void setOverwriteMode(boolean mode
){
137 fChannelInfo
.setOverwriteMode(mode
);
140 * @return the sub-buffer size.
142 public long getSubBufferSize() {
143 return fChannelInfo
.getSubBufferSize();
146 * Sets the sub-buffer size to the given value.
147 * @param bufferSize - size to set to set.
149 public void setSubBufferSize(long bufferSize
) {
150 fChannelInfo
.setSubBufferSize(bufferSize
);
153 * @return the number of sub-buffers.
155 public int getNumberOfSubBuffers() {
156 return fChannelInfo
.getNumberOfSubBuffers();
159 * Sets the number of sub-buffers to the given value.
160 * @param numberOfSubBuffers - value to set.
162 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
163 fChannelInfo
.setNumberOfSubBuffers(numberOfSubBuffers
);
166 * @return the switch timer interval.
168 public long getSwitchTimer() {
169 return fChannelInfo
.getSwitchTimer();
172 * Sets the switch timer interval to the given value.
173 * @param timer - timer value to set.
175 public void setSwitchTimer(long timer
) {
176 fChannelInfo
.setSwitchTimer(timer
);
179 * @return the read timer interval.
181 public long getReadTimer() {
182 return fChannelInfo
.getReadTimer();
185 * Sets the read timer interval to the given value.
186 * @param timer - timer value to set..
188 public void setReadTimer(long timer
) {
189 fChannelInfo
.setReadTimer(timer
);
192 * @return the output type.
194 public String
getOutputType() {
195 return fChannelInfo
.getOutputType();
198 * Sets the output type to the given value.
199 * @param type - type to set.
201 public void setOutputType(String type
) {
202 fChannelInfo
.setOutputType(type
);
205 * @return the channel state (enabled or disabled).
207 public TraceEnablement
getState() {
208 return fChannelInfo
.getState();
211 * Sets the channel state (enablement) to the given value.
212 * @param state - state to set.
214 public void setState(TraceEnablement state
) {
215 fChannelInfo
.setState(state
);
218 * Sets the channel state (enablement) to the value specified by the given name.
219 * @param stateName - state to set.
221 public void setState(String stateName
) {
222 fChannelInfo
.setState(stateName
);
226 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
229 public Object
getAdapter(Class adapter
) {
230 if (adapter
== IPropertySource
.class) {
231 return new TraceChannelPropertySource(this);
237 * @return session name from parent
239 public String
getSessionName() {
240 return ((TraceDomainComponent
)getParent()).getSessionName();
244 * @return session from parent
246 public TraceSessionComponent
getSession() {
247 return ((TraceDomainComponent
)getParent()).getSession();
251 * @return if domain is kernel or UST
253 public boolean isKernel() {
254 return ((TraceDomainComponent
)getParent()).isKernel();
258 * @return the parent target node
260 public TargetNodeComponent
getTargetNode() {
261 return ((TraceDomainComponent
)getParent()).getTargetNode();
264 // ------------------------------------------------------------------------
266 // ------------------------------------------------------------------------
268 * Enables a list of events with no additional parameters.
271 * - a list of event names to enabled.
272 * @throws ExecutionException
273 * If the command fails
275 public void enableEvents(List
<String
> eventNames
) throws ExecutionException
{
276 enableEvents(eventNames
, new NullProgressMonitor());
280 * Enables a list of events with no additional parameters.
283 * - a list of event names to enabled.
285 * - a progress monitor
286 * @throws ExecutionException
287 * If the command fails
289 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
290 enableEvents(eventNames
, null, monitor
);
294 * Enables a list of events with no additional parameters.
297 * - a list of event names to enabled.
298 * @param filterExpression
299 * - a filter expression
301 * - a progress monitor
302 * @throws ExecutionException
303 * If the command fails
305 public void enableEvents(List
<String
> eventNames
, String filterExpression
, IProgressMonitor monitor
) throws ExecutionException
{
306 getControlService().enableEvents(getSessionName(), getName(), eventNames
, isKernel(), filterExpression
, monitor
);
310 * Enables all syscalls (for kernel domain)
312 * @throws ExecutionException
313 * If the command fails
315 public void enableSyscalls() throws ExecutionException
{
316 enableSyscalls(new NullProgressMonitor());
320 * Enables all syscalls (for kernel domain)
323 * - a progress monitor
324 * @throws ExecutionException
325 * If the command fails
327 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
328 getControlService().enableSyscalls(getSessionName(), getName(), monitor
);
332 * Enables a dynamic probe (for kernel domain)
335 * - event name for probe
337 * - true for dynamic function entry/return probe else false
340 * @throws ExecutionException
341 * If the command fails
343 public void enableProbe(String eventName
, boolean isFunction
, String probe
)
344 throws ExecutionException
{
345 enableProbe(eventName
, isFunction
, probe
, new NullProgressMonitor());
349 * Enables a dynamic probe (for kernel domain)
352 * - event name for probe
354 * - true for dynamic function entry/return probe else false
358 * - a progress monitor
359 * @throws ExecutionException
360 * If the command fails
362 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
363 IProgressMonitor monitor
) throws ExecutionException
{
364 getControlService().enableProbe(getSessionName(), getName(), eventName
, isFunction
, probe
, monitor
);
368 * Enables events using log level.
372 * @param logLevelType
376 * @param filterExpression
377 * - a filter expression
378 * @throws ExecutionException
379 * If the command fails
381 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
382 TraceLogLevel level
, String filterExpression
) throws ExecutionException
{
383 enableLogLevel(eventName
, logLevelType
, level
, filterExpression
, new NullProgressMonitor());
387 * Enables events using log level.
391 * @param logLevelType
395 * @param filterExpression
396 * - a filter expression
398 * - a progress monitor
399 * @throws ExecutionException
400 * If the command fails
402 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
403 TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
)
404 throws ExecutionException
{
405 getControlService().enableLogLevel(getSessionName(), getName(), eventName
, logLevelType
, level
, filterExpression
, monitor
);
409 * Enables a list of events with no additional parameters.
412 * - a list of event names to enabled.
413 * @throws ExecutionException
414 * If the command fails
416 public void disableEvent(List
<String
> eventNames
) throws ExecutionException
{
417 disableEvent(eventNames
, new NullProgressMonitor());
421 * Enables a list of events with no additional parameters.
424 * - a list of event names to enabled.
426 * - a progress monitor
427 * @throws ExecutionException
428 * If the command fails
430 public void disableEvent(List
<String
> eventNames
, IProgressMonitor monitor
)
431 throws ExecutionException
{
432 getControlService().disableEvent(getParent().getParent().getName(),
433 getName(), eventNames
, isKernel(), monitor
);
437 * Add contexts to given channels and or events
440 * - a list of contexts to add
441 * @throws ExecutionException
442 * If the command fails
444 public void addContexts(List
<String
> contexts
) throws ExecutionException
{
445 addContexts(contexts
, new NullProgressMonitor());
449 * Add contexts to given channels and or events
452 * - a list of contexts to add
454 * - a progress monitor
455 * @throws ExecutionException
456 * If the command fails
458 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
459 throws ExecutionException
{
460 getControlService().addContexts(getSessionName(), getName(), null,
461 isKernel(), contexts
, monitor
);