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
.internal
.lttng2
.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
.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
;
31 * Implementation of the trace domain component.
34 * @author Bernd Hufmann
36 public class TraceDomainComponent
extends TraceControlComponent
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 * Path to icon file for this component.
43 public static final String TRACE_DOMAIN_ICON_FILE
= "icons/obj16/domain.gif"; //$NON-NLS-1$
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
49 * The domain information.
51 private IDomainInfo fDomainInfo
= null;
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 * @param name - the name of the component.
59 * @param parent - the parent of this component.
61 public TraceDomainComponent(String name
, ITraceControlComponent parent
) {
63 setImage(TRACE_DOMAIN_ICON_FILE
);
64 setToolTip(Messages
.TraceControl_DomainDisplayName
);
65 fDomainInfo
= new DomainInfo(name
);
68 // ------------------------------------------------------------------------
70 // ------------------------------------------------------------------------
72 * Sets the domain information.
73 * @param domainInfo - the domain information to set.
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
]);
87 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
89 @SuppressWarnings("rawtypes")
91 public Object
getAdapter(Class adapter
) {
92 if (adapter
== IPropertySource
.class) {
93 return new TraceDomainPropertySource(this);
99 * @return session name from parent
101 public String
getSessionName() {
102 return ((TraceSessionComponent
)getParent()).getName();
106 * @return session from parent
108 public TraceSessionComponent
getSession() {
109 return (TraceSessionComponent
)getParent();
113 * @return true if domain is kernel, false for UST
115 public boolean isKernel() {
116 return fDomainInfo
.isKernel();
120 * Sets whether domain is Kernel domain or UST
121 * @param isKernel true for kernel, false for UST
123 public void setIsKernel(boolean isKernel
) {
124 fDomainInfo
.setIsKernel(isKernel
);
128 * @return returns all available channels for this domain.
130 public TraceChannelComponent
[] getChannels() {
131 List
<ITraceControlComponent
> channels
= getChildren(TraceChannelComponent
.class);
132 return channels
.toArray(new TraceChannelComponent
[channels
.size()]);
136 * @return the parent target node
138 public TargetNodeComponent
getTargetNode() {
139 return ((TraceSessionComponent
)getParent()).getTargetNode();
142 // ------------------------------------------------------------------------
144 // ------------------------------------------------------------------------
147 * Retrieves the session configuration from the node.
149 * @throws ExecutionException
150 * If the command fails
152 public void getConfigurationFromNode() throws ExecutionException
{
153 getConfigurationFromNode(new NullProgressMonitor());
157 * Retrieves the session configuration from the node.
160 * - a progress monitor
161 * @throws ExecutionException
162 * If the command fails
164 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
165 TraceSessionComponent session
= (TraceSessionComponent
) getParent();
166 session
.getConfigurationFromNode(monitor
);
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).
174 * @param channelNames
175 * - a list of channel names to enable on this domain
177 * - channel information to set for the channel (use null for
179 * @throws ExecutionException
180 * If the command fails
182 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
) throws ExecutionException
{
183 enableChannels(channelNames
, info
, new NullProgressMonitor());
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).
191 * @param channelNames
192 * - a list of channel names to enable on this domain
194 * - channel information to set for the channel (use null for
197 * - a progress monitor
198 * @throws ExecutionException
199 * If the command fails
201 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
,
202 IProgressMonitor monitor
) throws ExecutionException
{
203 getControlService().enableChannels(getParent().getName(), channelNames
,
204 isKernel(), info
, monitor
);
208 * Disables channels with given names which are part of this domain.
210 * @param channelNames
211 * - a list of channel names to enable on this domain
212 * @throws ExecutionException
213 * If the command fails
215 public void disableChannels(List
<String
> channelNames
)
216 throws ExecutionException
{
217 disableChannels(channelNames
, new NullProgressMonitor());
221 * Disables channels with given names which are part of this domain.
223 * @param channelNames
224 * - a list of channel names to enable on this domain
226 * - a progress monitor
227 * @throws ExecutionException
228 * If the command fails
230 public void disableChannels(List
<String
> channelNames
,
231 IProgressMonitor monitor
) throws ExecutionException
{
232 getControlService().disableChannels(getParent().getName(),
233 channelNames
, isKernel(), monitor
);
237 * Enables a list of events with no additional parameters.
240 * - a list of event names to enabled.
242 * - a progress monitor
243 * @throws ExecutionException
244 * If the command fails
246 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
)
247 throws ExecutionException
{
248 getControlService().enableEvents(getSessionName(), null, eventNames
,
249 isKernel(), monitor
);
253 * Enables all syscalls (for kernel domain)
255 * @throws ExecutionException
256 * If the command fails
258 public void enableSyscalls() throws ExecutionException
{
259 enableSyscalls(new NullProgressMonitor());
263 * Enables all syscalls (for kernel domain)
266 * - a progress monitor
267 * @throws ExecutionException
268 * If the command fails
271 public void enableSyscalls(IProgressMonitor monitor
)
272 throws ExecutionException
{
273 getControlService().enableSyscalls(getSessionName(), null, monitor
);
277 * Enables a dynamic probe (for kernel domain)
280 * - event name for probe
282 * - true for dynamic function entry/return probe else false
285 * @throws ExecutionException
286 * If the command fails
288 public void enableProbe(String eventName
, boolean isFunction
, String probe
)
289 throws ExecutionException
{
290 enableProbe(eventName
, isFunction
, probe
, new NullProgressMonitor());
294 * Enables a dynamic probe (for kernel domain)
297 * - event name for probe
299 * - true for dynamic function entry/return probe else false
303 * - a progress monitor
304 * @throws ExecutionException
305 * If the command fails
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
);
314 * Enables events using log level.
318 * @param logLevelType
322 * @throws ExecutionException
323 * If the command fails
325 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
326 TraceLogLevel level
) throws ExecutionException
{
327 enableLogLevel(eventName
, logLevelType
, level
,
328 new NullProgressMonitor());
332 * Enables events using log level.
336 * @param logLevelType
341 * - a progress monitor
342 * @throws ExecutionException
343 * If the command fails
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
);
353 * Add contexts to given channels and or events
356 * - a list of contexts to add
357 * @throws ExecutionException
358 * If the command fails
360 public void addContexts(List
<String
> contexts
) throws ExecutionException
{
361 addContexts(contexts
, new NullProgressMonitor());
365 * Add contexts to given channels and or events
368 * - a list of contexts to add
370 * - a progress monitor
371 * @throws ExecutionException
372 * If the command fails
374 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
375 throws ExecutionException
{
376 getControlService().addContexts(getSessionName(), null, null,
377 isKernel(), contexts
, monitor
);
381 * Executes calibrate command to quantify LTTng overhead.
383 * @throws ExecutionException
384 * If the command fails
386 public void calibrate() throws ExecutionException
{
387 calibrate(new NullProgressMonitor());
391 * Executes calibrate command to quantify LTTng overhead.
394 * - a progress monitor
395 * @throws ExecutionException
396 * If the command fails
398 public void calibrate(IProgressMonitor monitor
) throws ExecutionException
{
399 getControlService().calibrate(isKernel(), monitor
);