lttng: Fix Javadoc and formatting in lttng2.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceDomainComponent.java
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 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
13
14 import java.util.List;
15
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.internal.lttng2.core.control.model.IChannelInfo;
20 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
21 import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
22 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
23 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.DomainInfo;
24 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
25 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
26 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceDomainPropertySource;
27 import org.eclipse.ui.views.properties.IPropertySource;
28
29 /**
30 * <p>
31 * Implementation of the trace domain component.
32 * </p>
33 *
34 * @author Bernd Hufmann
35 */
36 public class TraceDomainComponent extends TraceControlComponent {
37 // ------------------------------------------------------------------------
38 // Constants
39 // ------------------------------------------------------------------------
40 /**
41 * Path to icon file for this component.
42 */
43 public static final String TRACE_DOMAIN_ICON_FILE = "icons/obj16/domain.gif"; //$NON-NLS-1$
44
45 // ------------------------------------------------------------------------
46 // Attributes
47 // ------------------------------------------------------------------------
48 /**
49 * The domain information.
50 */
51 private IDomainInfo fDomainInfo = null;
52
53 // ------------------------------------------------------------------------
54 // Constructors
55 // ------------------------------------------------------------------------
56 /**
57 * Constructor
58 * @param name - the name of the component.
59 * @param parent - the parent of this component.
60 */
61 public TraceDomainComponent(String name, ITraceControlComponent parent) {
62 super(name, parent);
63 setImage(TRACE_DOMAIN_ICON_FILE);
64 setToolTip(Messages.TraceControl_DomainDisplayName);
65 fDomainInfo = new DomainInfo(name);
66 }
67
68 // ------------------------------------------------------------------------
69 // Accessors
70 // ------------------------------------------------------------------------
71 /**
72 * Sets the domain information.
73 * @param domainInfo - the domain information to set.
74 */
75 public void setDomainInfo(IDomainInfo domainInfo) {
76 fDomainInfo = domainInfo;
77 IChannelInfo[] channels = fDomainInfo.getChannels();
78 for (int i = 0; i < channels.length; i++) {
79 TraceChannelComponent channel = new TraceChannelComponent(channels[i].getName(), this);
80 channel.setChannelInfo(channels[i]);
81 addChild(channel);
82 }
83 }
84
85 /*
86 * (non-Javadoc)
87 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
88 */
89 @SuppressWarnings("rawtypes")
90 @Override
91 public Object getAdapter(Class adapter) {
92 if (adapter == IPropertySource.class) {
93 return new TraceDomainPropertySource(this);
94 }
95 return null;
96 }
97
98 /**
99 * @return session name from parent
100 */
101 public String getSessionName() {
102 return ((TraceSessionComponent)getParent()).getName();
103 }
104
105 /**
106 * @return session from parent
107 */
108 public TraceSessionComponent getSession() {
109 return (TraceSessionComponent)getParent();
110 }
111
112 /**
113 * @return true if domain is kernel, false for UST
114 */
115 public boolean isKernel() {
116 return fDomainInfo.isKernel();
117 }
118
119 /**
120 * Sets whether domain is Kernel domain or UST
121 * @param isKernel true for kernel, false for UST
122 */
123 public void setIsKernel(boolean isKernel) {
124 fDomainInfo.setIsKernel(isKernel);
125 }
126
127 /**
128 * @return returns all available channels for this domain.
129 */
130 public TraceChannelComponent[] getChannels() {
131 List<ITraceControlComponent> channels = getChildren(TraceChannelComponent.class);
132 return channels.toArray(new TraceChannelComponent[channels.size()]);
133 }
134
135 /**
136 * @return the parent target node
137 */
138 public TargetNodeComponent getTargetNode() {
139 return ((TraceSessionComponent)getParent()).getTargetNode();
140 }
141
142 // ------------------------------------------------------------------------
143 // Operations
144 // ------------------------------------------------------------------------
145
146 /**
147 * Retrieves the session configuration from the node.
148 *
149 * @throws ExecutionException
150 * If the command fails
151 */
152 public void getConfigurationFromNode() throws ExecutionException {
153 getConfigurationFromNode(new NullProgressMonitor());
154 }
155
156 /**
157 * Retrieves the session configuration from the node.
158 *
159 * @param monitor
160 * - a progress monitor
161 * @throws ExecutionException
162 * If the command fails
163 */
164 public void getConfigurationFromNode(IProgressMonitor monitor) throws ExecutionException {
165 TraceSessionComponent session = (TraceSessionComponent) getParent();
166 session.getConfigurationFromNode(monitor);
167 }
168
169 /**
170 * Enables channels with given names which are part of this domain. If a
171 * given channel doesn't exists it creates a new channel with the given
172 * parameters (or default values if given parameter is null).
173 *
174 * @param channelNames
175 * - a list of channel names to enable on this domain
176 * @param info
177 * - channel information to set for the channel (use null for
178 * default)
179 * @throws ExecutionException
180 * If the command fails
181 */
182 public void enableChannels(List<String> channelNames, IChannelInfo info) throws ExecutionException {
183 enableChannels(channelNames, info, new NullProgressMonitor());
184 }
185
186 /**
187 * Enables channels with given names which are part of this domain. If a
188 * given channel doesn't exists it creates a new channel with the given
189 * parameters (or default values if given parameter is null).
190 *
191 * @param channelNames
192 * - a list of channel names to enable on this domain
193 * @param info
194 * - channel information to set for the channel (use null for
195 * default)
196 * @param monitor
197 * - a progress monitor
198 * @throws ExecutionException
199 * If the command fails
200 */
201 public void enableChannels(List<String> channelNames, IChannelInfo info,
202 IProgressMonitor monitor) throws ExecutionException {
203 getControlService().enableChannels(getParent().getName(), channelNames,
204 isKernel(), info, monitor);
205 }
206
207 /**
208 * Disables channels with given names which are part of this domain.
209 *
210 * @param channelNames
211 * - a list of channel names to enable on this domain
212 * @throws ExecutionException
213 * If the command fails
214 */
215 public void disableChannels(List<String> channelNames)
216 throws ExecutionException {
217 disableChannels(channelNames, new NullProgressMonitor());
218 }
219
220 /**
221 * Disables channels with given names which are part of this domain.
222 *
223 * @param channelNames
224 * - a list of channel names to enable on this domain
225 * @param monitor
226 * - a progress monitor
227 * @throws ExecutionException
228 * If the command fails
229 */
230 public void disableChannels(List<String> channelNames,
231 IProgressMonitor monitor) throws ExecutionException {
232 getControlService().disableChannels(getParent().getName(),
233 channelNames, isKernel(), monitor);
234 }
235
236 /**
237 * Enables a list of events with no additional parameters.
238 *
239 * @param eventNames
240 * - a list of event names to enabled.
241 * @param monitor
242 * - a progress monitor
243 * @throws ExecutionException
244 * If the command fails
245 */
246 public void enableEvents(List<String> eventNames, IProgressMonitor monitor)
247 throws ExecutionException {
248 getControlService().enableEvents(getSessionName(), null, eventNames,
249 isKernel(), monitor);
250 }
251
252 /**
253 * Enables all syscalls (for kernel domain)
254 *
255 * @throws ExecutionException
256 * If the command fails
257 */
258 public void enableSyscalls() throws ExecutionException {
259 enableSyscalls(new NullProgressMonitor());
260 }
261
262 /**
263 * Enables all syscalls (for kernel domain)
264 *
265 * @param monitor
266 * - a progress monitor
267 * @throws ExecutionException
268 * If the command fails
269 */
270
271 public void enableSyscalls(IProgressMonitor monitor)
272 throws ExecutionException {
273 getControlService().enableSyscalls(getSessionName(), null, monitor);
274 }
275
276 /**
277 * Enables a dynamic probe (for kernel domain)
278 *
279 * @param eventName
280 * - event name for probe
281 * @param isFunction
282 * - true for dynamic function entry/return probe else false
283 * @param probe
284 * - the actual probe
285 * @throws ExecutionException
286 * If the command fails
287 */
288 public void enableProbe(String eventName, boolean isFunction, String probe)
289 throws ExecutionException {
290 enableProbe(eventName, isFunction, probe, new NullProgressMonitor());
291 }
292
293 /**
294 * Enables a dynamic probe (for kernel domain)
295 *
296 * @param eventName
297 * - event name for probe
298 * @param isFunction
299 * - true for dynamic function entry/return probe else false
300 * @param probe
301 * - the actual probe
302 * @param monitor
303 * - a progress monitor
304 * @throws ExecutionException
305 * If the command fails
306 */
307 public void enableProbe(String eventName, boolean isFunction, String probe,
308 IProgressMonitor monitor) throws ExecutionException {
309 getControlService().enableProbe(getSessionName(), null, eventName,
310 isFunction, probe, monitor);
311 }
312
313 /**
314 * Enables events using log level.
315 *
316 * @param eventName
317 * - a event name
318 * @param logLevelType
319 * - a log level type
320 * @param level
321 * - a log level
322 * @throws ExecutionException
323 * If the command fails
324 */
325 public void enableLogLevel(String eventName, LogLevelType logLevelType,
326 TraceLogLevel level) throws ExecutionException {
327 enableLogLevel(eventName, logLevelType, level,
328 new NullProgressMonitor());
329 }
330
331 /**
332 * Enables events using log level.
333 *
334 * @param eventName
335 * - a event name
336 * @param logLevelType
337 * - a log level type
338 * @param level
339 * - a log level
340 * @param monitor
341 * - a progress monitor
342 * @throws ExecutionException
343 * If the command fails
344 */
345 public void enableLogLevel(String eventName, LogLevelType logLevelType,
346 TraceLogLevel level, IProgressMonitor monitor)
347 throws ExecutionException {
348 getControlService().enableLogLevel(getSessionName(), null, eventName,
349 logLevelType, level, monitor);
350 }
351
352 /**
353 * Add contexts to given channels and or events
354 *
355 * @param contexts
356 * - a list of contexts to add
357 * @throws ExecutionException
358 * If the command fails
359 */
360 public void addContexts(List<String> contexts) throws ExecutionException {
361 addContexts(contexts, new NullProgressMonitor());
362 }
363
364 /**
365 * Add contexts to given channels and or events
366 *
367 * @param contexts
368 * - a list of contexts to add
369 * @param monitor
370 * - a progress monitor
371 * @throws ExecutionException
372 * If the command fails
373 */
374 public void addContexts(List<String> contexts, IProgressMonitor monitor)
375 throws ExecutionException {
376 getControlService().addContexts(getSessionName(), null, null,
377 isKernel(), contexts, monitor);
378 }
379
380 /**
381 * Executes calibrate command to quantify LTTng overhead.
382 *
383 * @throws ExecutionException
384 * If the command fails
385 */
386 public void calibrate() throws ExecutionException {
387 calibrate(new NullProgressMonitor());
388 }
389
390 /**
391 * Executes calibrate command to quantify LTTng overhead.
392 *
393 * @param monitor
394 * - a progress monitor
395 * @throws ExecutionException
396 * If the command fails
397 */
398 public void calibrate(IProgressMonitor monitor) throws ExecutionException {
399 getControlService().calibrate(isKernel(), monitor);
400 }
401 }
This page took 0.04066 seconds and 6 git commands to generate.