1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
;
14 import java
.util
.List
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.Messages
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IChannelInfo
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IEventInfo
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.LogLevelType
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceEnablement
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceLogLevel
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceChannelPropertySource
;
28 import org
.eclipse
.swt
.graphics
.Image
;
29 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
33 * <b><u>TraceChannelComponent</u></b>
35 * Implementation of the trace channel component.
38 public class TraceChannelComponent
extends TraceControlComponent
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 * Path to icon file for this component (state enabled).
45 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED
= "icons/obj16/channel.gif"; //$NON-NLS-1$
47 * Path to icon file for this component (state disabled).
49 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED
= "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
55 * The channel information.
57 private IChannelInfo fChannelInfo
= null;
59 * The image to be displayed in disabled state.
61 private Image fDisabledImage
= null;
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
68 * @param name - the name of the component.
69 * @param parent - the parent of this component.
71 public TraceChannelComponent(String name
, ITraceControlComponent parent
) {
73 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED
);
74 setToolTip(Messages
.TraceControl_ChannelDisplayName
);
75 fChannelInfo
= new ChannelInfo(name
);
76 fDisabledImage
= Activator
.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED
);
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
87 public Image
getImage() {
88 if (fChannelInfo
.getState() == TraceEnablement
.DISABLED
) {
89 return fDisabledImage
;
91 return super.getImage();
95 * Sets the channel information.
98 public void setChannelInfo(IChannelInfo channelInfo
) {
99 fChannelInfo
= channelInfo
;
100 IEventInfo
[] events
= fChannelInfo
.getEvents();
101 for (int i
= 0; i
< events
.length
; i
++) {
102 TraceEventComponent event
= null;
103 if (events
[i
].getClass() == ProbeEventInfo
.class) {
104 event
= new TraceProbeEventComponent(events
[i
].getName(), this);
106 event
= new TraceEventComponent(events
[i
].getName(), this);
109 event
.setEventInfo(events
[i
]);
115 * @return the overwrite mode value.
117 public boolean isOverwriteMode() {
118 return fChannelInfo
.isOverwriteMode();
121 * Sets the overwrite mode value to the given mode.
122 * @param mode - mode to set.
124 public void setOverwriteMode(boolean mode
){
125 fChannelInfo
.setOverwriteMode(mode
);
128 * @return the sub-buffer size.
130 public long getSubBufferSize() {
131 return fChannelInfo
.getSubBufferSize();
134 * Sets the sub-buffer size to the given value.
135 * @param bufferSize - size to set to set.
137 public void setSubBufferSize(long bufferSize
) {
138 fChannelInfo
.setSubBufferSize(bufferSize
);
141 * @return the number of sub-buffers.
143 public int getNumberOfSubBuffers() {
144 return fChannelInfo
.getNumberOfSubBuffers();
147 * Sets the number of sub-buffers to the given value.
148 * @param numberOfSubBuffers - value to set.
150 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
151 fChannelInfo
.setNumberOfSubBuffers(numberOfSubBuffers
);
154 * @return the switch timer interval.
156 public long getSwitchTimer() {
157 return fChannelInfo
.getSwitchTimer();
160 * Sets the switch timer interval to the given value.
161 * @param timer - timer value to set.
163 public void setSwitchTimer(long timer
) {
164 fChannelInfo
.setSwitchTimer(timer
);
167 * @return the read timer interval.
169 public long getReadTimer() {
170 return fChannelInfo
.getReadTimer();
173 * Sets the read timer interval to the given value.
174 * @param timer - timer value to set..
176 public void setReadTimer(long timer
) {
177 fChannelInfo
.setReadTimer(timer
);
180 * @return the output type.
182 public String
getOutputType() {
183 return fChannelInfo
.getOutputType();
186 * Sets the output type to the given value.
187 * @param type - type to set.
189 public void setOutputType(String type
) {
190 fChannelInfo
.setOutputType(type
);
193 * @return the channel state (enabled or disabled).
195 public TraceEnablement
getState() {
196 return fChannelInfo
.getState();
199 * Sets the channel state (enablement) to the given value.
200 * @param state - state to set.
202 public void setState(TraceEnablement state
) {
203 fChannelInfo
.setState(state
);
206 * Sets the channel state (enablement) to the value specified by the given name.
207 * @param stateName - state to set.
209 public void setState(String stateName
) {
210 fChannelInfo
.setState(stateName
);
214 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
216 @SuppressWarnings("rawtypes")
218 public Object
getAdapter(Class adapter
) {
219 if (adapter
== IPropertySource
.class) {
220 return new TraceChannelPropertySource(this);
226 * @return session name from parent
228 public String
getSessionName() {
229 return ((TraceDomainComponent
)getParent()).getSessionName();
233 * @return session from parent
235 public TraceSessionComponent
getSession() {
236 return ((TraceDomainComponent
)getParent()).getSession();
240 * @return if domain is kernel or UST
242 public boolean isKernel() {
243 return ((TraceDomainComponent
)getParent()).isKernel();
247 * @return the parent target node
249 public TargetNodeComponent
getTargetNode() {
250 return ((TraceDomainComponent
)getParent()).getTargetNode();
253 // ------------------------------------------------------------------------
255 // ------------------------------------------------------------------------
257 * Enables a list of events with no additional parameters.
258 * @param eventNames - a list of event names to enabled.
259 * @throws ExecutionException
261 public void enableEvents(List
<String
> eventNames
) throws ExecutionException
{
262 enableEvents(eventNames
, new NullProgressMonitor());
266 * Enables a list of events with no additional parameters.
267 * @param eventNames - a list of event names to enabled.
268 * @param monitor - a progress monitor
269 * @throws ExecutionException
271 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
272 getControlService().enableEvents(getSessionName(), getName(), eventNames
, isKernel(), monitor
);
276 * Enables all syscalls (for kernel domain)
277 * @throws ExecutionException
279 public void enableSyscalls() throws ExecutionException
{
280 enableSyscalls(new NullProgressMonitor());
284 * Enables all syscalls (for kernel domain)
285 * @param monitor - a progress monitor
286 * @throws ExecutionException
288 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
289 getControlService().enableSyscalls(getSessionName(), getName(), monitor
);
293 * Enables a dynamic probe (for kernel domain)
294 * @param eventName - event name for probe
295 * @param isFunction - true for dynamic function entry/return probe else false
296 * @param probe - the actual probe
297 * @throws ExecutionException
299 public void enableProbe(String eventName
, boolean isFunction
, String probe
) throws ExecutionException
{
300 enableProbe(eventName
, isFunction
, probe
, new NullProgressMonitor());
304 * Enables a dynamic probe (for kernel domain)
305 * @param eventName - event name for probe
306 * @param isFunction - true for dynamic function entry/return probe else false
307 * @param probe - the actual probe
308 * @param monitor - a progress monitor
309 * @throws ExecutionException
311 public void enableProbe(String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
312 getControlService().enableProbe(getSessionName(), getName(), eventName
, isFunction
, probe
, monitor
);
316 * Enables events using log level.
317 * @param eventName - a event name
318 * @param logLevelType - a log level type
319 * @param level - a log level
320 * @throws ExecutionException
322 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
) throws ExecutionException
{
323 enableLogLevel(eventName
, logLevelType
, level
, new NullProgressMonitor());
327 * Enables events using log level.
328 * @param eventName - a event name
329 * @param logLevelType - a log level type
330 * @param level - a log level
331 * @param monitor - a progress monitor
332 * @throws ExecutionException
334 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
335 getControlService().enableLogLevel(getSessionName(), getName(), eventName
, logLevelType
, level
, monitor
);
339 * Enables a list of events with no additional parameters.
340 * @param eventNames - a list of event names to enabled.
341 * @throws ExecutionException
343 public void disableEvent(List
<String
> eventNames
) throws ExecutionException
{
344 disableEvent(eventNames
, new NullProgressMonitor());
348 * Enables a list of events with no additional parameters.
349 * @param eventNames - a list of event names to enabled.
350 * @param monitor - a progress monitor
351 * @throws ExecutionException
353 public void disableEvent(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
354 getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames
, isKernel(), monitor
);