1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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
.control
.ui
.views
.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
.linuxtools
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IEventInfo
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceChannelOutputType
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.ProbeEventInfo
;
28 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.Activator
;
29 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
30 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
31 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.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
{
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
50 * Path to icon file for this component (state enabled).
52 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED
= "icons/obj16/channel.gif"; //$NON-NLS-1$
54 * Path to icon file for this component (state disabled).
56 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED
= "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
58 // ------------------------------------------------------------------------
60 // ------------------------------------------------------------------------
63 * The channel information.
65 private IChannelInfo fChannelInfo
= null;
67 * The image to be displayed in disabled state.
69 private Image fDisabledImage
= null;
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
77 * @param name - the name of the component.
78 * @param parent - the parent of this component.
80 public TraceChannelComponent(String name
, ITraceControlComponent parent
) {
82 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED
);
83 setToolTip(Messages
.TraceControl_ChannelDisplayName
);
84 fChannelInfo
= new ChannelInfo(name
);
85 fDisabledImage
= Activator
.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED
);
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
93 public Image
getImage() {
94 if (fChannelInfo
.getState() == TraceEnablement
.DISABLED
) {
95 return fDisabledImage
;
97 return super.getImage();
101 * Sets the channel information.
104 * The channel info to assign to this component
106 public void setChannelInfo(IChannelInfo channelInfo
) {
107 fChannelInfo
= channelInfo
;
108 IEventInfo
[] events
= fChannelInfo
.getEvents();
109 List
<ITraceControlComponent
> eventComponents
= new ArrayList
<>();
110 for (int i
= 0; i
< events
.length
; i
++) {
111 TraceEventComponent event
= null;
112 if (events
[i
].getClass() == ProbeEventInfo
.class) {
113 event
= new TraceProbeEventComponent(events
[i
].getName(), this);
115 event
= new TraceEventComponent(events
[i
].getName(), this);
118 eventComponents
.add(event
);
119 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 TraceChannelOutputType
getOutputType() {
195 return fChannelInfo
.getOutputType();
198 * Sets the output type to the given value.
199 * @param type - type to set.
201 public void setOutputType(TraceChannelOutputType type
) {
202 fChannelInfo
.setOutputType(type
);
205 * Sets the output type to the given value.
206 * @param type - type to set.
208 public void setOutputType(String type
) {
209 fChannelInfo
.setOutputType(type
);
213 * @return the channel state (enabled or disabled).
215 public TraceEnablement
getState() {
216 return fChannelInfo
.getState();
219 * Sets the channel state (enablement) to the given value.
220 * @param state - state to set.
222 public void setState(TraceEnablement state
) {
223 fChannelInfo
.setState(state
);
226 * Sets the channel state (enablement) to the value specified by the given name.
227 * @param stateName - state to set.
229 public void setState(String stateName
) {
230 fChannelInfo
.setState(stateName
);
234 public Object
getAdapter(Class adapter
) {
235 if (adapter
== IPropertySource
.class) {
236 return new TraceChannelPropertySource(this);
242 * @return session name from parent
244 public String
getSessionName() {
245 return ((TraceDomainComponent
)getParent()).getSessionName();
249 * @return session from parent
251 public TraceSessionComponent
getSession() {
252 return ((TraceDomainComponent
)getParent()).getSession();
256 * @return if domain is kernel or UST
258 public boolean isKernel() {
259 return ((TraceDomainComponent
)getParent()).isKernel();
263 * @return the parent target node
265 public TargetNodeComponent
getTargetNode() {
266 return ((TraceDomainComponent
)getParent()).getTargetNode();
269 // ------------------------------------------------------------------------
271 // ------------------------------------------------------------------------
274 * Enables a list of events with no additional parameters.
277 * - a list of event names to enabled.
279 * - a progress monitor
280 * @throws ExecutionException
281 * If the command fails
283 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
284 enableEvents(eventNames
, null, monitor
);
288 * Enables a list of events with no additional parameters.
291 * - a list of event names to enabled.
292 * @param filterExpression
293 * - a filter expression
295 * - a progress monitor
296 * @throws ExecutionException
297 * If the command fails
299 public void enableEvents(List
<String
> eventNames
, String filterExpression
, IProgressMonitor monitor
) throws ExecutionException
{
300 getControlService().enableEvents(getSessionName(), getName(), eventNames
, isKernel(), filterExpression
, monitor
);
304 * Enables all syscalls (for kernel domain)
307 * - a progress monitor
308 * @throws ExecutionException
309 * If the command fails
311 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
312 getControlService().enableSyscalls(getSessionName(), getName(), monitor
);
316 * Enables a dynamic probe (for kernel domain)
319 * - event name for probe
321 * - true for dynamic function entry/return probe else false
325 * - a progress monitor
326 * @throws ExecutionException
327 * If the command fails
329 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
330 IProgressMonitor monitor
) throws ExecutionException
{
331 getControlService().enableProbe(getSessionName(), getName(), eventName
, isFunction
, probe
, monitor
);
335 * Enables events using log level.
339 * @param logLevelType
343 * @param filterExpression
344 * - a filter expression
346 * - a progress monitor
347 * @throws ExecutionException
348 * If the command fails
350 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
351 TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
)
352 throws ExecutionException
{
353 getControlService().enableLogLevel(getSessionName(), getName(), eventName
, logLevelType
, level
, filterExpression
, monitor
);
357 * Enables a list of events with no additional parameters.
360 * - a list of event names to enabled.
362 * - a progress monitor
363 * @throws ExecutionException
364 * If the command fails
366 public void disableEvent(List
<String
> eventNames
, IProgressMonitor monitor
)
367 throws ExecutionException
{
368 getControlService().disableEvent(getParent().getParent().getName(),
369 getName(), eventNames
, isKernel(), monitor
);
373 * Add contexts to given channels and or events
376 * - a list of contexts to add
378 * - a progress monitor
379 * @throws ExecutionException
380 * If the command fails
382 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
383 throws ExecutionException
{
384 getControlService().addContexts(getSessionName(), getName(), null,
385 isKernel(), contexts
, monitor
);