1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
;
15 import java
.util
.List
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
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
]);
86 public Object
getAdapter(Class adapter
) {
87 if (adapter
== IPropertySource
.class) {
88 return new TraceDomainPropertySource(this);
94 * @return session name from parent
96 public String
getSessionName() {
97 return ((TraceSessionComponent
)getParent()).getName();
101 * @return session from parent
103 public TraceSessionComponent
getSession() {
104 return (TraceSessionComponent
)getParent();
108 * @return true if domain is kernel, false for UST
110 public boolean isKernel() {
111 return fDomainInfo
.isKernel();
115 * Sets whether domain is Kernel domain or UST
116 * @param isKernel true for kernel, false for UST
118 public void setIsKernel(boolean isKernel
) {
119 fDomainInfo
.setIsKernel(isKernel
);
123 * @return returns all available channels for this domain.
125 public TraceChannelComponent
[] getChannels() {
126 List
<ITraceControlComponent
> channels
= getChildren(TraceChannelComponent
.class);
127 return channels
.toArray(new TraceChannelComponent
[channels
.size()]);
131 * @return the parent target node
133 public TargetNodeComponent
getTargetNode() {
134 return ((TraceSessionComponent
)getParent()).getTargetNode();
137 // ------------------------------------------------------------------------
139 // ------------------------------------------------------------------------
142 * Retrieves the session configuration from the node.
145 * - a progress monitor
146 * @throws ExecutionException
147 * If the command fails
149 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
150 TraceSessionComponent session
= (TraceSessionComponent
) getParent();
151 session
.getConfigurationFromNode(monitor
);
155 * Enables channels with given names which are part of this domain. If a
156 * given channel doesn't exists it creates a new channel with the given
157 * parameters (or default values if given parameter is null).
159 * @param channelNames
160 * - a list of channel names to enable on this domain
162 * - channel information to set for the channel (use null for
165 * - a progress monitor
166 * @throws ExecutionException
167 * If the command fails
169 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
,
170 IProgressMonitor monitor
) throws ExecutionException
{
171 getControlService().enableChannels(getParent().getName(), channelNames
,
172 isKernel(), info
, monitor
);
176 * Disables channels with given names which are part of this domain.
178 * @param channelNames
179 * - a list of channel names to enable on this domain
181 * - a progress monitor
182 * @throws ExecutionException
183 * If the command fails
185 public void disableChannels(List
<String
> channelNames
,
186 IProgressMonitor monitor
) throws ExecutionException
{
187 getControlService().disableChannels(getParent().getName(),
188 channelNames
, isKernel(), monitor
);
192 * Enables a list of events with no additional parameters.
195 * - a list of event names to enabled.
197 * - a progress monitor
198 * @throws ExecutionException
199 * If the command fails
201 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
)
202 throws ExecutionException
{
203 getControlService().enableEvents(getSessionName(), null, eventNames
,
204 isKernel(), null, monitor
);
208 * Enables all syscalls (for kernel domain)
211 * - a progress monitor
212 * @throws ExecutionException
213 * If the command fails
216 public void enableSyscalls(IProgressMonitor monitor
)
217 throws ExecutionException
{
218 getControlService().enableSyscalls(getSessionName(), null, monitor
);
222 * Enables a dynamic probe (for kernel domain)
225 * - event name for probe
227 * - true for dynamic function entry/return probe else false
231 * - a progress monitor
232 * @throws ExecutionException
233 * If the command fails
235 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
236 IProgressMonitor monitor
) throws ExecutionException
{
237 getControlService().enableProbe(getSessionName(), null, eventName
,
238 isFunction
, probe
, monitor
);
242 * Enables events using log level.
246 * @param logLevelType
250 * @param filterExpression
251 * - a filter expression
253 * - a progress monitor
254 * @throws ExecutionException
255 * If the command fails
257 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
258 TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
)
259 throws ExecutionException
{
260 getControlService().enableLogLevel(getSessionName(), null, eventName
,
261 logLevelType
, level
, filterExpression
, monitor
);
265 * Add contexts to given channels and or events
268 * - a list of contexts to add
270 * - a progress monitor
271 * @throws ExecutionException
272 * If the command fails
274 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
275 throws ExecutionException
{
276 getControlService().addContexts(getSessionName(), null, null,
277 isKernel(), contexts
, monitor
);
281 * Executes calibrate command to quantify LTTng overhead.
284 * - a progress monitor
285 * @throws ExecutionException
286 * If the command fails
288 public void calibrate(IProgressMonitor monitor
) throws ExecutionException
{
289 getControlService().calibrate(isKernel(), monitor
);