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)
90 public Object
getAdapter(Class adapter
) {
91 if (adapter
== IPropertySource
.class) {
92 return new TraceDomainPropertySource(this);
98 * @return session name from parent
100 public String
getSessionName() {
101 return ((TraceSessionComponent
)getParent()).getName();
105 * @return session from parent
107 public TraceSessionComponent
getSession() {
108 return (TraceSessionComponent
)getParent();
112 * @return true if domain is kernel, false for UST
114 public boolean isKernel() {
115 return fDomainInfo
.isKernel();
119 * Sets whether domain is Kernel domain or UST
120 * @param isKernel true for kernel, false for UST
122 public void setIsKernel(boolean isKernel
) {
123 fDomainInfo
.setIsKernel(isKernel
);
127 * @return returns all available channels for this domain.
129 public TraceChannelComponent
[] getChannels() {
130 List
<ITraceControlComponent
> channels
= getChildren(TraceChannelComponent
.class);
131 return channels
.toArray(new TraceChannelComponent
[channels
.size()]);
135 * @return the parent target node
137 public TargetNodeComponent
getTargetNode() {
138 return ((TraceSessionComponent
)getParent()).getTargetNode();
141 // ------------------------------------------------------------------------
143 // ------------------------------------------------------------------------
146 * Retrieves the session configuration from the node.
148 * @throws ExecutionException
149 * If the command fails
151 public void getConfigurationFromNode() throws ExecutionException
{
152 getConfigurationFromNode(new NullProgressMonitor());
156 * Retrieves the session configuration from the node.
159 * - a progress monitor
160 * @throws ExecutionException
161 * If the command fails
163 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
164 TraceSessionComponent session
= (TraceSessionComponent
) getParent();
165 session
.getConfigurationFromNode(monitor
);
169 * Enables channels with given names which are part of this domain. If a
170 * given channel doesn't exists it creates a new channel with the given
171 * parameters (or default values if given parameter is null).
173 * @param channelNames
174 * - a list of channel names to enable on this domain
176 * - channel information to set for the channel (use null for
178 * @throws ExecutionException
179 * If the command fails
181 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
) throws ExecutionException
{
182 enableChannels(channelNames
, info
, new NullProgressMonitor());
186 * Enables channels with given names which are part of this domain. If a
187 * given channel doesn't exists it creates a new channel with the given
188 * parameters (or default values if given parameter is null).
190 * @param channelNames
191 * - a list of channel names to enable on this domain
193 * - channel information to set for the channel (use null for
196 * - a progress monitor
197 * @throws ExecutionException
198 * If the command fails
200 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
,
201 IProgressMonitor monitor
) throws ExecutionException
{
202 getControlService().enableChannels(getParent().getName(), channelNames
,
203 isKernel(), info
, monitor
);
207 * Disables channels with given names which are part of this domain.
209 * @param channelNames
210 * - a list of channel names to enable on this domain
211 * @throws ExecutionException
212 * If the command fails
214 public void disableChannels(List
<String
> channelNames
)
215 throws ExecutionException
{
216 disableChannels(channelNames
, new NullProgressMonitor());
220 * Disables channels with given names which are part of this domain.
222 * @param channelNames
223 * - a list of channel names to enable on this domain
225 * - a progress monitor
226 * @throws ExecutionException
227 * If the command fails
229 public void disableChannels(List
<String
> channelNames
,
230 IProgressMonitor monitor
) throws ExecutionException
{
231 getControlService().disableChannels(getParent().getName(),
232 channelNames
, isKernel(), monitor
);
236 * Enables a list of events with no additional parameters.
239 * - a list of event names to enabled.
241 * - a progress monitor
242 * @throws ExecutionException
243 * If the command fails
245 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
)
246 throws ExecutionException
{
247 getControlService().enableEvents(getSessionName(), null, eventNames
,
248 isKernel(), null, monitor
);
252 * Enables all syscalls (for kernel domain)
254 * @throws ExecutionException
255 * If the command fails
257 public void enableSyscalls() throws ExecutionException
{
258 enableSyscalls(new NullProgressMonitor());
262 * Enables all syscalls (for kernel domain)
265 * - a progress monitor
266 * @throws ExecutionException
267 * If the command fails
270 public void enableSyscalls(IProgressMonitor monitor
)
271 throws ExecutionException
{
272 getControlService().enableSyscalls(getSessionName(), null, monitor
);
276 * Enables a dynamic probe (for kernel domain)
279 * - event name for probe
281 * - true for dynamic function entry/return probe else false
284 * @throws ExecutionException
285 * If the command fails
287 public void enableProbe(String eventName
, boolean isFunction
, String probe
)
288 throws ExecutionException
{
289 enableProbe(eventName
, isFunction
, probe
, new NullProgressMonitor());
293 * Enables a dynamic probe (for kernel domain)
296 * - event name for probe
298 * - true for dynamic function entry/return probe else false
302 * - a progress monitor
303 * @throws ExecutionException
304 * If the command fails
306 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
307 IProgressMonitor monitor
) throws ExecutionException
{
308 getControlService().enableProbe(getSessionName(), null, eventName
,
309 isFunction
, probe
, monitor
);
313 * Enables events using log level.
317 * @param logLevelType
321 * @param filterExpression
322 * - a filter expression
323 * @throws ExecutionException
324 * If the command fails
326 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
327 TraceLogLevel level
, String filterExpression
) throws ExecutionException
{
328 enableLogLevel(eventName
, logLevelType
, level
, filterExpression
,
329 new NullProgressMonitor());
333 * Enables events using log level.
337 * @param logLevelType
341 * @param filterExpression
342 * - a filter expression
344 * - a progress monitor
345 * @throws ExecutionException
346 * If the command fails
348 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
349 TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
)
350 throws ExecutionException
{
351 getControlService().enableLogLevel(getSessionName(), null, eventName
,
352 logLevelType
, level
, filterExpression
, monitor
);
356 * Add contexts to given channels and or events
359 * - a list of contexts to add
360 * @throws ExecutionException
361 * If the command fails
363 public void addContexts(List
<String
> contexts
) throws ExecutionException
{
364 addContexts(contexts
, new NullProgressMonitor());
368 * Add contexts to given channels and or events
371 * - a list of contexts to add
373 * - a progress monitor
374 * @throws ExecutionException
375 * If the command fails
377 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
378 throws ExecutionException
{
379 getControlService().addContexts(getSessionName(), null, null,
380 isKernel(), contexts
, monitor
);
384 * Executes calibrate command to quantify LTTng overhead.
386 * @throws ExecutionException
387 * If the command fails
389 public void calibrate() throws ExecutionException
{
390 calibrate(new NullProgressMonitor());
394 * Executes calibrate command to quantify LTTng overhead.
397 * - a progress monitor
398 * @throws ExecutionException
399 * If the command fails
401 public void calibrate(IProgressMonitor monitor
) throws ExecutionException
{
402 getControlService().calibrate(isKernel(), monitor
);