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
.core
.runtime
.NullProgressMonitor
;
20 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
21 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
25 * Implementation of the trace session group.
28 * @author Bernd Hufmann
30 public class TraceSessionGroup
extends TraceControlComponent
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 * Path to icon file for this component.
37 public static final String TRACE_SESSIONS_ICON_FILE
= "icons/obj16/sessions.gif"; //$NON-NLS-1$
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
48 * @param name - the name of the component.
49 * @param parent - the parent of this component.
51 public TraceSessionGroup(String name
, ITraceControlComponent parent
) {
53 setImage(TRACE_SESSIONS_ICON_FILE
);
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
61 * @return the parent target node
63 public TargetNodeComponent
getTargetNode() {
64 return (TargetNodeComponent
)getParent();
68 * Returns if node supports networks streaming or not
69 * @return <code>true</code> if node supports filtering else <code>false</code>
71 public boolean isNetworkStreamingSupported() {
72 return getTargetNode().isNetworkStreamingSupported();
75 * Returns if node supports snapshots or not
76 * @return <code>true</code> if it supports snapshots else <code>false</code>
78 */ public boolean isSnapshotSupported() {
79 return getTargetNode().isSnapshotSupported();
83 * Returns if node supports live or not
85 * @return <code>true</code> if it supports live else <code>false</code>
87 public boolean isLiveSupported() {
88 return getTargetNode().isLiveSupported();
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
95 * Retrieves the sessions information from the node.
97 * @throws ExecutionException
98 * If the command fails
100 public void getSessionsFromNode() throws ExecutionException
{
101 getSessionsFromNode(new NullProgressMonitor());
105 * Retrieves the sessions information from the node.
108 * - a progress monitor
109 * @throws ExecutionException
110 * If the command fails
112 public void getSessionsFromNode(IProgressMonitor monitor
)
113 throws ExecutionException
{
114 List
<String
> sessionNames
= getControlService().getSessionNames(monitor
);
115 for (String sessionName
: sessionNames
) {
116 TraceSessionComponent session
=
117 new TraceSessionComponent(sessionName
, this);
119 session
.getConfigurationFromNode(monitor
);
124 * Creates a session with given session name and location.
127 * the session information used to create the session
130 * - a progress monitor
131 * @throws ExecutionException
132 * If the command fails
134 public void createSession(ISessionInfo sessionInf
, IProgressMonitor monitor
) throws ExecutionException
{
135 ISessionInfo sessionInfo
= getControlService().createSession(sessionInf
, monitor
);
137 if (sessionInfo
!= null) {
138 TraceSessionComponent session
= new TraceSessionComponent(sessionInfo
, TraceSessionGroup
.this);
140 session
.getConfigurationFromNode(monitor
);
145 * Loads a session from a path
150 * - a progress monitor
151 * @throws ExecutionException
152 * If the command fails
154 public void loadSession(String sessionPath
, IProgressMonitor monitor
) throws ExecutionException
{
155 getControlService().loadSession(sessionPath
, monitor
);
161 * Command to execute a list of commands
163 * - a progress monitor
165 * - a list of commands to execute
166 * @throws ExecutionException
167 * If the command fails
169 public void executeCommands(IProgressMonitor monitor
, List
<String
> commands
) throws ExecutionException
{
170 getControlService().runCommands(monitor
, commands
);
171 getTargetNode().refresh();
175 * Destroys a session with given session name.
178 * - a session component to destroy
180 * - a progress monitor
181 * @throws ExecutionException
182 * If the command fails
184 public void destroySession(TraceSessionComponent session
,
185 IProgressMonitor monitor
) throws ExecutionException
{
186 getControlService().destroySession(session
.getName(), monitor
);
187 session
.removeAllChildren();
188 removeChild(session
);