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
.LTTngUiPlugin
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.Messages
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IDomainInfo
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ISessionInfo
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ITraceControlComponent
;
24 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceSessionState
;
25 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceSessionPropertySource
;
26 import org
.eclipse
.swt
.graphics
.Image
;
27 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
30 * <b><u>TraceSessionComponent</u></b>
32 * Implementation of the trace session component.
35 public class TraceSessionComponent
extends TraceControlComponent
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 * Path to icon file for this component (inactive state).
43 public static final String TRACE_SESSION_ICON_FILE_INACTIVE
= "icons/obj16/session_inactive.gif"; //$NON-NLS-1$
45 * Path to icon file for this component (active state).
47 public static final String TRACE_SESSION_ICON_FILE_ACTIVE
= "icons/obj16/session_active.gif"; //$NON-NLS-1$
49 * Path to icon file for this component (destroyed state).
51 public static final String TRACE_SESSION_ICON_FILE_DESTROYED
= "icons/obj16/session_destroyed.gif"; //$NON-NLS-1$
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
57 * The session information.
59 private ISessionInfo fSessionInfo
= null;
61 * A flag to indicate if session has been destroyed.
63 private boolean fIsDestroyed
= false;
65 * The image to be displayed in state active.
67 private Image fActiveImage
= null;
69 * The image to be displayed in state destroyed
71 private Image fDestroyedImage
= null;
73 // ------------------------------------------------------------------------
75 // ------------------------------------------------------------------------
78 * @param name - the name of the component.
79 * @param parent - the parent of this component.
81 public TraceSessionComponent(String name
, ITraceControlComponent parent
) {
83 setImage(TRACE_SESSION_ICON_FILE_INACTIVE
);
84 setToolTip(Messages
.TraceControl_SessionDisplayName
);
85 fSessionInfo
= new SessionInfo(name
);
86 fActiveImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_ACTIVE
);
87 fDestroyedImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_DESTROYED
);
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
95 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
98 public Image
getImage() {
100 return fDestroyedImage
;
103 if (fSessionInfo
.getSessionState() == TraceSessionState
.INACTIVE
) {
104 return super.getImage();
111 * @return the whether the session is destroyed or not.
113 public boolean isDestroyed() {
118 * Sets the session destroyed state to the given value.
119 * @param destroyed - value to set.
121 public void setDestroyed(boolean destroyed
) {
122 fIsDestroyed
= destroyed
;
126 * @return the session state state (active or inactive).
128 public TraceSessionState
getSessionState() {
129 return fSessionInfo
.getSessionState();
133 * Sets the session state to the given value.
134 * @param state - state to set.
136 public void setSessionState(TraceSessionState state
) {
137 fSessionInfo
.setSessionState(state
);
141 * Sets the event state to the value specified by the given name.
142 * @param stateName - state to set.
144 public void setSessionState(String stateName
) {
145 fSessionInfo
.setSessionState(stateName
);
149 * @return path string where session is located.
151 public String
getSessionPath() {
152 return fSessionInfo
.getSessionPath();
156 * Sets the path string (where session is located) to the given value.
157 * @param path - session path to set.
159 public void setSessionPath(String sessionPath
) {
160 fSessionInfo
.setSessionPath(sessionPath
);
165 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
167 @SuppressWarnings("rawtypes")
169 public Object
getAdapter(Class adapter
) {
170 if (adapter
== IPropertySource
.class) {
171 return new TraceSessionPropertySource(this);
177 * @return all available domains of this session.
179 public TraceDomainComponent
[] getDomains() {
180 List
<ITraceControlComponent
> sessions
= getChildren(TraceDomainComponent
.class);
181 return (TraceDomainComponent
[])sessions
.toArray(new TraceDomainComponent
[sessions
.size()]);
185 * @return the parent target node
187 public TargetNodeComponent
getTargetNode() {
188 return ((TraceSessionGroup
)getParent()).getTargetNode();
191 // ------------------------------------------------------------------------
193 // ------------------------------------------------------------------------
195 * Retrieves the session configuration from the node.
196 * @throws ExecutionException
198 public void getConfigurationFromNode() throws ExecutionException
{
199 getConfigurationFromNode(new NullProgressMonitor());
203 * Retrieves the session configuration from the node.
204 * @param monitor - a progress monitor
205 * @throws ExecutionException
207 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
209 fSessionInfo
= getControlService().getSession(getName(), monitor
);
210 IDomainInfo
[] domains
= fSessionInfo
.getDomains();
211 for (int i
= 0; i
< domains
.length
; i
++) {
212 TraceDomainComponent domainComponent
= new TraceDomainComponent(domains
[i
].getName(), this);
213 addChild(domainComponent
);
214 domainComponent
.setDomainInfo(domains
[i
]);
219 * Starts the session.
220 * throws ExecutionExecption
222 public void startSession() throws ExecutionException
{
223 startSession(new NullProgressMonitor());
227 * Starts the session.
228 * @param monitor - a progress monitor
229 * throws ExecutionExecption
231 public void startSession(IProgressMonitor monitor
) throws ExecutionException
{
232 getControlService().startSession(getName(), monitor
);
236 * Starts the session.
237 * throws ExecutionExecption
239 public void stopSession() throws ExecutionException
{
240 startSession(new NullProgressMonitor());
244 * Starts the session.
245 * @param monitor - a progress monitor
246 * throws ExecutionExecption
248 public void stopSession(IProgressMonitor monitor
) throws ExecutionException
{
249 getControlService().stopSession(getName(), monitor
);
253 * Enables a list of events with no additional parameters.
254 * @param eventNames - a list of event names to enabled.
255 * @param isKernel - a flag for indicating kernel or UST.
256 * @throws ExecutionException
258 public void enableEvent(List
<String
> eventNames
, boolean isKernel
) throws ExecutionException
{
259 enableEvents(eventNames
, isKernel
, new NullProgressMonitor());
263 * Enables a list of events with no additional parameters.
264 * @param eventNames - a list of event names to enabled.
265 * @param isKernel - a flag for indicating kernel or UST.
266 * @param monitor - a progress monitor
267 * @throws ExecutionException
269 public void enableEvents(List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
270 getControlService().enableEvents(getName(), null, eventNames
, isKernel
, monitor
);
274 * Enables all syscalls (for kernel domain)
275 * @throws ExecutionException
277 public void enableSyscalls() throws ExecutionException
{
278 enableSyscalls(new NullProgressMonitor());
282 * Enables all syscalls (for kernel domain)
283 * @param monitor - a progress monitor
284 * @throws ExecutionException
286 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
287 getControlService().enableSyscalls(getName(), null, monitor
);
291 * Enables a dynamic probe (for kernel domain)
292 * @param eventName - event name for probe
293 * @param probe - the actual probe
294 * @throws ExecutionException
296 public void enableProbe(String eventName
, String probe
) throws ExecutionException
{
297 enableProbe(eventName
, probe
, new NullProgressMonitor());
301 * Enables a dynamic probe (for kernel domain)
302 * @param eventName - event name for probe
303 * @param probe - the actual probe
304 * @param monitor - a progress monitor
305 * @throws ExecutionException
307 public void enableProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
308 getControlService().enableProbe(getName(), null, eventName
, probe
, monitor
);
312 * Enables a dynamic function entry/return probe (for kernel domain)
313 * @param eventName - event name for probe
314 * @param probe - the actual probe
315 * @throws ExecutionException
317 public void enableFunctionProbe(String eventName
, String probe
) throws ExecutionException
{
318 enableFunctionProbe(eventName
, probe
, new NullProgressMonitor());
322 * Enables a dynamic function entry/return probe (for kernel domain)
323 * @param eventName - event name for probe
324 * @param probe - the actual probe
325 * @param monitor - a progress monitor
326 * @throws ExecutionException
328 public void enableFunctionProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
329 getControlService().enableFunctionProbe(getName(), null, eventName
, probe
, monitor
);