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
.TraceDomainType
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IEventInfo
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ITraceLogLevel
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceChannelOutputType
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceEnablement
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ChannelInfo
;
29 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.ProbeEventInfo
;
30 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.Activator
;
31 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
32 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
33 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.property
.TraceChannelPropertySource
;
34 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
39 * Implementation of the trace channel component.
42 * @author Bernd Hufmann
44 public class TraceChannelComponent
extends TraceControlComponent
{
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
51 * Path to icon file for this component (state enabled).
53 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED
= "icons/obj16/channel.gif"; //$NON-NLS-1$
55 * Path to icon file for this component (state disabled).
57 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED
= "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
64 * The channel information.
66 private IChannelInfo fChannelInfo
= null;
68 * The image to be displayed in disabled state.
70 private Image fDisabledImage
= null;
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
78 * @param name - the name of the component.
79 * @param parent - the parent of this component.
81 public TraceChannelComponent(String name
, ITraceControlComponent parent
) {
83 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED
);
84 setToolTip(Messages
.TraceControl_ChannelDisplayName
);
85 fChannelInfo
= new ChannelInfo(name
);
86 fDisabledImage
= Activator
.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED
);
89 // ------------------------------------------------------------------------
91 // ------------------------------------------------------------------------
94 public Image
getImage() {
95 if (fChannelInfo
.getState() == TraceEnablement
.DISABLED
) {
96 return fDisabledImage
;
98 return super.getImage();
102 * Sets the channel information.
105 * The channel info to assign to this component
107 public void setChannelInfo(IChannelInfo channelInfo
) {
108 fChannelInfo
= channelInfo
;
109 IEventInfo
[] events
= fChannelInfo
.getEvents();
110 List
<ITraceControlComponent
> eventComponents
= new ArrayList
<>();
111 for (int i
= 0; i
< events
.length
; i
++) {
112 TraceEventComponent event
= null;
113 if (events
[i
].getClass() == ProbeEventInfo
.class) {
114 event
= new TraceProbeEventComponent(events
[i
].getName(), this);
116 event
= new TraceEventComponent(events
[i
].getName(), this);
119 eventComponents
.add(event
);
120 event
.setEventInfo(events
[i
]);
122 if (!eventComponents
.isEmpty()) {
123 setChildren(eventComponents
);
128 * @return the overwrite mode value.
130 public boolean isOverwriteMode() {
131 return fChannelInfo
.isOverwriteMode();
134 * Sets the overwrite mode value to the given mode.
135 * @param mode - mode to set.
137 public void setOverwriteMode(boolean mode
){
138 fChannelInfo
.setOverwriteMode(mode
);
141 * @return the sub-buffer size.
143 public long getSubBufferSize() {
144 return fChannelInfo
.getSubBufferSize();
147 * Sets the sub-buffer size to the given value.
148 * @param bufferSize - size to set to set.
150 public void setSubBufferSize(long bufferSize
) {
151 fChannelInfo
.setSubBufferSize(bufferSize
);
154 * @return the number of sub-buffers.
156 public int getNumberOfSubBuffers() {
157 return fChannelInfo
.getNumberOfSubBuffers();
160 * Sets the number of sub-buffers to the given value.
161 * @param numberOfSubBuffers - value to set.
163 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
164 fChannelInfo
.setNumberOfSubBuffers(numberOfSubBuffers
);
167 * @return the switch timer interval.
169 public long getSwitchTimer() {
170 return fChannelInfo
.getSwitchTimer();
173 * Sets the switch timer interval to the given value.
174 * @param timer - timer value to set.
176 public void setSwitchTimer(long timer
) {
177 fChannelInfo
.setSwitchTimer(timer
);
180 * @return the read timer interval.
182 public long getReadTimer() {
183 return fChannelInfo
.getReadTimer();
186 * Sets the read timer interval to the given value.
187 * @param timer - timer value to set..
189 public void setReadTimer(long timer
) {
190 fChannelInfo
.setReadTimer(timer
);
193 * @return the output type.
195 public TraceChannelOutputType
getOutputType() {
196 return fChannelInfo
.getOutputType();
199 * Sets the output type to the given value.
200 * @param type - type to set.
202 public void setOutputType(TraceChannelOutputType type
) {
203 fChannelInfo
.setOutputType(type
);
206 * Sets the output type to the given value.
207 * @param type - type to set.
209 public void setOutputType(String type
) {
210 fChannelInfo
.setOutputType(type
);
214 * @return the channel state (enabled or disabled).
216 public TraceEnablement
getState() {
217 return fChannelInfo
.getState();
220 * Sets the channel state (enablement) to the given value.
221 * @param state - state to set.
223 public void setState(TraceEnablement state
) {
224 fChannelInfo
.setState(state
);
227 * Sets the channel state (enablement) to the value specified by the given name.
228 * @param stateName - state to set.
230 public void setState(String stateName
) {
231 fChannelInfo
.setState(stateName
);
235 * @return number of discarded events
237 public long getNumberOfDiscardedEvents() {
238 return fChannelInfo
.getNumberOfDiscardedEvents();
241 * @return number of lost packets
243 public long getNumberOfLostPackets() {
244 return fChannelInfo
.getNumberOfLostPackets();
248 * @return maximum size of trace files
250 public long getMaxSizeTraceFiles() {
251 return fChannelInfo
.getMaxSizeTraceFiles();
254 * @return maximum number of trace files
256 public int getMaxNumberTraceFiles() {
257 return fChannelInfo
.getMaxNumberTraceFiles();
261 public <T
> T
getAdapter(Class
<T
> adapter
) {
262 if (adapter
== IPropertySource
.class) {
263 return adapter
.cast(new TraceChannelPropertySource(this));
269 * @return session name from parent
271 public String
getSessionName() {
272 return ((TraceDomainComponent
)getParent()).getSessionName();
276 * @return session from parent
278 public TraceSessionComponent
getSession() {
279 return ((TraceDomainComponent
)getParent()).getSession();
283 * @return the domain type ({@link TraceDomainType})
285 public TraceDomainType
getDomain() {
286 return ((TraceDomainComponent
)getParent()).getDomain();
290 * @return the parent target node
292 public TargetNodeComponent
getTargetNode() {
293 return ((TraceDomainComponent
)getParent()).getTargetNode();
296 // ------------------------------------------------------------------------
298 // ------------------------------------------------------------------------
301 * Enables a list of events with no additional parameters.
304 * - a list of event names to enabled.
306 * - a progress monitor
307 * @throws ExecutionException
308 * If the command fails
310 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
311 enableEvents(eventNames
, null, null, monitor
);
315 * Enables a list of events with no additional parameters.
318 * - a list of event names to enabled.
319 * @param filterExpression
320 * - a filter expression
321 * @param excludedEvents
322 * - a list of events to exclude.
324 * - a progress monitor
325 * @throws ExecutionException
326 * If the command fails
328 public void enableEvents(List
<String
> eventNames
, String filterExpression
, List
<String
> excludedEvents
, IProgressMonitor monitor
) throws ExecutionException
{
329 getControlService().enableEvents(getSessionName(), getName(), eventNames
, getDomain(), filterExpression
, excludedEvents
, monitor
);
333 * Enables all syscalls (for kernel domain)
335 * @param syscallNames
336 * - a list of syscall to enable
338 * - a progress monitor
339 * @throws ExecutionException
340 * If the command fails
342 public void enableSyscalls(List
<String
> syscallNames
, IProgressMonitor monitor
) throws ExecutionException
{
343 getControlService().enableSyscalls(getSessionName(), getName(), syscallNames
, monitor
);
347 * Enables a dynamic probe (for kernel domain)
350 * - event name for probe
352 * - true for dynamic function entry/return probe else false
356 * - a progress monitor
357 * @throws ExecutionException
358 * If the command fails
360 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
361 IProgressMonitor monitor
) throws ExecutionException
{
362 getControlService().enableProbe(getSessionName(), getName(), eventName
, isFunction
, probe
, monitor
);
366 * Enables events using log level.
369 * - a list of event names
370 * @param logLevelType
374 * @param filterExpression
375 * - a filter expression
377 * - the domain type ({@link TraceDomainType})
379 * - a progress monitor
380 * @throws ExecutionException
381 * If the command fails
383 public void enableLogLevel(List
<String
> eventNames
, LogLevelType logLevelType
,
384 ITraceLogLevel level
, String filterExpression
, TraceDomainType domain
, IProgressMonitor monitor
)
385 throws ExecutionException
{
386 getControlService().enableLogLevel(getSessionName(), getName(), eventNames
, logLevelType
, level
, filterExpression
, domain
, monitor
);
390 * Enables a list of events with no additional parameters.
393 * - a list of event names to enabled.
395 * - a progress monitor
396 * @throws ExecutionException
397 * If the command fails
399 public void disableEvent(List
<String
> eventNames
, IProgressMonitor monitor
)
400 throws ExecutionException
{
401 getControlService().disableEvent(getParent().getParent().getName(),
402 getName(), eventNames
, getDomain(), monitor
);
406 * Add contexts to given channels and or events
409 * - a list of contexts to add
411 * - a progress monitor
412 * @throws ExecutionException
413 * If the command fails
415 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
416 throws ExecutionException
{
417 getControlService().addContexts(getSessionName(), getName(), null,
418 getDomain(), contexts
, monitor
);