Add support for streaming feature of LTTng Tools 2.1 (part 1)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceSessionGroup.java
CommitLineData
eb1bab5b
BH
1/**********************************************************************
2 * Copyright (c) 2012 Ericsson
cfdb727a 3 *
eb1bab5b
BH
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
cfdb727a
AM
8 *
9 * Contributors:
eb1bab5b
BH
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
115b4a01 12package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
eb1bab5b
BH
13
14import org.eclipse.core.commands.ExecutionException;
15import org.eclipse.core.runtime.IProgressMonitor;
16import org.eclipse.core.runtime.NullProgressMonitor;
9315aeee 17import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
115b4a01 18import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
eb1bab5b
BH
19
20/**
eb1bab5b
BH
21 * <p>
22 * Implementation of the trace session group.
23 * </p>
cfdb727a 24 *
dbd4432d 25 * @author Bernd Hufmann
eb1bab5b
BH
26 */
27public class TraceSessionGroup extends TraceControlComponent {
28 // ------------------------------------------------------------------------
29 // Constants
30 // ------------------------------------------------------------------------
31 /**
32 * Path to icon file for this component.
cfdb727a 33 */
eb1bab5b 34 public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$
cfdb727a 35
eb1bab5b
BH
36 // ------------------------------------------------------------------------
37 // Attributes
38 // ------------------------------------------------------------------------
cfdb727a 39
eb1bab5b
BH
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43 /**
cfdb727a 44 * Constructor
eb1bab5b
BH
45 * @param name - the name of the component.
46 * @param parent - the parent of this component.
cfdb727a 47 */
eb1bab5b
BH
48 public TraceSessionGroup(String name, ITraceControlComponent parent) {
49 super(name, parent);
50 setImage(TRACE_SESSIONS_ICON_FILE);
51 }
bbb3538a 52
eb1bab5b
BH
53 // ------------------------------------------------------------------------
54 // Accessors
55 // ------------------------------------------------------------------------
56
498704b3
BH
57 /**
58 * @return the parent target node
59 */
60 public TargetNodeComponent getTargetNode() {
61 return (TargetNodeComponent)getParent();
62 }
63
f3b33d40
BH
64 /**
65 * Returns if node supports networks streaming or not
66 * @return <code>true</code> if node supports filtering else <code>false</code>
67 */
68 public boolean isNetworkStreamingSupported() {
69 return getTargetNode().isNetworkStreamingSupported();
70 }
71
eb1bab5b
BH
72 // ------------------------------------------------------------------------
73 // Operations
74 // ------------------------------------------------------------------------
75 /**
76 * Retrieves the sessions information from the node.
cfdb727a 77 *
eb1bab5b 78 * @throws ExecutionException
cfdb727a 79 * If the command fails
eb1bab5b
BH
80 */
81 public void getSessionsFromNode() throws ExecutionException {
82 getSessionsFromNode(new NullProgressMonitor());
83 }
84
85 /**
86 * Retrieves the sessions information from the node.
cfdb727a
AM
87 *
88 * @param monitor
89 * - a progress monitor
eb1bab5b 90 * @throws ExecutionException
cfdb727a 91 * If the command fails
eb1bab5b 92 */
cfdb727a
AM
93 public void getSessionsFromNode(IProgressMonitor monitor)
94 throws ExecutionException {
eb1bab5b
BH
95 String[] sessionNames = getControlService().getSessionNames(monitor);
96 for (int i = 0; i < sessionNames.length; i++) {
cfdb727a
AM
97 TraceSessionComponent session = new TraceSessionComponent(
98 sessionNames[i], this);
eb1bab5b
BH
99 addChild(session);
100 session.getConfigurationFromNode(monitor);
101 }
102 }
bbb3538a
BH
103
104 /**
cfdb727a
AM
105 * Creates a session with given session name and location.
106 *
107 * @param sessionName
108 * - a session name to create
109 * @param sessionPath
110 * - a path for storing the traces (use null for default)
f3b33d40
BH
111 * @param noConsumer
112 * - a flag to indicate no consumer
113 * @param disableConsumer
114 * - a flag to disable consumer
cfdb727a
AM
115 * @throws ExecutionException
116 * If the command fails
bbb3538a 117 */
f3b33d40
BH
118 public void createSession(String sessionName, String sessionPath, boolean noConsumer, boolean disableConsumer) throws ExecutionException {
119 createSession(sessionName, sessionPath, noConsumer, disableConsumer, new NullProgressMonitor());
bbb3538a 120 }
cfdb727a 121
bbb3538a 122 /**
cfdb727a
AM
123 * Creates a session with given session name and location.
124 *
125 * @param sessionName
126 * - a session name to create
127 * @param sessionPath
128 * - a path for storing the traces (use null for default)
f3b33d40
BH
129 * @param noConsumer
130 * - a flag to indicate no consumer
131 * @param disableConsumer
132 * - a flag to disable consumer
cfdb727a
AM
133 * @param monitor
134 * - a progress monitor
135 * @throws ExecutionException
136 * If the command fails
bbb3538a 137 */
f3b33d40
BH
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);
140
bbb3538a 141 if (sessionInfo != null) {
cfdb727a
AM
142 TraceSessionComponent session = new TraceSessionComponent(
143 sessionInfo.getName(), TraceSessionGroup.this);
bbb3538a 144 addChild(session);
f3b33d40
BH
145 session.getConfigurationFromNode(monitor);
146 }
147 }
148
149 /**
150 * Creates a session with given session name and location.
151 *
152 * @param sessionName
153 * - a session name to create
154 * @param networkUrl
155 * - a network URL for common definition of data and control channel
156 * or null if separate definition of data and control channel
157 * @param controlUrl
158 * - a URL for control channel (networkUrl has to be null, dataUrl has to be set)
159 * @param dataUrl
160 * - a URL for data channel (networkUrl has to be null, controlUrl has to be set)
161 * @param noConsumer
162 * - a flag to indicate no consumer
163 * @param disableConsumer
164 * - a flag to disable consumer
165 * @throws ExecutionException
166 * If the command fails
167 */
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());
170 }
171
172 /**
173 * Creates a session with given session name and location.
174 *
175 * @param sessionName
176 * - a session name to create
177 * @param networkUrl
178 * - a network URL for common definition of data and control channel
179 * or null if separate definition of data and control channel
180 * @param controlUrl
181 * - a URL for control channel (networkUrl has to be null, dataUrl has to be set)
182 * @param dataUrl
183 * - a URL for data channel (networkUrl has to be null, controlUrl has to be set)
184 * @param noConsumer
185 * - a flag to indicate no consumer
186 * @param disableConsumer
187 * - a flag to disable consumer
188 * @param monitor
189 * - a progress monitor
190 * @throws ExecutionException
191 * If the command fails
192 */
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);
195
196 if (sessionInfo != null) {
197 TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
198 addChild(session);
bbb3538a
BH
199 session.getConfigurationFromNode(monitor);
200 }
201 }
202
203 /**
cfdb727a
AM
204 * Destroys a session with given session name.
205 *
206 * @param session
207 * - a session component to destroy
208 * @throws ExecutionException
209 * If the command fails
bbb3538a 210 */
cfdb727a
AM
211 public void destroySession(TraceSessionComponent session)
212 throws ExecutionException {
6503ae0f 213 destroySession(session, new NullProgressMonitor());
bbb3538a 214 }
cfdb727a 215
bbb3538a 216 /**
cfdb727a
AM
217 * Destroys a session with given session name.
218 *
219 * @param session
220 * - a session component to destroy
221 * @param monitor
222 * - a progress monitor
223 * @throws ExecutionException
224 * If the command fails
bbb3538a 225 */
cfdb727a
AM
226 public void destroySession(TraceSessionComponent session,
227 IProgressMonitor monitor) throws ExecutionException {
6503ae0f 228 getControlService().destroySession(session.getName(), monitor);
bbb3538a
BH
229 session.removeAllChildren();
230 removeChild(session);
231 }
eb1bab5b 232}
This page took 0.063018 seconds and 5 git commands to generate.