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
.jdt
.annotation
.Nullable
;
21 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
26 * Implementation of the trace session group.
29 * @author Bernd Hufmann
31 public class TraceSessionGroup
extends TraceControlComponent
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 * Path to icon file for this component.
38 public static final String TRACE_SESSIONS_ICON_FILE
= "icons/obj16/sessions.gif"; //$NON-NLS-1$
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
49 * @param name - the name of the component.
50 * @param parent - the parent of this component.
52 public TraceSessionGroup(String name
, ITraceControlComponent parent
) {
54 setImage(TRACE_SESSIONS_ICON_FILE
);
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
62 * @return the parent target node
64 public TargetNodeComponent
getTargetNode() {
65 return (TargetNodeComponent
)getParent();
69 * Returns if node supports networks streaming or not
70 * @return <code>true</code> if node supports filtering else <code>false</code>
72 public boolean isNetworkStreamingSupported() {
73 return getTargetNode().isNetworkStreamingSupported();
76 * Returns if node supports snapshots or not
77 * @return <code>true</code> if it supports snapshots else <code>false</code>
79 */ public boolean isSnapshotSupported() {
80 return getTargetNode().isSnapshotSupported();
84 * Returns if node supports live or not
86 * @return <code>true</code> if it supports live else <code>false</code>
88 public boolean isLiveSupported() {
89 return getTargetNode().isLiveSupported();
92 // ------------------------------------------------------------------------
94 // ------------------------------------------------------------------------
96 * Retrieves the sessions information from the node.
98 * @throws ExecutionException
99 * If the command fails
101 public void getSessionsFromNode() throws ExecutionException
{
102 getSessionsFromNode(new NullProgressMonitor());
106 * Retrieves the sessions information from the node.
109 * - a progress monitor
110 * @throws ExecutionException
111 * If the command fails
113 public void getSessionsFromNode(IProgressMonitor monitor
)
114 throws ExecutionException
{
115 List
<String
> sessionNames
= getControlService().getSessionNames(monitor
);
116 for (String sessionName
: sessionNames
) {
117 TraceSessionComponent session
=
118 new TraceSessionComponent(sessionName
, this);
120 session
.getConfigurationFromNode(monitor
);
125 * Creates a session with given session name and location.
128 * the session information used to create the session
131 * - a progress monitor
132 * @throws ExecutionException
133 * If the command fails
135 public void createSession(ISessionInfo sessionInf
, IProgressMonitor monitor
) throws ExecutionException
{
136 ISessionInfo sessionInfo
= getControlService().createSession(sessionInf
, monitor
);
138 if (sessionInfo
!= null) {
139 TraceSessionComponent session
= new TraceSessionComponent(sessionInfo
, TraceSessionGroup
.this);
141 session
.getConfigurationFromNode(monitor
);
146 * Command to execute a list of commands
148 * - a progress monitor
150 * - a list of commands to execute
151 * @throws ExecutionException
152 * If the command fails
154 public void executeCommands(IProgressMonitor monitor
, List
<String
> commands
) throws ExecutionException
{
155 getControlService().runCommands(monitor
, commands
);
156 getTargetNode().refresh();
160 * Destroys a session with given session name.
163 * - a session component to destroy
165 * - a progress monitor
166 * @throws ExecutionException
167 * If the command fails
169 public void destroySession(TraceSessionComponent session
,
170 IProgressMonitor monitor
) throws ExecutionException
{
171 getControlService().destroySession(session
.getName(), monitor
);
172 session
.removeAllChildren();
173 removeChild(session
);
177 * Load all or a given session.
180 * a input path to load session from or null for load all from default
182 * flag whether to overwrite existing or not
185 * @throws ExecutionException
186 * If the command fails
188 public void loadSession(@Nullable String inputPath
, boolean isForce
, IProgressMonitor monitor
)
189 throws ExecutionException
{
190 getControlService().loadSession(inputPath
, isForce
, monitor
);
191 getTargetNode().refresh();