gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / model / impl / TraceChannelComponent.java
CommitLineData
eb1bab5b 1/**********************************************************************
60ae41e1 2 * Copyright (c) 2012, 2014 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 **********************************************************************/
8e8c0226 13package org.eclipse.linuxtools.internal.lttng2.control.ui.views.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;
8e8c0226
AM
20import org.eclipse.linuxtools.internal.lttng2.control.core.model.IChannelInfo;
21import org.eclipse.linuxtools.internal.lttng2.control.core.model.IEventInfo;
22import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType;
0ad9fc89 23import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceChannelOutputType;
8e8c0226
AM
24import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement;
25import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceLogLevel;
26import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.ChannelInfo;
27import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.ProbeEventInfo;
28import org.eclipse.linuxtools.internal.lttng2.control.ui.Activator;
29import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages;
30import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent;
31import org.eclipse.linuxtools.internal.lttng2.control.ui.views.property.TraceChannelPropertySource;
eb1bab5b 32import org.eclipse.swt.graphics.Image;
06b9339e 33import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
34
35
36/**
eb1bab5b
BH
37 * <p>
38 * Implementation of the trace channel component.
39 * </p>
cfdb727a 40 *
dbd4432d 41 * @author Bernd Hufmann
eb1bab5b
BH
42 */
43public class TraceChannelComponent extends TraceControlComponent {
11252342 44
eb1bab5b
BH
45 // ------------------------------------------------------------------------
46 // Constants
47 // ------------------------------------------------------------------------
11252342 48
eb1bab5b
BH
49 /**
50 * Path to icon file for this component (state enabled).
51 */
52 public static final String TRACE_CHANNEL_ICON_FILE_ENABLED = "icons/obj16/channel.gif"; //$NON-NLS-1$
53 /**
54 * Path to icon file for this component (state disabled).
55 */
56 public static final String TRACE_CHANNEL_ICON_FILE_DISABLED = "icons/obj16/channel_disabled.gif"; //$NON-NLS-1$
cfdb727a 57
eb1bab5b
BH
58 // ------------------------------------------------------------------------
59 // Attributes
60 // ------------------------------------------------------------------------
11252342 61
eb1bab5b
BH
62 /**
63 * The channel information.
64 */
65 private IChannelInfo fChannelInfo = null;
66 /**
67 * The image to be displayed in disabled state.
68 */
69 private Image fDisabledImage = null;
cfdb727a 70
eb1bab5b
BH
71 // ------------------------------------------------------------------------
72 // Constructors
73 // ------------------------------------------------------------------------
11252342 74
eb1bab5b 75 /**
cfdb727a 76 * Constructor
eb1bab5b
BH
77 * @param name - the name of the component.
78 * @param parent - the parent of this component.
79 */
80 public TraceChannelComponent(String name, ITraceControlComponent parent) {
81 super(name, parent);
82 setImage(TRACE_CHANNEL_ICON_FILE_ENABLED);
83 setToolTip(Messages.TraceControl_ChannelDisplayName);
84 fChannelInfo = new ChannelInfo(name);
31a6a4e4 85 fDisabledImage = Activator.getDefault().loadIcon(TRACE_CHANNEL_ICON_FILE_DISABLED);
eb1bab5b 86 }
cfdb727a 87
eb1bab5b
BH
88 // ------------------------------------------------------------------------
89 // Accessors
90 // ------------------------------------------------------------------------
11252342 91
eb1bab5b
BH
92 @Override
93 public Image getImage() {
94 if (fChannelInfo.getState() == TraceEnablement.DISABLED) {
95 return fDisabledImage;
96 }
97 return super.getImage();
98 }
99
100 /**
101 * Sets the channel information.
cfdb727a 102 *
eb1bab5b 103 * @param channelInfo
cfdb727a 104 * The channel info to assign to this component
eb1bab5b
BH
105 */
106 public void setChannelInfo(IChannelInfo channelInfo) {
107 fChannelInfo = channelInfo;
108 IEventInfo[] events = fChannelInfo.getEvents();
e0838ca1 109 List<ITraceControlComponent> eventComponents = new ArrayList<>();
eb1bab5b 110 for (int i = 0; i < events.length; i++) {
d132bcc7
BH
111 TraceEventComponent event = null;
112 if (events[i].getClass() == ProbeEventInfo.class) {
113 event = new TraceProbeEventComponent(events[i].getName(), this);
114 } else {
115 event = new TraceEventComponent(events[i].getName(), this);
116 }
117
b957fb8c 118 eventComponents.add(event);
eb1bab5b 119 event.setEventInfo(events[i]);
b957fb8c
BH
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 */
0ad9fc89 194 public TraceChannelOutputType getOutputType() {
eb1bab5b
BH
195 return fChannelInfo.getOutputType();
196 }
0ad9fc89
JRJ
197 /**
198 * Sets the output type to the given value.
199 * @param type - type to set.
200 */
201 public void setOutputType(TraceChannelOutputType type) {
202 fChannelInfo.setOutputType(type);
203 }
eb1bab5b
BH
204 /**
205 * Sets the output type to the given value.
206 * @param type - type to set.
207 */
208 public void setOutputType(String type) {
209 fChannelInfo.setOutputType(type);
210 }
0ad9fc89 211
eb1bab5b
BH
212 /**
213 * @return the channel state (enabled or disabled).
214 */
215 public TraceEnablement getState() {
216 return fChannelInfo.getState();
217 }
218 /**
219 * Sets the channel state (enablement) to the given value.
220 * @param state - state to set.
221 */
222 public void setState(TraceEnablement state) {
223 fChannelInfo.setState(state);
224 }
225 /**
226 * Sets the channel state (enablement) to the value specified by the given name.
227 * @param stateName - state to set.
228 */
229 public void setState(String stateName) {
230 fChannelInfo.setState(stateName);
231 }
11252342 232
06b9339e
BH
233 @Override
234 public Object getAdapter(Class adapter) {
235 if (adapter == IPropertySource.class) {
236 return new TraceChannelPropertySource(this);
237 }
238 return null;
cfdb727a 239 }
bbb3538a
BH
240
241 /**
242 * @return session name from parent
243 */
244 public String getSessionName() {
cfdb727a 245 return ((TraceDomainComponent)getParent()).getSessionName();
bbb3538a
BH
246 }
247
6503ae0f
BH
248 /**
249 * @return session from parent
250 */
251 public TraceSessionComponent getSession() {
cfdb727a 252 return ((TraceDomainComponent)getParent()).getSession();
6503ae0f
BH
253 }
254
bbb3538a
BH
255 /**
256 * @return if domain is kernel or UST
257 */
258 public boolean isKernel() {
259 return ((TraceDomainComponent)getParent()).isKernel();
260 }
cfdb727a 261
498704b3
BH
262 /**
263 * @return the parent target node
264 */
265 public TargetNodeComponent getTargetNode() {
266 return ((TraceDomainComponent)getParent()).getTargetNode();
267 }
cfdb727a 268
eb1bab5b
BH
269 // ------------------------------------------------------------------------
270 // Operations
271 // ------------------------------------------------------------------------
6503ae0f
BH
272
273 /**
274 * Enables a list of events with no additional parameters.
cfdb727a
AM
275 *
276 * @param eventNames
277 * - a list of event names to enabled.
278 * @param monitor
279 * - a progress monitor
6503ae0f 280 * @throws ExecutionException
cfdb727a 281 * If the command fails
6503ae0f 282 */
498704b3 283 public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
d4514365
BH
284 enableEvents(eventNames, null, monitor);
285 }
286
287 /**
288 * Enables a list of events with no additional parameters.
289 *
290 * @param eventNames
291 * - a list of event names to enabled.
292 * @param filterExpression
293 * - a filter expression
294 * @param monitor
295 * - a progress monitor
296 * @throws ExecutionException
297 * If the command fails
298 */
299 public void enableEvents(List<String> eventNames, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
300 getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), filterExpression, monitor);
498704b3 301 }
cfdb727a 302
498704b3
BH
303 /**
304 * Enables all syscalls (for kernel domain)
cfdb727a
AM
305 *
306 * @param monitor
307 * - a progress monitor
498704b3 308 * @throws ExecutionException
cfdb727a 309 * If the command fails
498704b3
BH
310 */
311 public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
312 getControlService().enableSyscalls(getSessionName(), getName(), monitor);
313 }
314
498704b3
BH
315 /**
316 * Enables a dynamic probe (for kernel domain)
cfdb727a
AM
317 *
318 * @param eventName
319 * - event name for probe
320 * @param isFunction
321 * - true for dynamic function entry/return probe else false
322 * @param probe
323 * - the actual probe
324 * @param monitor
325 * - a progress monitor
498704b3 326 * @throws ExecutionException
cfdb727a 327 * If the command fails
498704b3 328 */
cfdb727a
AM
329 public void enableProbe(String eventName, boolean isFunction, String probe,
330 IProgressMonitor monitor) throws ExecutionException {
d132bcc7 331 getControlService().enableProbe(getSessionName(), getName(), eventName, isFunction, probe, monitor);
498704b3
BH
332 }
333
ccc66d01
BH
334 /**
335 * Enables events using log level.
cfdb727a
AM
336 *
337 * @param eventName
338 * - a event name
339 * @param logLevelType
340 * - a log level type
341 * @param level
342 * - a log level
d4514365
BH
343 * @param filterExpression
344 * - a filter expression
cfdb727a
AM
345 * @param monitor
346 * - a progress monitor
ccc66d01 347 * @throws ExecutionException
cfdb727a 348 * If the command fails
ccc66d01 349 */
cfdb727a 350 public void enableLogLevel(String eventName, LogLevelType logLevelType,
d4514365 351 TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
cfdb727a 352 throws ExecutionException {
d4514365 353 getControlService().enableLogLevel(getSessionName(), getName(), eventName, logLevelType, level, filterExpression, monitor);
ccc66d01
BH
354 }
355
6503ae0f
BH
356 /**
357 * Enables a list of events with no additional parameters.
cfdb727a
AM
358 *
359 * @param eventNames
360 * - a list of event names to enabled.
361 * @param monitor
362 * - a progress monitor
6503ae0f 363 * @throws ExecutionException
cfdb727a 364 * If the command fails
6503ae0f 365 */
cfdb727a
AM
366 public void disableEvent(List<String> eventNames, IProgressMonitor monitor)
367 throws ExecutionException {
368 getControlService().disableEvent(getParent().getParent().getName(),
369 getName(), eventNames, isKernel(), monitor);
6503ae0f 370 }
cfdb727a 371
b793fbe1
BH
372 /**
373 * Add contexts to given channels and or events
cfdb727a
AM
374 *
375 * @param contexts
376 * - a list of contexts to add
377 * @param monitor
378 * - a progress monitor
b793fbe1 379 * @throws ExecutionException
cfdb727a 380 * If the command fails
b793fbe1 381 */
cfdb727a
AM
382 public void addContexts(List<String> contexts, IProgressMonitor monitor)
383 throws ExecutionException {
384 getControlService().addContexts(getSessionName(), getName(), null,
385 isKernel(), contexts, monitor);
b793fbe1 386 }
eb1bab5b 387}
This page took 0.068963 seconds and 5 git commands to generate.