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
.TraceEnablement
;
25 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceChannelPropertySource
;
26 import org
.eclipse
.swt
.graphics
.Image
;
27 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
31 * <b><u>TraceChannelComponent</u></b>
33 * Implementation of the trace channel component.
36 public class TraceChannelComponent
extends TraceControlComponent
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 * Path to icon file for this component (state enabled).
43 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED
= "icons/obj16/channel.gif"; //$NON-NLS-1$
45 * Path to icon file for this component (state disabled).
47 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED
= "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
53 * The channel information.
55 private IChannelInfo fChannelInfo
= null;
57 * The image to be displayed in disabled state.
59 private Image fDisabledImage
= null;
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
66 * @param name - the name of the component.
67 * @param parent - the parent of this component.
69 public TraceChannelComponent(String name
, ITraceControlComponent parent
) {
71 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED
);
72 setToolTip(Messages
.TraceControl_ChannelDisplayName
);
73 fChannelInfo
= new ChannelInfo(name
);
74 fDisabledImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED
);
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
82 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
85 public Image
getImage() {
86 if (fChannelInfo
.getState() == TraceEnablement
.DISABLED
) {
87 return fDisabledImage
;
89 return super.getImage();
93 * Sets the channel information.
96 public void setChannelInfo(IChannelInfo channelInfo
) {
97 fChannelInfo
= channelInfo
;
98 IEventInfo
[] events
= fChannelInfo
.getEvents();
99 for (int i
= 0; i
< events
.length
; i
++) {
100 TraceEventComponent event
= new TraceEventComponent(events
[i
].getName(), this);
101 event
.setEventInfo(events
[i
]);
107 * @return the overwrite mode value.
109 public boolean isOverwriteMode() {
110 return fChannelInfo
.isOverwriteMode();
113 * Sets the overwrite mode value to the given mode.
114 * @param mode - mode to set.
116 public void setOverwriteMode(boolean mode
){
117 fChannelInfo
.setOverwriteMode(mode
);
120 * @return the sub-buffer size.
122 public long getSubBufferSize() {
123 return fChannelInfo
.getSubBufferSize();
126 * Sets the sub-buffer size to the given value.
127 * @param bufferSize - size to set to set.
129 public void setSubBufferSize(long bufferSize
) {
130 fChannelInfo
.setSubBufferSize(bufferSize
);
133 * @return the number of sub-buffers.
135 public int getNumberOfSubBuffers() {
136 return fChannelInfo
.getNumberOfSubBuffers();
139 * Sets the number of sub-buffers to the given value.
140 * @param numberOfSubBuffers - value to set.
142 public void setNumberOfSubBuffers(int numberOfSubBuffers
) {
143 fChannelInfo
.setNumberOfSubBuffers(numberOfSubBuffers
);
146 * @return the switch timer interval.
148 public long getSwitchTimer() {
149 return fChannelInfo
.getSwitchTimer();
152 * Sets the switch timer interval to the given value.
153 * @param timer - timer value to set.
155 public void setSwitchTimer(long timer
) {
156 fChannelInfo
.setSwitchTimer(timer
);
159 * @return the read timer interval.
161 public long getReadTimer() {
162 return fChannelInfo
.getReadTimer();
165 * Sets the read timer interval to the given value.
166 * @param timer - timer value to set..
168 public void setReadTimer(long timer
) {
169 fChannelInfo
.setReadTimer(timer
);
172 * @return the output type.
174 public String
getOutputType() {
175 return fChannelInfo
.getOutputType();
178 * Sets the output type to the given value.
179 * @param type - type to set.
181 public void setOutputType(String type
) {
182 fChannelInfo
.setOutputType(type
);
185 * @return the channel state (enabled or disabled).
187 public TraceEnablement
getState() {
188 return fChannelInfo
.getState();
191 * Sets the channel state (enablement) to the given value.
192 * @param state - state to set.
194 public void setState(TraceEnablement state
) {
195 fChannelInfo
.setState(state
);
198 * Sets the channel state (enablement) to the value specified by the given name.
199 * @param stateName - state to set.
201 public void setState(String stateName
) {
202 fChannelInfo
.setState(stateName
);
206 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
208 @SuppressWarnings("rawtypes")
210 public Object
getAdapter(Class adapter
) {
211 if (adapter
== IPropertySource
.class) {
212 return new TraceChannelPropertySource(this);
218 * @return session name from parent
220 public String
getSessionName() {
221 return ((TraceDomainComponent
)getParent()).getSessionName();
225 * @return session from parent
227 public TraceSessionComponent
getSession() {
228 return ((TraceDomainComponent
)getParent()).getSession();
232 * @return if domain is kernel or UST
234 public boolean isKernel() {
235 return ((TraceDomainComponent
)getParent()).isKernel();
239 * @return the parent target node
241 public TargetNodeComponent
getTargetNode() {
242 return ((TraceDomainComponent
)getParent()).getTargetNode();
245 // ------------------------------------------------------------------------
247 // ------------------------------------------------------------------------
249 * Enables a list of events with no additional parameters.
250 * @param eventNames - a list of event names to enabled.
251 * @throws ExecutionException
253 public void enableEvents(List
<String
> eventNames
) throws ExecutionException
{
254 enableEvents(eventNames
, new NullProgressMonitor());
258 * Enables a list of events with no additional parameters.
259 * @param eventNames - a list of event names to enabled.
260 * @param monitor - a progress monitor
261 * @throws ExecutionException
263 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
264 getControlService().enableEvents(getSessionName(), getName(), eventNames
, isKernel(), monitor
);
268 * Enables all syscalls (for kernel domain)
269 * @throws ExecutionException
271 public void enableSyscalls() throws ExecutionException
{
272 enableSyscalls(new NullProgressMonitor());
276 * Enables all syscalls (for kernel domain)
277 * @param monitor - a progress monitor
278 * @throws ExecutionException
280 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
281 getControlService().enableSyscalls(getSessionName(), getName(), monitor
);
285 * Enables a dynamic probe (for kernel domain)
286 * @param eventName - event name for probe
287 * @param probe - the actual probe
288 * @throws ExecutionException
290 public void enableProbe(String eventName
, String probe
) throws ExecutionException
{
291 enableProbe(eventName
, probe
, new NullProgressMonitor());
295 * Enables a dynamic probe (for kernel domain)
296 * @param eventName - event name for probe
297 * @param probe - the actual probe
298 * @param monitor - a progress monitor
299 * @throws ExecutionException
301 public void enableProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
302 getControlService().enableProbe(getSessionName(), getName(), eventName
, probe
, monitor
);
306 * Enables a dynamic function entry/return probe (for kernel domain)
307 * @param eventName - event name for probe
308 * @param probe - the actual probe
309 * @throws ExecutionException
311 public void enableFunctionProbe(String eventName
, String probe
) throws ExecutionException
{
312 enableFunctionProbe(eventName
, probe
, new NullProgressMonitor());
316 * Enables a dynamic function entry/return probe (for kernel domain)
317 * @param eventName - event name for probe
318 * @param probe - the actual probe
319 * @param monitor - a progress monitor
320 * @throws ExecutionException
322 public void enableFunctionProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
323 getControlService().enableFunctionProbe(getSessionName(), getName(), eventName
, probe
, monitor
);
327 * Enables a list of events with no additional parameters.
328 * @param eventNames - a list of event names to enabled.
329 * @throws ExecutionException
331 public void disableEvent(List
<String
> eventNames
) throws ExecutionException
{
332 disableEvent(eventNames
, new NullProgressMonitor());
336 * Enables a list of events with no additional parameters.
337 * @param eventNames - a list of event names to enabled.
338 * @param monitor - a progress monitor
339 * @throws ExecutionException
341 public void disableEvent(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
342 getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames
, isKernel(), monitor
);