1 /**********************************************************************
2 * Copyright (c) 2012, 2015 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
.tracecompass
.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
.swt
.graphics
.Image
;
21 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IEventInfo
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceChannelOutputType
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ProbeEventInfo
;
29 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.Activator
;
30 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
31 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
32 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.property
.TraceChannelPropertySource
;
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 * @return maximum size of trace files
236 public long getMaxSizeTraceFiles() {
237 return fChannelInfo
.getMaxSizeTraceFiles();
240 * @return maximum number of trace files
242 public int getMaxNumberTraceFiles() {
243 return fChannelInfo
.getMaxNumberTraceFiles();
247 public <T
> T
getAdapter(Class
<T
> adapter
) {
248 if (adapter
== IPropertySource
.class) {
249 return adapter
.cast(new TraceChannelPropertySource(this));
255 * @return session name from parent
257 public String
getSessionName() {
258 return ((TraceDomainComponent
)getParent()).getSessionName();
262 * @return session from parent
264 public TraceSessionComponent
getSession() {
265 return ((TraceDomainComponent
)getParent()).getSession();
269 * @return if domain is kernel or UST
271 public boolean isKernel() {
272 return ((TraceDomainComponent
)getParent()).isKernel();
276 * @return the parent target node
278 public TargetNodeComponent
getTargetNode() {
279 return ((TraceDomainComponent
)getParent()).getTargetNode();
282 // ------------------------------------------------------------------------
284 // ------------------------------------------------------------------------
287 * Enables a list of events with no additional parameters.
290 * - a list of event names to enabled.
292 * - a progress monitor
293 * @throws ExecutionException
294 * If the command fails
296 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
297 enableEvents(eventNames
, null, null, monitor
);
301 * Enables a list of events with no additional parameters.
304 * - a list of event names to enabled.
305 * @param filterExpression
306 * - a filter expression
307 * @param excludedEvents
308 * - a list of events to exclude.
310 * - a progress monitor
311 * @throws ExecutionException
312 * If the command fails
314 public void enableEvents(List
<String
> eventNames
, String filterExpression
, List
<String
> excludedEvents
, IProgressMonitor monitor
) throws ExecutionException
{
315 getControlService().enableEvents(getSessionName(), getName(), eventNames
, isKernel(), filterExpression
, excludedEvents
, monitor
);
319 * Enables all syscalls (for kernel domain)
322 * - a progress monitor
323 * @throws ExecutionException
324 * If the command fails
326 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
327 getControlService().enableSyscalls(getSessionName(), getName(), monitor
);
331 * Enables a dynamic probe (for kernel domain)
334 * - event name for probe
336 * - true for dynamic function entry/return probe else false
340 * - a progress monitor
341 * @throws ExecutionException
342 * If the command fails
344 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
345 IProgressMonitor monitor
) throws ExecutionException
{
346 getControlService().enableProbe(getSessionName(), getName(), eventName
, isFunction
, probe
, monitor
);
350 * Enables events using log level.
354 * @param logLevelType
358 * @param filterExpression
359 * - a filter expression
361 * - a progress monitor
362 * @throws ExecutionException
363 * If the command fails
365 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
366 TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
)
367 throws ExecutionException
{
368 getControlService().enableLogLevel(getSessionName(), getName(), eventName
, logLevelType
, level
, filterExpression
, monitor
);
372 * Enables a list of events with no additional parameters.
375 * - a list of event names to enabled.
377 * - a progress monitor
378 * @throws ExecutionException
379 * If the command fails
381 public void disableEvent(List
<String
> eventNames
, IProgressMonitor monitor
)
382 throws ExecutionException
{
383 getControlService().disableEvent(getParent().getParent().getName(),
384 getName(), eventNames
, isKernel(), monitor
);
388 * Add contexts to given channels and or events
391 * - a list of contexts to add
393 * - a progress monitor
394 * @throws ExecutionException
395 * If the command fails
397 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
398 throws ExecutionException
{
399 getControlService().addContexts(getSessionName(), getName(), null,
400 isKernel(), contexts
, monitor
);