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
.TraceDomainType
;
20 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IChannelInfo
;
21 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.IDomainInfo
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ILoggerInfo
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ITraceLogLevel
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.BufferType
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.DomainInfo
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
29 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.property
.TraceDomainPropertySource
;
30 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
34 * Implementation of the trace domain component.
37 * @author Bernd Hufmann
39 public class TraceDomainComponent
extends TraceControlComponent
{
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
44 * Path to icon file for this component.
46 public static final String TRACE_DOMAIN_ICON_FILE
= "icons/obj16/domain.gif"; //$NON-NLS-1$
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
52 * The domain information.
54 private IDomainInfo fDomainInfo
= null;
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
61 * @param name - the name of the component.
62 * @param parent - the parent of this component.
64 public TraceDomainComponent(String name
, ITraceControlComponent parent
) {
66 setImage(TRACE_DOMAIN_ICON_FILE
);
67 setToolTip(Messages
.TraceControl_DomainDisplayName
);
68 fDomainInfo
= new DomainInfo(name
);
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
75 * Sets the domain information.
76 * @param domainInfo - the domain information to set.
78 public void setDomainInfo(IDomainInfo domainInfo
) {
79 fDomainInfo
= domainInfo
;
80 IChannelInfo
[] channels
= fDomainInfo
.getChannels();
81 for (int i
= 0; i
< channels
.length
; i
++) {
82 TraceChannelComponent channel
= new TraceChannelComponent(channels
[i
].getName(), this);
83 channel
.setChannelInfo(channels
[i
]);
87 // Since the loggers are not in a channel, the loggers won't be added by the previous loop
88 if (TraceDomainType
.JUL
.equals(domainInfo
.getDomain()) ||
89 TraceDomainType
.LOG4J
.equals(domainInfo
.getDomain()) ||
90 TraceDomainType
.PYTHON
.equals(domainInfo
.getDomain())) {
91 List
<ILoggerInfo
> loggers
= fDomainInfo
.getLoggers();
92 for (ILoggerInfo loggerInfo
: loggers
) {
93 TraceLoggerComponent logger
= new TraceLoggerComponent(loggerInfo
.getName(), this);
94 logger
.setLoggerInfo(loggerInfo
);
101 public <T
> T
getAdapter(Class
<T
> adapter
) {
102 if (adapter
== IPropertySource
.class) {
103 return adapter
.cast(new TraceDomainPropertySource(this));
109 * @return session name from parent
111 public String
getSessionName() {
112 return ((TraceSessionComponent
)getParent()).getName();
116 * @return session from parent
118 public TraceSessionComponent
getSession() {
119 return (TraceSessionComponent
)getParent();
123 * @return the domain type ({@link TraceDomainType})
125 public TraceDomainType
getDomain() {
126 return fDomainInfo
.getDomain();
130 * Sets the domain type
133 * the domain type ({@link TraceDomainType})
135 public void setDomain(TraceDomainType domain
) {
136 fDomainInfo
.setDomain(domain
);
140 * @return returns all available channels for this domain.
142 public TraceChannelComponent
[] getChannels() {
143 List
<ITraceControlComponent
> channels
= getChildren(TraceChannelComponent
.class);
144 return channels
.toArray(new TraceChannelComponent
[channels
.size()]);
148 * @return the parent target node
150 public TargetNodeComponent
getTargetNode() {
151 return ((TraceSessionComponent
)getParent()).getTargetNode();
155 * @return the buffer type
157 public BufferType
getBufferType(){
158 return fDomainInfo
.getBufferType();
161 // ------------------------------------------------------------------------
163 // ------------------------------------------------------------------------
166 * Retrieves the session configuration from the node.
169 * - a progress monitor
170 * @throws ExecutionException
171 * If the command fails
173 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
174 TraceSessionComponent session
= (TraceSessionComponent
) getParent();
175 session
.getConfigurationFromNode(monitor
);
179 * Enables channels with given names which are part of this domain. If a
180 * given channel doesn't exists it creates a new channel with the given
181 * parameters (or default values if given parameter is null).
183 * @param channelNames
184 * - a list of channel names to enable on this domain
186 * - channel information to set for the channel (use null for
189 * - a progress monitor
190 * @throws ExecutionException
191 * If the command fails
193 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
,
194 IProgressMonitor monitor
) throws ExecutionException
{
195 getControlService().enableChannels(getParent().getName(), channelNames
,
196 getDomain(), info
, monitor
);
200 * Disables channels with given names which are part of this domain.
202 * @param channelNames
203 * - a list of channel names to enable on this domain
205 * - a progress monitor
206 * @throws ExecutionException
207 * If the command fails
209 public void disableChannels(List
<String
> channelNames
,
210 IProgressMonitor monitor
) throws ExecutionException
{
211 getControlService().disableChannels(getParent().getName(),
212 channelNames
, getDomain(), monitor
);
216 * Enables a list of events with no additional parameters.
219 * - a list of event names to enabled.
220 * @param filterExpression
221 * - a filter expression
222 * @param excludedEvents
223 * - a list of events to exclude.
225 * - a progress monitor
226 * @throws ExecutionException
227 * If the command fails
229 public void enableEvents(List
<String
> eventNames
, String filterExpression
, List
<String
> excludedEvents
, IProgressMonitor monitor
)
230 throws ExecutionException
{
231 getControlService().enableEvents(getSessionName(), null, eventNames
,
232 getDomain(), filterExpression
, excludedEvents
, monitor
);
236 * Disables events with given names which are part of this domain.
239 * - a list of logger names to disable
241 * - a progress monitor
242 * @throws ExecutionException
243 * If the command fails
245 public void disableLoggers(List
<String
> loggerNames
,
246 IProgressMonitor monitor
) throws ExecutionException
{
247 getControlService().disableEvent(getSessionName(), null, loggerNames
, getDomain(), monitor
);
251 * Enables all syscalls (for kernel domain)
252 * @param syscallNames
253 * - a list of syscall names
255 * - a progress monitor
256 * @throws ExecutionException
257 * If the command fails
260 public void enableSyscalls(List
<String
> syscallNames
, IProgressMonitor monitor
)
261 throws ExecutionException
{
262 getControlService().enableSyscalls(getSessionName(), null, syscallNames
, monitor
);
266 * Enables a dynamic probe (for kernel domain)
269 * - event name for probe
271 * - true for dynamic function entry/return probe else false
275 * - a progress monitor
276 * @throws ExecutionException
277 * If the command fails
279 public void enableProbe(String eventName
, boolean isFunction
, String probe
,
280 IProgressMonitor monitor
) throws ExecutionException
{
281 getControlService().enableProbe(getSessionName(), null, eventName
,
282 isFunction
, probe
, monitor
);
286 * Enables events using log level.
289 * - a list of event names
290 * @param logLevelType
294 * @param filterExpression
295 * - a filter expression
297 * - the domain type ({@link TraceDomainType})
299 * - a progress monitor
300 * @throws ExecutionException
301 * If the command fails
303 public void enableLogLevel(List
<String
> eventNames
, LogLevelType logLevelType
,
304 ITraceLogLevel level
, String filterExpression
, TraceDomainType domain
, IProgressMonitor monitor
)
305 throws ExecutionException
{
306 getControlService().enableLogLevel(getSessionName(), null, eventNames
,
307 logLevelType
, level
, filterExpression
, domain
, monitor
);
311 * Add contexts to given channels and or events
314 * - a list of contexts to add
316 * - a progress monitor
317 * @throws ExecutionException
318 * If the command fails
320 public void addContexts(List
<String
> contexts
, IProgressMonitor monitor
)
321 throws ExecutionException
{
322 getControlService().addContexts(getSessionName(), null, null,
323 getDomain(), contexts
, monitor
);