1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
17 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.ISessionInfo
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
22 * Implementation of the trace session group.
25 * @author Bernd Hufmann
27 public class TraceSessionGroup
extends TraceControlComponent
{
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
32 * Path to icon file for this component.
34 public static final String TRACE_SESSIONS_ICON_FILE
= "icons/obj16/sessions.gif"; //$NON-NLS-1$
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
45 * @param name - the name of the component.
46 * @param parent - the parent of this component.
48 public TraceSessionGroup(String name
, ITraceControlComponent parent
) {
50 setImage(TRACE_SESSIONS_ICON_FILE
);
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 * @return the parent target node
60 public TargetNodeComponent
getTargetNode() {
61 return (TargetNodeComponent
)getParent();
65 * Returns if node supports networks streaming or not
66 * @return <code>true</code> if node supports filtering else <code>false</code>
68 public boolean isNetworkStreamingSupported() {
69 return getTargetNode().isNetworkStreamingSupported();
72 // ------------------------------------------------------------------------
74 // ------------------------------------------------------------------------
76 * Retrieves the sessions information from the node.
78 * @throws ExecutionException
79 * If the command fails
81 public void getSessionsFromNode() throws ExecutionException
{
82 getSessionsFromNode(new NullProgressMonitor());
86 * Retrieves the sessions information from the node.
89 * - a progress monitor
90 * @throws ExecutionException
91 * If the command fails
93 public void getSessionsFromNode(IProgressMonitor monitor
)
94 throws ExecutionException
{
95 String
[] sessionNames
= getControlService().getSessionNames(monitor
);
96 for (int i
= 0; i
< sessionNames
.length
; i
++) {
97 TraceSessionComponent session
= new TraceSessionComponent(
98 sessionNames
[i
], this);
100 session
.getConfigurationFromNode(monitor
);
105 * Creates a session with given session name and location.
108 * - a session name to create
110 * - a path for storing the traces (use null for default)
112 * - a flag to indicate no consumer
113 * @param disableConsumer
114 * - a flag to disable consumer
115 * @throws ExecutionException
116 * If the command fails
118 public void createSession(String sessionName
, String sessionPath
, boolean noConsumer
, boolean disableConsumer
) throws ExecutionException
{
119 createSession(sessionName
, sessionPath
, noConsumer
, disableConsumer
, new NullProgressMonitor());
123 * Creates a session with given session name and location.
126 * - a session name to create
128 * - a path for storing the traces (use null for default)
130 * - a flag to indicate no consumer
131 * @param disableConsumer
132 * - a flag to disable consumer
134 * - a progress monitor
135 * @throws ExecutionException
136 * If the command fails
138 public void createSession(String sessionName
, String sessionPath
, boolean noConsumer
, boolean disableConsumer
, IProgressMonitor monitor
) throws ExecutionException
{
139 ISessionInfo sessionInfo
= getControlService().createSession(sessionName
, sessionPath
, noConsumer
, disableConsumer
, monitor
);
141 if (sessionInfo
!= null) {
142 TraceSessionComponent session
= new TraceSessionComponent(
143 sessionInfo
.getName(), TraceSessionGroup
.this);
145 session
.getConfigurationFromNode(monitor
);
150 * Creates a session with given session name and location.
153 * - a session name to create
155 * - a network URL for common definition of data and control channel
156 * or null if separate definition of data and control channel
158 * - a URL for control channel (networkUrl has to be null, dataUrl has to be set)
160 * - a URL for data channel (networkUrl has to be null, controlUrl has to be set)
162 * - a flag to indicate no consumer
163 * @param disableConsumer
164 * - a flag to disable consumer
165 * @throws ExecutionException
166 * If the command fails
168 public void createSession(String sessionName
, String networkUrl
, String controlUrl
, String dataUrl
, boolean noConsumer
, boolean disableConsumer
) throws ExecutionException
{
169 createSession(sessionName
, networkUrl
, controlUrl
, dataUrl
, noConsumer
, disableConsumer
, new NullProgressMonitor());
173 * Creates a session with given session name and location.
176 * - a session name to create
178 * - a network URL for common definition of data and control channel
179 * or null if separate definition of data and control channel
181 * - a URL for control channel (networkUrl has to be null, dataUrl has to be set)
183 * - a URL for data channel (networkUrl has to be null, controlUrl has to be set)
185 * - a flag to indicate no consumer
186 * @param disableConsumer
187 * - a flag to disable consumer
189 * - a progress monitor
190 * @throws ExecutionException
191 * If the command fails
193 public void createSession(String sessionName
, String networkUrl
, String controlUrl
, String dataUrl
, boolean noConsumer
, boolean disableConsumer
, IProgressMonitor monitor
) throws ExecutionException
{
194 ISessionInfo sessionInfo
= getControlService().createSession(sessionName
, networkUrl
, controlUrl
, dataUrl
, noConsumer
, disableConsumer
, monitor
);
196 if (sessionInfo
!= null) {
197 TraceSessionComponent session
= new TraceSessionComponent(sessionInfo
.getName(), TraceSessionGroup
.this);
199 session
.getConfigurationFromNode(monitor
);
204 * Destroys a session with given session name.
207 * - a session component to destroy
208 * @throws ExecutionException
209 * If the command fails
211 public void destroySession(TraceSessionComponent session
)
212 throws ExecutionException
{
213 destroySession(session
, new NullProgressMonitor());
217 * Destroys a session with given session name.
220 * - a session component to destroy
222 * - a progress monitor
223 * @throws ExecutionException
224 * If the command fails
226 public void destroySession(TraceSessionComponent session
,
227 IProgressMonitor monitor
) throws ExecutionException
{
228 getControlService().destroySession(session
.getName(), monitor
);
229 session
.removeAllChildren();
230 removeChild(session
);