1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
23 * Implementation of the trace session group.
26 * @author Bernd Hufmann
28 public class TraceSessionGroup
extends TraceControlComponent
{
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
33 * Path to icon file for this component.
35 public static final String TRACE_SESSIONS_ICON_FILE
= "icons/obj16/sessions.gif"; //$NON-NLS-1$
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
46 * @param name - the name of the component.
47 * @param parent - the parent of this component.
49 public TraceSessionGroup(String name
, ITraceControlComponent parent
) {
51 setImage(TRACE_SESSIONS_ICON_FILE
);
54 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
59 * @return the parent target node
61 public TargetNodeComponent
getTargetNode() {
62 return (TargetNodeComponent
)getParent();
66 * Returns if node supports networks streaming or not
67 * @return <code>true</code> if node supports filtering else <code>false</code>
69 public boolean isNetworkStreamingSupported() {
70 return getTargetNode().isNetworkStreamingSupported();
73 * Returns if node supports snapshots or not
74 * @return <code>true</code> if it supports snapshots else <code>false</code>
76 */ public boolean isSnapshotSupported() {
77 return getTargetNode().isSnapshotSupported();
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
84 * Retrieves the sessions information from the node.
86 * @throws ExecutionException
87 * If the command fails
89 public void getSessionsFromNode() throws ExecutionException
{
90 getSessionsFromNode(new NullProgressMonitor());
94 * Retrieves the sessions information from the node.
97 * - a progress monitor
98 * @throws ExecutionException
99 * If the command fails
101 public void getSessionsFromNode(IProgressMonitor monitor
)
102 throws ExecutionException
{
103 String
[] sessionNames
= getControlService().getSessionNames(monitor
);
104 for (int i
= 0; i
< sessionNames
.length
; i
++) {
105 TraceSessionComponent session
= new TraceSessionComponent(
106 sessionNames
[i
], this);
108 session
.getConfigurationFromNode(monitor
);
113 * Creates a session with given session name and location.
116 * the session information used to create the session
119 * - a progress monitor
120 * @throws ExecutionException
121 * If the command fails
123 public void createSession(ISessionInfo sessionInf
, IProgressMonitor monitor
) throws ExecutionException
{
124 ISessionInfo sessionInfo
= getControlService().createSession(sessionInf
, monitor
);
126 if (sessionInfo
!= null) {
127 TraceSessionComponent session
= new TraceSessionComponent(sessionInfo
.getName(), TraceSessionGroup
.this);
129 session
.getConfigurationFromNode(monitor
);
134 * Destroys a session with given session name.
137 * - a session component to destroy
139 * - a progress monitor
140 * @throws ExecutionException
141 * If the command fails
143 public void destroySession(TraceSessionComponent session
,
144 IProgressMonitor monitor
) throws ExecutionException
{
145 getControlService().destroySession(session
.getName(), monitor
);
146 session
.removeAllChildren();
147 removeChild(session
);