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
.ui
.Activator
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.Messages
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.IDomainInfo
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ISessionInfo
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.LogLevelType
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceLogLevel
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceSessionState
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.property
.TraceSessionPropertySource
;
28 import org
.eclipse
.swt
.graphics
.Image
;
29 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
32 * <b><u>TraceSessionComponent</u></b>
34 * Implementation of the trace session component.
37 public class TraceSessionComponent
extends TraceControlComponent
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 * Path to icon file for this component (inactive state).
45 public static final String TRACE_SESSION_ICON_FILE_INACTIVE
= "icons/obj16/session_inactive.gif"; //$NON-NLS-1$
47 * Path to icon file for this component (active state).
49 public static final String TRACE_SESSION_ICON_FILE_ACTIVE
= "icons/obj16/session_active.gif"; //$NON-NLS-1$
51 * Path to icon file for this component (destroyed state).
53 public static final String TRACE_SESSION_ICON_FILE_DESTROYED
= "icons/obj16/session_destroyed.gif"; //$NON-NLS-1$
55 // ------------------------------------------------------------------------
57 // ------------------------------------------------------------------------
59 * The session information.
61 private ISessionInfo fSessionInfo
= null;
63 * A flag to indicate if session has been destroyed.
65 private boolean fIsDestroyed
= false;
67 * The image to be displayed in state active.
69 private Image fActiveImage
= null;
71 * The image to be displayed in state destroyed
73 private Image fDestroyedImage
= null;
75 // ------------------------------------------------------------------------
77 // ------------------------------------------------------------------------
80 * @param name - the name of the component.
81 * @param parent - the parent of this component.
83 public TraceSessionComponent(String name
, ITraceControlComponent parent
) {
85 setImage(TRACE_SESSION_ICON_FILE_INACTIVE
);
86 setToolTip(Messages
.TraceControl_SessionDisplayName
);
87 fSessionInfo
= new SessionInfo(name
);
88 fActiveImage
= Activator
.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_ACTIVE
);
89 fDestroyedImage
= Activator
.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_DESTROYED
);
92 // ------------------------------------------------------------------------
94 // ------------------------------------------------------------------------
97 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getImage()
100 public Image
getImage() {
102 return fDestroyedImage
;
105 if (fSessionInfo
.getSessionState() == TraceSessionState
.INACTIVE
) {
106 return super.getImage();
113 * @return the whether the session is destroyed or not.
115 public boolean isDestroyed() {
120 * Sets the session destroyed state to the given value.
121 * @param destroyed - value to set.
123 public void setDestroyed(boolean destroyed
) {
124 fIsDestroyed
= destroyed
;
128 * @return the session state state (active or inactive).
130 public TraceSessionState
getSessionState() {
131 return fSessionInfo
.getSessionState();
135 * Sets the session state to the given value.
136 * @param state - state to set.
138 public void setSessionState(TraceSessionState state
) {
139 fSessionInfo
.setSessionState(state
);
143 * Sets the event state to the value specified by the given name.
144 * @param stateName - state to set.
146 public void setSessionState(String stateName
) {
147 fSessionInfo
.setSessionState(stateName
);
151 * @return path string where session is located.
153 public String
getSessionPath() {
154 return fSessionInfo
.getSessionPath();
158 * Sets the path string (where session is located) to the given value.
159 * @param path - session path to set.
161 public void setSessionPath(String sessionPath
) {
162 fSessionInfo
.setSessionPath(sessionPath
);
167 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
169 @SuppressWarnings("rawtypes")
171 public Object
getAdapter(Class adapter
) {
172 if (adapter
== IPropertySource
.class) {
173 return new TraceSessionPropertySource(this);
179 * @return all available domains of this session.
181 public TraceDomainComponent
[] getDomains() {
182 List
<ITraceControlComponent
> sessions
= getChildren(TraceDomainComponent
.class);
183 return (TraceDomainComponent
[])sessions
.toArray(new TraceDomainComponent
[sessions
.size()]);
187 * @return the parent target node
189 public TargetNodeComponent
getTargetNode() {
190 return ((TraceSessionGroup
)getParent()).getTargetNode();
193 // ------------------------------------------------------------------------
195 // ------------------------------------------------------------------------
197 * Retrieves the session configuration from the node.
198 * @throws ExecutionException
200 public void getConfigurationFromNode() throws ExecutionException
{
201 getConfigurationFromNode(new NullProgressMonitor());
205 * Retrieves the session configuration from the node.
206 * @param monitor - a progress monitor
207 * @throws ExecutionException
209 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
211 fSessionInfo
= getControlService().getSession(getName(), monitor
);
212 IDomainInfo
[] domains
= fSessionInfo
.getDomains();
213 for (int i
= 0; i
< domains
.length
; i
++) {
214 TraceDomainComponent domainComponent
= new TraceDomainComponent(domains
[i
].getName(), this);
215 addChild(domainComponent
);
216 domainComponent
.setDomainInfo(domains
[i
]);
221 * Starts the session.
222 * throws ExecutionExecption
224 public void startSession() throws ExecutionException
{
225 startSession(new NullProgressMonitor());
229 * Starts the session.
230 * @param monitor - a progress monitor
231 * throws ExecutionExecption
233 public void startSession(IProgressMonitor monitor
) throws ExecutionException
{
234 getControlService().startSession(getName(), monitor
);
238 * Starts the session.
239 * throws ExecutionExecption
241 public void stopSession() throws ExecutionException
{
242 startSession(new NullProgressMonitor());
246 * Starts the session.
247 * @param monitor - a progress monitor
248 * throws ExecutionExecption
250 public void stopSession(IProgressMonitor monitor
) throws ExecutionException
{
251 getControlService().stopSession(getName(), monitor
);
255 * Enables a list of events with no additional parameters.
256 * @param eventNames - a list of event names to enabled.
257 * @param isKernel - a flag for indicating kernel or UST.
258 * @throws ExecutionException
260 public void enableEvent(List
<String
> eventNames
, boolean isKernel
) throws ExecutionException
{
261 enableEvents(eventNames
, isKernel
, new NullProgressMonitor());
265 * Enables a list of events with no additional parameters.
266 * @param eventNames - a list of event names to enabled.
267 * @param isKernel - a flag for indicating kernel or UST.
268 * @param monitor - a progress monitor
269 * @throws ExecutionException
271 public void enableEvents(List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
272 getControlService().enableEvents(getName(), null, eventNames
, isKernel
, monitor
);
276 * Enables all syscalls (for kernel domain)
277 * @throws ExecutionException
279 public void enableSyscalls() throws ExecutionException
{
280 enableSyscalls(new NullProgressMonitor());
284 * Enables all syscalls (for kernel domain)
285 * @param monitor - a progress monitor
286 * @throws ExecutionException
288 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
289 getControlService().enableSyscalls(getName(), null, monitor
);
293 * Enables a dynamic probe (for kernel domain)
294 * @param eventName - event name for probe
295 * @param isFunction - true for dynamic function entry/return probe else false
296 * @param probe - the actual probe
297 * @throws ExecutionException
299 public void enableProbe(String eventName
, boolean isFunction
, String probe
) throws ExecutionException
{
300 enableProbe(eventName
, isFunction
, probe
, new NullProgressMonitor());
304 * Enables a dynamic probe (for kernel domain)
305 * @param eventName - event name for probe
306 * @param isFunction - true for dynamic function entry/return probe else false
307 * @param probe - the actual probe
308 * @param monitor - a progress monitor
309 * @throws ExecutionException
311 public void enableProbe(String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
312 getControlService().enableProbe(getName(), null, eventName
, isFunction
, probe
, monitor
);
316 * Enables events using log level.
317 * @param eventName - a event name
318 * @param logLevelType - a log level type
319 * @param level - a log level
320 * @throws ExecutionException
322 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
) throws ExecutionException
{
323 enableLogLevel(eventName
, logLevelType
, level
, new NullProgressMonitor());
327 * Enables events using log level.
328 * @param eventName - a event name
329 * @param logLevelType - a log level type
330 * @param level - a log level
331 * @param monitor - a progress monitor
332 * @throws ExecutionException
334 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
335 getControlService().enableLogLevel(getName(), null, eventName
, logLevelType
, level
, monitor
);