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
.control
.ui
.views
.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
.control
.core
.model
.IChannelInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.BufferType
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.DomainInfo
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.property
.TraceDomainPropertySource
;
28 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
32 * Implementation of the trace domain component.
35 * @author Bernd Hufmann
37 public class TraceDomainComponent
extends TraceControlComponent
{
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
42 * Path to icon file for this component.
44 public static final String TRACE_DOMAIN_ICON_FILE
= "icons/obj16/domain.gif"; //$NON-NLS-1$
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
50 * The domain information.
52 private IDomainInfo fDomainInfo
= null;
54 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
59 * @param name - the name of the component.
60 * @param parent - the parent of this component.
62 public TraceDomainComponent(String name
, ITraceControlComponent parent
) {
64 setImage(TRACE_DOMAIN_ICON_FILE
);
65 setToolTip(Messages
.TraceControl_DomainDisplayName
);
66 fDomainInfo
= new DomainInfo(name
);
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
73 * Sets the domain information.
74 * @param domainInfo - the domain information to set.
76 public void setDomainInfo(IDomainInfo domainInfo
) {
77 fDomainInfo
= domainInfo
;
78 IChannelInfo
[] channels
= fDomainInfo
.getChannels();
79 for (int i
= 0; i
< channels
.length
; i
++) {
80 TraceChannelComponent channel
= new TraceChannelComponent(channels
[i
].getName(), this);
81 channel
.setChannelInfo(channels
[i
]);
87 public Object
getAdapter(Class adapter
) {
88 if (adapter
== IPropertySource
.class) {
89 return new TraceDomainPropertySource(this);
95 * @return session name from parent
97 public String
getSessionName() {
98 return ((TraceSessionComponent
)getParent()).getName();
102 * @return session from parent
104 public TraceSessionComponent
getSession() {
105 return (TraceSessionComponent
)getParent();
109 * @return true if domain is kernel, false for UST
111 public boolean isKernel() {
112 return fDomainInfo
.isKernel();
116 * Sets whether domain is Kernel domain or UST
117 * @param isKernel true for kernel, false for UST
119 public void setIsKernel(boolean isKernel
) {
120 fDomainInfo
.setIsKernel(isKernel
);
124 * @return returns all available channels for this domain.
126 public TraceChannelComponent
[] getChannels() {
127 List
<ITraceControlComponent
> channels
= getChildren(TraceChannelComponent
.class);
128 return channels
.toArray(new TraceChannelComponent
[channels
.size()]);
132 * @return the parent target node
134 public TargetNodeComponent
getTargetNode() {
135 return ((TraceSessionComponent
)getParent()).getTargetNode();
139 * @return the buffer type
141 public BufferType
getBufferType(){
142 return fDomainInfo
.getBufferType();
145 // ------------------------------------------------------------------------
147 // ------------------------------------------------------------------------
150 * Retrieves the session configuration from the node.
153 * - a progress monitor
154 * @throws ExecutionException
155 * If the command fails
157 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
158 TraceSessionComponent session
= (TraceSessionComponent
) getParent();
159 session
.getConfigurationFromNode(monitor
);
163 * Enables channels with given names which are part of this domain. If a
164 * given channel doesn't exists it creates a new channel with the given
165 * parameters (or default values if given parameter is null).
167 * @param channelNames
168 * - a list of channel names to enable on this domain
170 * - channel information to set for the channel (use null for
173 * - a progress monitor
174 * @throws ExecutionException
175 * If the command fails
177 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
,
178 IProgressMonitor monitor
) throws ExecutionException
{
179 getControlService().enableChannels(getParent().getName(), channelNames
,
180 isKernel(), info
, monitor
);
184 * Disables channels with given names which are part of this domain.
186 * @param channelNames
187 * - a list of channel names to enable on this domain
189 * - a progress monitor
190 * @throws ExecutionException
191 * If the command fails
193 public void disableChannels(List
<String
> channelNames
,
194 IProgressMonitor monitor
) throws ExecutionException
{
195 getControlService().disableChannels(getParent().getName(),
196 channelNames
, isKernel(), monitor
);
200 * Enables a list of events with no additional parameters.
203 * - a list of event names to enabled.
205 * - a progress monitor
206 * @throws ExecutionException
207 * If the command fails
209 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
)
210 throws ExecutionException
{
211 getControlService().enableEvents(getSessionName(), null, eventNames
,
212 isKernel(), null, monitor
);
216 * Enables all syscalls (for kernel domain)
219 * - a progress monitor
220 * @throws ExecutionException
221 * If the command fails
224 public void enableSyscalls(IProgressMonitor monitor
)
225 throws ExecutionException
{
226 getControlService().enableSyscalls(getSessionName(), null, monitor
);
230 * Enables a dynamic probe (for kernel domain)
233 * - event name for probe
235 * - true for dynamic function entry/return probe else false
239 * - a progress monitor
240 * @throws ExecutionException
241 * If the command fails
243 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
244 IProgressMonitor monitor
) throws ExecutionException
{
245 getControlService().enableProbe(getSessionName(), null, eventName
,
246 isFunction
, probe
, monitor
);
250 * Enables events using log level.
254 * @param logLevelType
258 * @param filterExpression
259 * - a filter expression
261 * - a progress monitor
262 * @throws ExecutionException
263 * If the command fails
265 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
266 TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
)
267 throws ExecutionException
{
268 getControlService().enableLogLevel(getSessionName(), null, eventName
,
269 logLevelType
, level
, filterExpression
, monitor
);
273 * Add contexts to given channels and or events
276 * - a list of contexts to add
278 * - a progress monitor
279 * @throws ExecutionException
280 * If the command fails
282 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
283 throws ExecutionException
{
284 getControlService().addContexts(getSessionName(), null, null,
285 isKernel(), contexts
, monitor
);
289 * Executes calibrate command to quantify LTTng overhead.
292 * - a progress monitor
293 * @throws ExecutionException
294 * If the command fails
296 public void calibrate(IProgressMonitor monitor
) throws ExecutionException
{
297 getControlService().calibrate(isKernel(), monitor
);