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 (TraceChannelComponent
[])channels
.toArray(new TraceChannelComponent
[channels
.size()]);
136 * @return the parent target node
138 public TargetNodeComponent
getTargetNode() {
139 return ((TraceSessionComponent
)getParent()).getTargetNode();
142 // ------------------------------------------------------------------------
144 // ------------------------------------------------------------------------
146 * Retrieves the session configuration from the node.
147 * @throws ExecutionException
149 public void getConfigurationFromNode() throws ExecutionException
{
150 getConfigurationFromNode(new NullProgressMonitor());
153 * Retrieves the session configuration from the node.
154 * @param monitor - a progress monitor
155 * @throws ExecutionException
157 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
158 TraceSessionComponent session
= (TraceSessionComponent
) getParent();
159 session
.getConfigurationFromNode(monitor
);
162 * Enables channels with given names which are part of this domain. If a given channel
163 * doesn't exists it creates a new channel with the given parameters (or default values
164 * if given parameter is null).
165 * @param channelNames - a list of channel names to enable on this domain
166 * @param info - channel information to set for the channel (use null for default)
167 * @throws ExecutionException
169 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
) throws ExecutionException
{
170 enableChannels(channelNames
, info
, new NullProgressMonitor());
173 * Enables channels with given names which are part of this domain. If a given channel
174 * doesn't exists it creates a new channel with the given parameters (or default values
175 * if given parameter is null).
176 * @param channelNames - a list of channel names to enable on this domain
177 * @param info - channel information to set for the channel (use null for default)
178 * @param monitor - a progress monitor
179 * @throws ExecutionException
181 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
, IProgressMonitor monitor
) throws ExecutionException
{
182 getControlService().enableChannels(getParent().getName(), channelNames
, isKernel(), info
, monitor
);
185 * Disables channels with given names which are part of this domain.
186 * @param channelNames - a list of channel names to enable on this domain
187 * @throws ExecutionException
189 public void disableChannels(List
<String
> channelNames
) throws ExecutionException
{
190 disableChannels(channelNames
, new NullProgressMonitor());
193 * Disables channels with given names which are part of this domain.
194 * @param channelNames - a list of channel names to enable on this domain
195 * @param monitor - a progress monitor
196 * @throws ExecutionException
198 public void disableChannels(List
<String
> channelNames
, IProgressMonitor monitor
) throws ExecutionException
{
199 getControlService().disableChannels(getParent().getName(), channelNames
, isKernel(), monitor
);
203 * Enables a list of events with no additional parameters.
204 * @param eventNames - a list of event names to enabled.
205 * @param monitor - a progress monitor
206 * @throws ExecutionException
208 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
209 getControlService().enableEvents(getSessionName(), null, eventNames
, isKernel(), monitor
);
213 * Enables all syscalls (for kernel domain)
214 * @throws ExecutionException
216 public void enableSyscalls() throws ExecutionException
{
217 enableSyscalls(new NullProgressMonitor());
221 * Enables all syscalls (for kernel domain)
222 * @param monitor - a progress monitor
223 * @throws ExecutionException
226 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
227 getControlService().enableSyscalls(getSessionName(), null, monitor
);
231 * Enables a dynamic probe (for kernel domain)
232 * @param eventName - event name for probe
233 * @param isFunction - true for dynamic function entry/return probe else false
234 * @param probe - the actual probe
235 * @throws ExecutionException
237 public void enableProbe(String eventName
, boolean isFunction
, String probe
) throws ExecutionException
{
238 enableProbe(eventName
, isFunction
, probe
, new NullProgressMonitor());
242 * Enables a dynamic probe (for kernel domain)
243 * @param eventName - event name for probe
244 * @param isFunction - true for dynamic function entry/return probe else false
245 * @param probe - the actual probe
246 * @param monitor - a progress monitor
247 * @throws ExecutionException
249 public void enableProbe(String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
250 getControlService().enableProbe(getSessionName(), null, eventName
, isFunction
, probe
, monitor
);
254 * Enables events using log level.
255 * @param eventName - a event name
256 * @param logLevelType - a log level type
257 * @param level - a log level
258 * @throws ExecutionException
260 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
) throws ExecutionException
{
261 enableLogLevel(eventName
, logLevelType
, level
, new NullProgressMonitor());
265 * Enables events using log level.
266 * @param eventName - a event name
267 * @param logLevelType - a log level type
268 * @param level - a log level
269 * @param monitor - a progress monitor
270 * @throws ExecutionException
272 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
273 getControlService().enableLogLevel(getSessionName(), null, eventName
, logLevelType
, level
, monitor
);
277 * Add contexts to given channels and or events
278 * @param contexts - a list of contexts to add
279 * @throws ExecutionException
281 public void addContexts(List
<String
> contexts
) throws ExecutionException
{
282 addContexts(contexts
, new NullProgressMonitor());
286 * Add contexts to given channels and or events
287 * @param contexts - a list of contexts to add
288 * @param monitor - a progress monitor
289 * @throws ExecutionException
291 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
) throws ExecutionException
{
292 getControlService().addContexts(getSessionName(), null, null, isKernel(), contexts
, monitor
);
296 * Executes calibrate command to quantify LTTng overhead.
297 * @throws ExecutionException
299 public void calibrate() throws ExecutionException
{
300 calibrate(new NullProgressMonitor());
304 * Executes calibrate command to quantify LTTng overhead.
305 * @param monitor - a progress monitor
306 * @throws ExecutionException
308 public void calibrate(IProgressMonitor monitor
) throws ExecutionException
{
309 getControlService().calibrate(isKernel(), monitor
);