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
.ui
.views
.control
.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
.core
.control
.model
.ISessionInfo
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.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 * - a session name to create
118 * - a path for storing the traces (use null for default)
120 * - true for snapshot session else false
122 * - a progress monitor
123 * @throws ExecutionException
124 * If the command fails
126 public void createSession(String sessionName
, String sessionPath
, boolean isSnapshot
, IProgressMonitor monitor
) throws ExecutionException
{
127 ISessionInfo sessionInfo
= getControlService().createSession(sessionName
, sessionPath
, isSnapshot
, monitor
);
129 if (sessionInfo
!= null) {
130 TraceSessionComponent session
= new TraceSessionComponent(
131 sessionInfo
.getName(), TraceSessionGroup
.this);
133 session
.getConfigurationFromNode(monitor
);
138 * Creates a session with given session name and location.
141 * - a session name to create
143 * - a network URL for common definition of data and control channel
144 * or null if separate definition of data and control channel
146 * - a URL for control channel (networkUrl has to be null, dataUrl has to be set)
148 * - a URL for data channel (networkUrl has to be null, controlUrl has to be set)
150 * - true for snapshot session else false
152 * - a progress monitor
153 * @throws ExecutionException
154 * If the command fails
156 public void createSession(String sessionName
, String networkUrl
, String controlUrl
, String dataUrl
, boolean isSnapshot
, IProgressMonitor monitor
) throws ExecutionException
{
157 ISessionInfo sessionInfo
= getControlService().createSession(sessionName
, networkUrl
, controlUrl
, dataUrl
, isSnapshot
, monitor
);
159 if (sessionInfo
!= null) {
160 TraceSessionComponent session
= new TraceSessionComponent(sessionInfo
.getName(), TraceSessionGroup
.this);
162 session
.getConfigurationFromNode(monitor
);
167 * Destroys a session with given session name.
170 * - a session component to destroy
172 * - a progress monitor
173 * @throws ExecutionException
174 * If the command fails
176 public void destroySession(TraceSessionComponent session
,
177 IProgressMonitor monitor
) throws ExecutionException
{
178 getControlService().destroySession(session
.getName(), monitor
);
179 session
.removeAllChildren();
180 removeChild(session
);