Add further support for enabling kernel events
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / model / impl / TraceChannelComponent.java
CommitLineData
eb1bab5b
BH
1/**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
13
6503ae0f
BH
14import java.util.List;
15
16import org.eclipse.core.commands.ExecutionException;
17import org.eclipse.core.runtime.IProgressMonitor;
18import org.eclipse.core.runtime.NullProgressMonitor;
eb1bab5b
BH
19import org.eclipse.linuxtools.lttng.ui.LTTngUiPlugin;
20import org.eclipse.linuxtools.lttng.ui.views.control.Messages;
21import org.eclipse.linuxtools.lttng.ui.views.control.model.IChannelInfo;
22import org.eclipse.linuxtools.lttng.ui.views.control.model.IEventInfo;
23import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
24import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceEnablement;
06b9339e 25import org.eclipse.linuxtools.lttng.ui.views.control.property.TraceChannelPropertySource;
eb1bab5b 26import org.eclipse.swt.graphics.Image;
06b9339e 27import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
28
29
30/**
31 * <b><u>TraceChannelComponent</u></b>
32 * <p>
33 * Implementation of the trace channel component.
34 * </p>
35 */
36public class TraceChannelComponent extends TraceControlComponent {
37 // ------------------------------------------------------------------------
38 // Constants
39 // ------------------------------------------------------------------------
40 /**
41 * Path to icon file for this component (state enabled).
42 */
43 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$
44 /**
45 * Path to icon file for this component (state disabled).
46 */
47 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
48
49 // ------------------------------------------------------------------------
50 // Attributes
51 // ------------------------------------------------------------------------
52 /**
53 * The channel information.
54 */
55 private IChannelInfo fChannelInfo = null;
56 /**
57 * The image to be displayed in disabled state.
58 */
59 private Image fDisabledImage = null;
60
61 // ------------------------------------------------------------------------
62 // Constructors
63 // ------------------------------------------------------------------------
64 /**
65 * Constructor
66 * @param name - the name of the component.
67 * @param parent - the parent of this component.
68 */
69 public TraceChannelComponent(String name, ITraceControlComponent parent) {
70 super(name, 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);
75 }
76
77 // ------------------------------------------------------------------------
78 // Accessors
79 // ------------------------------------------------------------------------
80 /*
81 * (non-Javadoc)
82 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
83 */
84 @Override
85 public Image getImage() {
86 if (fChannelInfo.getState() == TraceEnablement.DISABLED) {
87 return fDisabledImage;
88 }
89 return super.getImage();
90 }
91
92 /**
93 * Sets the channel information.
94 * @param channelInfo
95 */
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]);
102 addChild(event);
103 }
104 }
105
106 /**
107 * @return the overwrite mode value.
108 */
109 public boolean isOverwriteMode() {
110 return fChannelInfo.isOverwriteMode();
111 }
112 /**
113 * Sets the overwrite mode value to the given mode.
114 * @param mode - mode to set.
115 */
116 public void setOverwriteMode(boolean mode){
117 fChannelInfo.setOverwriteMode(mode);
118 }
119 /**
120 * @return the sub-buffer size.
121 */
122 public long getSubBufferSize() {
123 return fChannelInfo.getSubBufferSize();
124 }
125 /**
126 * Sets the sub-buffer size to the given value.
127 * @param bufferSize - size to set to set.
128 */
129 public void setSubBufferSize(long bufferSize) {
130 fChannelInfo.setSubBufferSize(bufferSize);
131 }
132 /**
133 * @return the number of sub-buffers.
134 */
135 public int getNumberOfSubBuffers() {
136 return fChannelInfo.getNumberOfSubBuffers();
137 }
138 /**
139 * Sets the number of sub-buffers to the given value.
140 * @param numberOfSubBuffers - value to set.
141 */
142 public void setNumberOfSubBuffers(int numberOfSubBuffers) {
143 fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers);
144 }
145 /**
146 * @return the switch timer interval.
147 */
148 public long getSwitchTimer() {
149 return fChannelInfo.getSwitchTimer();
150 }
151 /**
152 * Sets the switch timer interval to the given value.
153 * @param timer - timer value to set.
154 */
155 public void setSwitchTimer(long timer) {
156 fChannelInfo.setSwitchTimer(timer);
157 }
158 /**
159 * @return the read timer interval.
160 */
161 public long getReadTimer() {
162 return fChannelInfo.getReadTimer();
163 }
164 /**
165 * Sets the read timer interval to the given value.
166 * @param timer - timer value to set..
167 */
168 public void setReadTimer(long timer) {
169 fChannelInfo.setReadTimer(timer);
170 }
171 /**
172 * @return the output type.
173 */
174 public String getOutputType() {
175 return fChannelInfo.getOutputType();
176 }
177 /**
178 * Sets the output type to the given value.
179 * @param type - type to set.
180 */
181 public void setOutputType(String type) {
182 fChannelInfo.setOutputType(type);
183 }
184 /**
185 * @return the channel state (enabled or disabled).
186 */
187 public TraceEnablement getState() {
188 return fChannelInfo.getState();
189 }
190 /**
191 * Sets the channel state (enablement) to the given value.
192 * @param state - state to set.
193 */
194 public void setState(TraceEnablement state) {
195 fChannelInfo.setState(state);
196 }
197 /**
198 * Sets the channel state (enablement) to the value specified by the given name.
199 * @param stateName - state to set.
200 */
201 public void setState(String stateName) {
202 fChannelInfo.setState(stateName);
203 }
06b9339e
BH
204 /*
205 * (non-Javadoc)
206 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
207 */
208 @SuppressWarnings("rawtypes")
209 @Override
210 public Object getAdapter(Class adapter) {
211 if (adapter == IPropertySource.class) {
212 return new TraceChannelPropertySource(this);
213 }
214 return null;
215 }
bbb3538a
BH
216
217 /**
218 * @return session name from parent
219 */
220 public String getSessionName() {
221 return ((TraceDomainComponent)getParent()).getSessionName();
222 }
223
6503ae0f
BH
224 /**
225 * @return session from parent
226 */
227 public TraceSessionComponent getSession() {
228 return ((TraceDomainComponent)getParent()).getSession();
229 }
230
bbb3538a
BH
231 /**
232 * @return if domain is kernel or UST
233 */
234 public boolean isKernel() {
235 return ((TraceDomainComponent)getParent()).isKernel();
236 }
eb1bab5b 237
498704b3
BH
238 /**
239 * @return the parent target node
240 */
241 public TargetNodeComponent getTargetNode() {
242 return ((TraceDomainComponent)getParent()).getTargetNode();
243 }
244
eb1bab5b
BH
245 // ------------------------------------------------------------------------
246 // Operations
247 // ------------------------------------------------------------------------
6503ae0f
BH
248 /**
249 * Enables a list of events with no additional parameters.
250 * @param eventNames - a list of event names to enabled.
251 * @throws ExecutionException
252 */
498704b3
BH
253 public void enableEvents(List<String> eventNames) throws ExecutionException {
254 enableEvents(eventNames, new NullProgressMonitor());
6503ae0f
BH
255 }
256
257 /**
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
262 */
498704b3
BH
263 public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
264 getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), monitor);
265 }
266
267 /**
268 * Enables all syscalls (for kernel domain)
269 * @throws ExecutionException
270 */
271 public void enableSyscalls() throws ExecutionException {
272 enableSyscalls(new NullProgressMonitor());
273 }
274
275 /**
276 * Enables all syscalls (for kernel domain)
277 * @param monitor - a progress monitor
278 * @throws ExecutionException
279 */
280 public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
281 getControlService().enableSyscalls(getSessionName(), getName(), monitor);
282 }
283
284 /**
285 * Enables a dynamic probe (for kernel domain)
286 * @param eventName - event name for probe
287 * @param probe - the actual probe
288 * @throws ExecutionException
289 */
290 public void enableProbe(String eventName, String probe) throws ExecutionException {
291 enableProbe(eventName, probe, new NullProgressMonitor());
292 }
293
294 /**
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
300 */
301 public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
302 getControlService().enableProbe(getSessionName(), getName(), eventName, probe, monitor);
303 }
304
305 /**
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
310 */
311 public void enableFunctionProbe(String eventName, String probe) throws ExecutionException {
312 enableFunctionProbe(eventName, probe, new NullProgressMonitor());
313 }
314
315 /**
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
321 */
322 public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
323 getControlService().enableFunctionProbe(getSessionName(), getName(), eventName, probe, monitor);
6503ae0f
BH
324 }
325
326 /**
327 * Enables a list of events with no additional parameters.
328 * @param eventNames - a list of event names to enabled.
329 * @throws ExecutionException
330 */
331 public void disableEvent(List<String> eventNames) throws ExecutionException {
332 disableEvent(eventNames, new NullProgressMonitor());
333 }
334
335 /**
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
340 */
341 public void disableEvent(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
342 getControlService().disableEvent(getParent().getParent().getName(), getName(), eventNames, isKernel(), monitor);
343 }
eb1bab5b 344}
This page took 0.037881 seconds and 5 git commands to generate.