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
.lttng
.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
.lttng
.ui
.LTTngUiPlugin
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.Messages
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IChannelInfo
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IEventInfo
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ITraceControlComponent
;
24 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.LogLevelType
;
25 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceEnablement
;
26 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceLogLevel
;
27 import org
.eclipse
.linuxtools
.lttng
.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
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED
);
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 * @see org.eclipse.linuxtools.lttng.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
= new TraceEventComponent(events
[i
].getName(), this);
103 event
.setEventInfo(events
[i
]);
109 * @return the overwrite mode value.
111 public boolean isOverwriteMode() {
112 return fChannelInfo
.isOverwriteMode();
115 * Sets the overwrite mode value to the given mode.
116 * @param mode - mode to set.
118 public void setOverwriteMode(boolean mode
){
119 fChannelInfo
.setOverwriteMode(mode
);
122 * @return the sub-buffer size.
124 public long getSubBufferSize() {
125 return fChannelInfo
.getSubBufferSize();
128 * Sets the sub-buffer size to the given value.
129 * @param bufferSize - size to set to set.
131 public void setSubBufferSize(long bufferSize
) {
132 fChannelInfo
.setSubBufferSize(bufferSize
);
135 * @return the number of sub-buffers.
137 public int getNumberOfSubBuffers() {
138 return fChannelInfo
.getNumberOfSubBuffers();
141 * Sets the number of sub-buffers to the given value.
142 * @param numberOfSubBuffers - value to set.
144 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
145 fChannelInfo
.setNumberOfSubBuffers(numberOfSubBuffers
);
148 * @return the switch timer interval.
150 public long getSwitchTimer() {
151 return fChannelInfo
.getSwitchTimer();
154 * Sets the switch timer interval to the given value.
155 * @param timer - timer value to set.
157 public void setSwitchTimer(long timer
) {
158 fChannelInfo
.setSwitchTimer(timer
);
161 * @return the read timer interval.
163 public long getReadTimer() {
164 return fChannelInfo
.getReadTimer();
167 * Sets the read timer interval to the given value.
168 * @param timer - timer value to set..
170 public void setReadTimer(long timer
) {
171 fChannelInfo
.setReadTimer(timer
);
174 * @return the output type.
176 public String
getOutputType() {
177 return fChannelInfo
.getOutputType();
180 * Sets the output type to the given value.
181 * @param type - type to set.
183 public void setOutputType(String type
) {
184 fChannelInfo
.setOutputType(type
);
187 * @return the channel state (enabled or disabled).
189 public TraceEnablement
getState() {
190 return fChannelInfo
.getState();
193 * Sets the channel state (enablement) to the given value.
194 * @param state - state to set.
196 public void setState(TraceEnablement state
) {
197 fChannelInfo
.setState(state
);
200 * Sets the channel state (enablement) to the value specified by the given name.
201 * @param stateName - state to set.
203 public void setState(String stateName
) {
204 fChannelInfo
.setState(stateName
);
208 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
210 @SuppressWarnings("rawtypes")
212 public Object
getAdapter(Class adapter
) {
213 if (adapter
== IPropertySource
.class) {
214 return new TraceChannelPropertySource(this);
220 * @return session name from parent
222 public String
getSessionName() {
223 return ((TraceDomainComponent
)getParent()).getSessionName();
227 * @return session from parent
229 public TraceSessionComponent
getSession() {
230 return ((TraceDomainComponent
)getParent()).getSession();
234 * @return if domain is kernel or UST
236 public boolean isKernel() {
237 return ((TraceDomainComponent
)getParent()).isKernel();
241 * @return the parent target node
243 public TargetNodeComponent
getTargetNode() {
244 return ((TraceDomainComponent
)getParent()).getTargetNode();
247 // ------------------------------------------------------------------------
249 // ------------------------------------------------------------------------
251 * Enables a list of events with no additional parameters.
252 * @param eventNames - a list of event names to enabled.
253 * @throws ExecutionException
255 public void enableEvents(List
<String
> eventNames
) throws ExecutionException
{
256 enableEvents(eventNames
, new NullProgressMonitor());
260 * Enables a list of events with no additional parameters.
261 * @param eventNames - a list of event names to enabled.
262 * @param monitor - a progress monitor
263 * @throws ExecutionException
265 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
266 getControlService().enableEvents(getSessionName(), getName(), eventNames
, isKernel(), monitor
);
270 * Enables all syscalls (for kernel domain)
271 * @throws ExecutionException
273 public void enableSyscalls() throws ExecutionException
{
274 enableSyscalls(new NullProgressMonitor());
278 * Enables all syscalls (for kernel domain)
279 * @param monitor - a progress monitor
280 * @throws ExecutionException
282 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
283 getControlService().enableSyscalls(getSessionName(), getName(), monitor
);
287 * Enables a dynamic probe (for kernel domain)
288 * @param eventName - event name for probe
289 * @param probe - the actual probe
290 * @throws ExecutionException
292 public void enableProbe(String eventName
, String probe
) throws ExecutionException
{
293 enableProbe(eventName
, probe
, new NullProgressMonitor());
297 * Enables a dynamic probe (for kernel domain)
298 * @param eventName - event name for probe
299 * @param probe - the actual probe
300 * @param monitor - a progress monitor
301 * @throws ExecutionException
303 public void enableProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
304 getControlService().enableProbe(getSessionName(), getName(), eventName
, probe
, monitor
);
308 * Enables a dynamic function entry/return probe (for kernel domain)
309 * @param eventName - event name for probe
310 * @param probe - the actual probe
311 * @throws ExecutionException
313 public void enableFunctionProbe(String eventName
, String probe
) throws ExecutionException
{
314 enableFunctionProbe(eventName
, probe
, new NullProgressMonitor());
318 * Enables a dynamic function entry/return probe (for kernel domain)
319 * @param eventName - event name for probe
320 * @param probe - the actual probe
321 * @param monitor - a progress monitor
322 * @throws ExecutionException
324 public void enableFunctionProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
325 getControlService().enableFunctionProbe(getSessionName(), getName(), eventName
, probe
, monitor
);
329 * Enables events using log level.
330 * @param eventName - a event name
331 * @param logLevelType - a log level type
332 * @param level - a log level
333 * @throws ExecutionException
335 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
) throws ExecutionException
{
336 enableLogLevel(eventName
, logLevelType
, level
, new NullProgressMonitor());
340 * Enables events using log level.
341 * @param eventName - a event name
342 * @param logLevelType - a log level type
343 * @param level - a log level
344 * @param monitor - a progress monitor
345 * @throws ExecutionException
347 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
348 getControlService().enableLogLevel(getSessionName(), getName(), eventName
, logLevelType
, level
, monitor
);
352 * Enables a list of events with no additional parameters.
353 * @param eventNames - a list of event names to enabled.
354 * @throws ExecutionException
356 public void disableEvent(List
<String
> eventNames
) throws ExecutionException
{
357 disableEvent(eventNames
, new NullProgressMonitor());
361 * Enables a list of events with no additional parameters.
362 * @param eventNames - a list of event names to enabled.
363 * @param monitor - a progress monitor
364 * @throws ExecutionException
366 public void disableEvent(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
367 getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames
, isKernel(), monitor
);