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
.lttng
.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
.lttng
.ui
.views
.control
.Messages
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IChannelInfo
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IDomainInfo
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ITraceControlComponent
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.LogLevelType
;
24 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceLogLevel
;
25 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceDomainPropertySource
;
26 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
29 * <b><u>TraceDomainComponent</u></b>
31 * Implementation of the trace domain component.
34 public class TraceDomainComponent
extends TraceControlComponent
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
39 * Path to icon file for this component.
41 public static final String TRACE_DOMAIN_ICON_FILE
= "icons/obj16/domain.gif"; //$NON-NLS-1$
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
47 * The domain information.
49 private IDomainInfo fDomainInfo
= null;
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
56 * @param name - the name of the component.
57 * @param parent - the parent of this component.
59 public TraceDomainComponent(String name
, ITraceControlComponent parent
) {
61 setImage(TRACE_DOMAIN_ICON_FILE
);
62 setToolTip(Messages
.TraceControl_DomainDisplayName
);
63 fDomainInfo
= new DomainInfo(name
);
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
70 * Sets the domain information.
71 * @param domainInfo - the domain information to set.
73 public void setDomainInfo(IDomainInfo domainInfo
) {
74 fDomainInfo
= domainInfo
;
75 IChannelInfo
[] channels
= fDomainInfo
.getChannels();
76 for (int i
= 0; i
< channels
.length
; i
++) {
77 TraceChannelComponent channel
= new TraceChannelComponent(channels
[i
].getName(), this);
78 channel
.setChannelInfo(channels
[i
]);
85 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
87 @SuppressWarnings("rawtypes")
89 public Object
getAdapter(Class adapter
) {
90 if (adapter
== IPropertySource
.class) {
91 return new TraceDomainPropertySource(this);
97 * @return session name from parent
99 public String
getSessionName() {
100 return ((TraceSessionComponent
)getParent()).getName();
104 * @return session from parent
106 public TraceSessionComponent
getSession() {
107 return (TraceSessionComponent
)getParent();
111 * @return true if domain is kernel, false for UST
113 public boolean isKernel() {
114 return fDomainInfo
.isKernel();
118 * Sets whether domain is Kernel domain or UST
119 * @param isKernel true for kernel, false for UST
121 public void setIsKernel(boolean isKernel
) {
122 fDomainInfo
.setIsKernel(isKernel
);
126 * @return returns all available channels for this domain.
128 public TraceChannelComponent
[] getChannels() {
129 List
<ITraceControlComponent
> channels
= getChildren(TraceChannelComponent
.class);
130 return (TraceChannelComponent
[])channels
.toArray(new TraceChannelComponent
[channels
.size()]);
134 * @return the parent target node
136 public TargetNodeComponent
getTargetNode() {
137 return ((TraceSessionComponent
)getParent()).getTargetNode();
140 // ------------------------------------------------------------------------
142 // ------------------------------------------------------------------------
144 * Retrieves the session configuration from the node.
145 * @throws ExecutionException
147 public void getConfigurationFromNode() throws ExecutionException
{
148 getConfigurationFromNode(new NullProgressMonitor());
151 * Retrieves the session configuration from the node.
152 * @param monitor - a progress monitor
153 * @throws ExecutionException
155 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
156 TraceSessionComponent session
= (TraceSessionComponent
) getParent();
157 session
.getConfigurationFromNode(monitor
);
160 * Enables channels with given names which are part of this domain. If a given channel
161 * doesn't exists it creates a new channel with the given parameters (or default values
162 * if given parameter is null).
163 * @param channelNames - a list of channel names to enable on this domain
164 * @param info - channel information to set for the channel (use null for default)
165 * @throws ExecutionException
167 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
) throws ExecutionException
{
168 enableChannels(channelNames
, info
, new NullProgressMonitor());
171 * Enables channels with given names which are part of this domain. If a given channel
172 * doesn't exists it creates a new channel with the given parameters (or default values
173 * if given parameter is null).
174 * @param channelNames - a list of channel names to enable on this domain
175 * @param info - channel information to set for the channel (use null for default)
176 * @param monitor - a progress monitor
177 * @throws ExecutionException
179 public void enableChannels(List
<String
> channelNames
, IChannelInfo info
, IProgressMonitor monitor
) throws ExecutionException
{
180 getControlService().enableChannels(getParent().getName(), channelNames
, isKernel(), info
, monitor
);
183 * Disables channels with given names which are part of this domain.
184 * @param channelNames - a list of channel names to enable on this domain
185 * @throws ExecutionException
187 public void disableChannels(List
<String
> channelNames
) throws ExecutionException
{
188 disableChannels(channelNames
, new NullProgressMonitor());
191 * Disables channels with given names which are part of this domain.
192 * @param channelNames - a list of channel names to enable on this domain
193 * @param monitor - a progress monitor
194 * @throws ExecutionException
196 public void disableChannels(List
<String
> channelNames
, IProgressMonitor monitor
) throws ExecutionException
{
197 getControlService().disableChannels(getParent().getName(), channelNames
, isKernel(), monitor
);
201 * Enables a list of events with no additional parameters.
202 * @param eventNames - a list of event names to enabled.
203 * @param monitor - a progress monitor
204 * @throws ExecutionException
206 public void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
207 getControlService().enableEvents(getSessionName(), null, eventNames
, isKernel(), monitor
);
211 * Enables all syscalls (for kernel domain)
212 * @throws ExecutionException
214 public void enableSyscalls() throws ExecutionException
{
215 enableSyscalls(new NullProgressMonitor());
219 * Enables all syscalls (for kernel domain)
220 * @param monitor - a progress monitor
221 * @throws ExecutionException
224 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
225 getControlService().enableSyscalls(getSessionName(), null, monitor
);
229 * Enables a dynamic probe (for kernel domain)
230 * @param eventName - event name for probe
231 * @param probe - the actual probe
232 * @throws ExecutionException
234 public void enableProbe(String eventName
, String probe
) throws ExecutionException
{
235 enableProbe(eventName
, probe
, new NullProgressMonitor());
239 * Enables a dynamic probe (for kernel domain)
240 * @param eventName - event name for probe
241 * @param probe - the actual probe
242 * @param monitor - a progress monitor
243 * @throws ExecutionException
245 public void enableProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
246 getControlService().enableProbe(getSessionName(), null, eventName
, probe
, monitor
);
250 * Enables a dynamic function entry/return probe (for kernel domain)
251 * @param eventName - event name for probe
252 * @param probe - the actual probe
253 * @throws ExecutionException
255 public void enableFunctionProbe(String eventName
, String probe
) throws ExecutionException
{
256 enableFunctionProbe(eventName
, probe
, new NullProgressMonitor());
260 * Enables a dynamic function entry/return probe (for kernel domain)
261 * @param eventName - event name for probe
262 * @param probe - the actual probe
263 * @param monitor - a progress monitor
264 * @throws ExecutionException
266 public void enableFunctionProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
267 getControlService().enableFunctionProbe(getSessionName(), null, eventName
, probe
, monitor
);
271 * Enables events using log level.
272 * @param eventName - a event name
273 * @param logLevelType - a log level type
274 * @param level - a log level
275 * @throws ExecutionException
277 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
) throws ExecutionException
{
278 enableLogLevel(eventName
, logLevelType
, level
, new NullProgressMonitor());
282 * Enables events using log level.
283 * @param eventName - a event name
284 * @param logLevelType - a log level type
285 * @param level - a log level
286 * @param monitor - a progress monitor
287 * @throws ExecutionException
289 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
290 getControlService().enableLogLevel(getSessionName(), null, eventName
, logLevelType
, level
, monitor
);