tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceChannelComponent.java
CommitLineData
eb1bab5b 1/**********************************************************************
ba3a9bd2 2 * Copyright (c) 2012, 2013 Ericsson
cfdb727a 3 *
eb1bab5b
BH
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
cfdb727a
AM
8 *
9 * Contributors:
eb1bab5b 10 * Bernd Hufmann - Initial API and implementation
ba3a9bd2 11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
eb1bab5b 12 **********************************************************************/
115b4a01 13package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
eb1bab5b 14
b957fb8c 15import java.util.ArrayList;
6503ae0f
BH
16import java.util.List;
17
18import org.eclipse.core.commands.ExecutionException;
19import org.eclipse.core.runtime.IProgressMonitor;
9315aeee
BH
20import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
21import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
22import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
23import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEnablement;
24import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
25import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
26import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo;
115b4a01 27import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
9315aeee 28import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
115b4a01 29import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
115b4a01 30import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceChannelPropertySource;
eb1bab5b 31import org.eclipse.swt.graphics.Image;
06b9339e 32import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
33
34
35/**
eb1bab5b
BH
36 * <p>
37 * Implementation of the trace channel component.
38 * </p>
cfdb727a 39 *
dbd4432d 40 * @author Bernd Hufmann
eb1bab5b
BH
41 */
42public class TraceChannelComponent extends TraceControlComponent {
11252342 43
eb1bab5b
BH
44 // ------------------------------------------------------------------------
45 // Constants
46 // ------------------------------------------------------------------------
11252342 47
eb1bab5b
BH
48 /**
49 * Path to icon file for this component (state enabled).
50 */
51 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$
52 /**
53 * Path to icon file for this component (state disabled).
54 */
55 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
cfdb727a 56
eb1bab5b
BH
57 // ------------------------------------------------------------------------
58 // Attributes
59 // ------------------------------------------------------------------------
11252342 60
eb1bab5b
BH
61 /**
62 * The channel information.
63 */
64 private IChannelInfo fChannelInfo = null;
65 /**
66 * The image to be displayed in disabled state.
67 */
68 private Image fDisabledImage = null;
cfdb727a 69
eb1bab5b
BH
70 // ------------------------------------------------------------------------
71 // Constructors
72 // ------------------------------------------------------------------------
11252342 73
eb1bab5b 74 /**
cfdb727a 75 * Constructor
eb1bab5b
BH
76 * @param name - the name of the component.
77 * @param parent - the parent of this component.
78 */
79 public TraceChannelComponent(String name, ITraceControlComponent parent) {
80 super(name, parent);
81 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED);
82 setToolTip(Messages.TraceControl_ChannelDisplayName);
83 fChannelInfo = new ChannelInfo(name);
31a6a4e4 84 fDisabledImage = Activator.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED);
eb1bab5b 85 }
cfdb727a 86
eb1bab5b
BH
87 // ------------------------------------------------------------------------
88 // Accessors
89 // ------------------------------------------------------------------------
11252342 90
eb1bab5b
BH
91 @Override
92 public Image getImage() {
93 if (fChannelInfo.getState() == TraceEnablement.DISABLED) {
94 return fDisabledImage;
95 }
96 return super.getImage();
97 }
98
99 /**
100 * Sets the channel information.
cfdb727a 101 *
eb1bab5b 102 * @param channelInfo
cfdb727a 103 * The channel info to assign to this component
eb1bab5b
BH
104 */
105 public void setChannelInfo(IChannelInfo channelInfo) {
106 fChannelInfo = channelInfo;
107 IEventInfo[] events = fChannelInfo.getEvents();
b957fb8c 108 List<ITraceControlComponent> eventComponents = new ArrayList<ITraceControlComponent>();
eb1bab5b 109 for (int i = 0; i < events.length; i++) {
d132bcc7
BH
110 TraceEventComponent event = null;
111 if (events[i].getClass() == ProbeEventInfo.class) {
112 event = new TraceProbeEventComponent(events[i].getName(), this);
113 } else {
114 event = new TraceEventComponent(events[i].getName(), this);
115 }
116
b957fb8c 117 eventComponents.add(event);
eb1bab5b 118 event.setEventInfo(events[i]);
b957fb8c
BH
119// addChild(event);
120 }
121 if (!eventComponents.isEmpty()) {
122 setChildren(eventComponents);
eb1bab5b
BH
123 }
124 }
125
126 /**
127 * @return the overwrite mode value.
128 */
129 public boolean isOverwriteMode() {
130 return fChannelInfo.isOverwriteMode();
131 }
132 /**
133 * Sets the overwrite mode value to the given mode.
134 * @param mode - mode to set.
135 */
136 public void setOverwriteMode(boolean mode){
137 fChannelInfo.setOverwriteMode(mode);
138 }
139 /**
140 * @return the sub-buffer size.
141 */
142 public long getSubBufferSize() {
143 return fChannelInfo.getSubBufferSize();
144 }
145 /**
146 * Sets the sub-buffer size to the given value.
147 * @param bufferSize - size to set to set.
148 */
149 public void setSubBufferSize(long bufferSize) {
150 fChannelInfo.setSubBufferSize(bufferSize);
151 }
152 /**
153 * @return the number of sub-buffers.
154 */
155 public int getNumberOfSubBuffers() {
156 return fChannelInfo.getNumberOfSubBuffers();
157 }
158 /**
159 * Sets the number of sub-buffers to the given value.
160 * @param numberOfSubBuffers - value to set.
161 */
162 public void setNumberOfSubBuffers(int numberOfSubBuffers) {
163 fChannelInfo.setNumberOfSubBuffers(numberOfSubBuffers);
164 }
165 /**
166 * @return the switch timer interval.
167 */
168 public long getSwitchTimer() {
169 return fChannelInfo.getSwitchTimer();
170 }
171 /**
172 * Sets the switch timer interval to the given value.
173 * @param timer - timer value to set.
174 */
175 public void setSwitchTimer(long timer) {
176 fChannelInfo.setSwitchTimer(timer);
177 }
178 /**
179 * @return the read timer interval.
180 */
181 public long getReadTimer() {
cfdb727a 182 return fChannelInfo.getReadTimer();
eb1bab5b
BH
183 }
184 /**
185 * Sets the read timer interval to the given value.
186 * @param timer - timer value to set..
187 */
188 public void setReadTimer(long timer) {
189 fChannelInfo.setReadTimer(timer);
190 }
191 /**
192 * @return the output type.
193 */
194 public String getOutputType() {
195 return fChannelInfo.getOutputType();
196 }
197 /**
198 * Sets the output type to the given value.
199 * @param type - type to set.
200 */
201 public void setOutputType(String type) {
202 fChannelInfo.setOutputType(type);
203 }
204 /**
205 * @return the channel state (enabled or disabled).
206 */
207 public TraceEnablement getState() {
208 return fChannelInfo.getState();
209 }
210 /**
211 * Sets the channel state (enablement) to the given value.
212 * @param state - state to set.
213 */
214 public void setState(TraceEnablement state) {
215 fChannelInfo.setState(state);
216 }
217 /**
218 * Sets the channel state (enablement) to the value specified by the given name.
219 * @param stateName - state to set.
220 */
221 public void setState(String stateName) {
222 fChannelInfo.setState(stateName);
223 }
11252342 224
06b9339e
BH
225 @Override
226 public Object getAdapter(Class adapter) {
227 if (adapter == IPropertySource.class) {
228 return new TraceChannelPropertySource(this);
229 }
230 return null;
cfdb727a 231 }
bbb3538a
BH
232
233 /**
234 * @return session name from parent
235 */
236 public String getSessionName() {
cfdb727a 237 return ((TraceDomainComponent)getParent()).getSessionName();
bbb3538a
BH
238 }
239
6503ae0f
BH
240 /**
241 * @return session from parent
242 */
243 public TraceSessionComponent getSession() {
cfdb727a 244 return ((TraceDomainComponent)getParent()).getSession();
6503ae0f
BH
245 }
246
bbb3538a
BH
247 /**
248 * @return if domain is kernel or UST
249 */
250 public boolean isKernel() {
251 return ((TraceDomainComponent)getParent()).isKernel();
252 }
cfdb727a 253
498704b3
BH
254 /**
255 * @return the parent target node
256 */
257 public TargetNodeComponent getTargetNode() {
258 return ((TraceDomainComponent)getParent()).getTargetNode();
259 }
cfdb727a 260
eb1bab5b
BH
261 // ------------------------------------------------------------------------
262 // Operations
263 // ------------------------------------------------------------------------
6503ae0f
BH
264
265 /**
266 * Enables a list of events with no additional parameters.
cfdb727a
AM
267 *
268 * @param eventNames
269 * - a list of event names to enabled.
270 * @param monitor
271 * - a progress monitor
6503ae0f 272 * @throws ExecutionException
cfdb727a 273 * If the command fails
6503ae0f 274 */
498704b3 275 public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
d4514365
BH
276 enableEvents(eventNames, null, monitor);
277 }
278
279 /**
280 * Enables a list of events with no additional parameters.
281 *
282 * @param eventNames
283 * - a list of event names to enabled.
284 * @param filterExpression
285 * - a filter expression
286 * @param monitor
287 * - a progress monitor
288 * @throws ExecutionException
289 * If the command fails
290 */
291 public void enableEvents(List<String> eventNames, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
292 getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), filterExpression, monitor);
498704b3 293 }
cfdb727a 294
498704b3
BH
295 /**
296 * Enables all syscalls (for kernel domain)
cfdb727a
AM
297 *
298 * @param monitor
299 * - a progress monitor
498704b3 300 * @throws ExecutionException
cfdb727a 301 * If the command fails
498704b3
BH
302 */
303 public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
304 getControlService().enableSyscalls(getSessionName(), getName(), monitor);
305 }
306
498704b3
BH
307 /**
308 * Enables a dynamic probe (for kernel domain)
cfdb727a
AM
309 *
310 * @param eventName
311 * - event name for probe
312 * @param isFunction
313 * - true for dynamic function entry/return probe else false
314 * @param probe
315 * - the actual probe
316 * @param monitor
317 * - a progress monitor
498704b3 318 * @throws ExecutionException
cfdb727a 319 * If the command fails
498704b3 320 */
cfdb727a
AM
321 public void enableProbe(String eventName, boolean isFunction, String probe,
322 IProgressMonitor monitor) throws ExecutionException {
d132bcc7 323 getControlService().enableProbe(getSessionName(), getName(), eventName, isFunction, probe, monitor);
498704b3
BH
324 }
325
ccc66d01
BH
326 /**
327 * Enables events using log level.
cfdb727a
AM
328 *
329 * @param eventName
330 * - a event name
331 * @param logLevelType
332 * - a log level type
333 * @param level
334 * - a log level
d4514365
BH
335 * @param filterExpression
336 * - a filter expression
cfdb727a
AM
337 * @param monitor
338 * - a progress monitor
ccc66d01 339 * @throws ExecutionException
cfdb727a 340 * If the command fails
ccc66d01 341 */
cfdb727a 342 public void enableLogLevel(String eventName, LogLevelType logLevelType,
d4514365 343 TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
cfdb727a 344 throws ExecutionException {
d4514365 345 getControlService().enableLogLevel(getSessionName(), getName(), eventName, logLevelType, level, filterExpression, monitor);
ccc66d01
BH
346 }
347
6503ae0f
BH
348 /**
349 * Enables a list of events with no additional parameters.
cfdb727a
AM
350 *
351 * @param eventNames
352 * - a list of event names to enabled.
353 * @param monitor
354 * - a progress monitor
6503ae0f 355 * @throws ExecutionException
cfdb727a 356 * If the command fails
6503ae0f 357 */
cfdb727a
AM
358 public void disableEvent(List<String> eventNames, IProgressMonitor monitor)
359 throws ExecutionException {
360 getControlService().disableEvent(getParent().getParent().getName(),
361 getName(), eventNames, isKernel(), monitor);
6503ae0f 362 }
cfdb727a 363
b793fbe1
BH
364 /**
365 * Add contexts to given channels and or events
cfdb727a
AM
366 *
367 * @param contexts
368 * - a list of contexts to add
369 * @param monitor
370 * - a progress monitor
b793fbe1 371 * @throws ExecutionException
cfdb727a 372 * If the command fails
b793fbe1 373 */
cfdb727a
AM
374 public void addContexts(List<String> contexts, IProgressMonitor monitor)
375 throws ExecutionException {
376 getControlService().addContexts(getSessionName(), getName(), null,
377 isKernel(), contexts, monitor);
b793fbe1 378 }
eb1bab5b 379}
This page took 0.052954 seconds and 5 git commands to generate.