1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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
.tracecompass
.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
.tracecompass
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
20 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
21 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.BufferType
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.DomainInfo
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
27 import org
.eclipse
.tracecompass
.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 <T
> T
getAdapter(Class
<T
> adapter
) {
88 if (adapter
== IPropertySource
.class) {
89 return adapter
.cast(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.
204 * @param filterExpression
205 * - a filter expression
207 * - a progress monitor
208 * @throws ExecutionException
209 * If the command fails
211 public void enableEvents(List
<String
> eventNames
, String filterExpression
, IProgressMonitor monitor
)
212 throws ExecutionException
{
213 getControlService().enableEvents(getSessionName(), null, eventNames
,
214 isKernel(), filterExpression
, monitor
);
218 * Enables all syscalls (for kernel domain)
221 * - a progress monitor
222 * @throws ExecutionException
223 * If the command fails
226 public void enableSyscalls(IProgressMonitor monitor
)
227 throws ExecutionException
{
228 getControlService().enableSyscalls(getSessionName(), null, monitor
);
232 * Enables a dynamic probe (for kernel domain)
235 * - event name for probe
237 * - true for dynamic function entry/return probe else false
241 * - a progress monitor
242 * @throws ExecutionException
243 * If the command fails
245 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
246 IProgressMonitor monitor
) throws ExecutionException
{
247 getControlService().enableProbe(getSessionName(), null, eventName
,
248 isFunction
, probe
, monitor
);
252 * Enables events using log level.
256 * @param logLevelType
260 * @param filterExpression
261 * - a filter expression
263 * - a progress monitor
264 * @throws ExecutionException
265 * If the command fails
267 public void enableLogLevel(String eventName
, LogLevelType logLevelType
,
268 TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
)
269 throws ExecutionException
{
270 getControlService().enableLogLevel(getSessionName(), null, eventName
,
271 logLevelType
, level
, filterExpression
, monitor
);
275 * Add contexts to given channels and or events
278 * - a list of contexts to add
280 * - a progress monitor
281 * @throws ExecutionException
282 * If the command fails
284 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
285 throws ExecutionException
{
286 getControlService().addContexts(getSessionName(), null, null,
287 isKernel(), contexts
, monitor
);