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 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
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
21 import org
.eclipse
.linuxtools
.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();
82 // ------------------------------------------------------------------------
84 // ------------------------------------------------------------------------
86 * Retrieves the sessions information from the node.
88 * @throws ExecutionException
89 * If the command fails
91 public void getSessionsFromNode() throws ExecutionException
{
92 getSessionsFromNode(new NullProgressMonitor());
96 * Retrieves the sessions information from the node.
99 * - a progress monitor
100 * @throws ExecutionException
101 * If the command fails
103 public void getSessionsFromNode(IProgressMonitor monitor
)
104 throws ExecutionException
{
105 String
[] sessionNames
= getControlService().getSessionNames(monitor
);
106 for (int i
= 0; i
< sessionNames
.length
; i
++) {
107 TraceSessionComponent session
= new TraceSessionComponent(
108 sessionNames
[i
], this);
110 session
.getConfigurationFromNode(monitor
);
115 * Creates a session with given session name and location.
118 * the session information used to create the session
121 * - a progress monitor
122 * @throws ExecutionException
123 * If the command fails
125 public void createSession(ISessionInfo sessionInf
, IProgressMonitor monitor
) throws ExecutionException
{
126 ISessionInfo sessionInfo
= getControlService().createSession(sessionInf
, monitor
);
128 if (sessionInfo
!= null) {
129 TraceSessionComponent session
= new TraceSessionComponent(sessionInfo
.getName(), TraceSessionGroup
.this);
131 session
.getConfigurationFromNode(monitor
);
136 * Command to execute a list of commands
138 * - a progress monitor
140 * - a list of commands to execute
141 * @throws ExecutionException
142 * If the command fails
144 public void executeCommands(IProgressMonitor monitor
, List
<String
> commands
) throws ExecutionException
{
145 getControlService().runCommands(monitor
, commands
);
146 getTargetNode().refresh();
150 * Destroys a session with given session name.
153 * - a session component to destroy
155 * - a progress monitor
156 * @throws ExecutionException
157 * If the command fails
159 public void destroySession(TraceSessionComponent session
,
160 IProgressMonitor monitor
) throws ExecutionException
{
161 getControlService().destroySession(session
.getName(), monitor
);
162 session
.removeAllChildren();
163 removeChild(session
);