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
1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
13
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;
19
20 /**
21 * <p>
22 * Implementation of the trace session group.
23 * </p>
24 *
25 * @author Bernd Hufmann
26 */
27 public class TraceSessionGroup extends TraceControlComponent {
28 // ------------------------------------------------------------------------
29 // Constants
30 // ------------------------------------------------------------------------
31 /**
32 * Path to icon file for this component.
33 */
34 public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$
35
36 // ------------------------------------------------------------------------
37 // Attributes
38 // ------------------------------------------------------------------------
39
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43 /**
44 * Constructor
45 * @param name - the name of the component.
46 * @param parent - the parent of this component.
47 */
48 public TraceSessionGroup(String name, ITraceControlComponent parent) {
49 super(name, parent);
50 setImage(TRACE_SESSIONS_ICON_FILE);
51 }
52
53 // ------------------------------------------------------------------------
54 // Accessors
55 // ------------------------------------------------------------------------
56
57 /**
58 * @return the parent target node
59 */
60 public TargetNodeComponent getTargetNode() {
61 return (TargetNodeComponent)getParent();
62 }
63
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
72 // ------------------------------------------------------------------------
73 // Operations
74 // ------------------------------------------------------------------------
75 /**
76 * Retrieves the sessions information from the node.
77 *
78 * @throws ExecutionException
79 * If the command fails
80 */
81 public void getSessionsFromNode() throws ExecutionException {
82 getSessionsFromNode(new NullProgressMonitor());
83 }
84
85 /**
86 * Retrieves the sessions information from the node.
87 *
88 * @param monitor
89 * - a progress monitor
90 * @throws ExecutionException
91 * If the command fails
92 */
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);
99 addChild(session);
100 session.getConfigurationFromNode(monitor);
101 }
102 }
103
104 /**
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)
111 * @param noConsumer
112 * - a flag to indicate no consumer
113 * @param disableConsumer
114 * - a flag to disable consumer
115 * @throws ExecutionException
116 * If the command fails
117 */
118 public void createSession(String sessionName, String sessionPath, boolean noConsumer, boolean disableConsumer) throws ExecutionException {
119 createSession(sessionName, sessionPath, noConsumer, disableConsumer, new NullProgressMonitor());
120 }
121
122 /**
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)
129 * @param noConsumer
130 * - a flag to indicate no consumer
131 * @param disableConsumer
132 * - a flag to disable consumer
133 * @param monitor
134 * - a progress monitor
135 * @throws ExecutionException
136 * If the command fails
137 */
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
141 if (sessionInfo != null) {
142 TraceSessionComponent session = new TraceSessionComponent(
143 sessionInfo.getName(), TraceSessionGroup.this);
144 addChild(session);
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);
199 session.getConfigurationFromNode(monitor);
200 }
201 }
202
203 /**
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
210 */
211 public void destroySession(TraceSessionComponent session)
212 throws ExecutionException {
213 destroySession(session, new NullProgressMonitor());
214 }
215
216 /**
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
225 */
226 public void destroySession(TraceSessionComponent session,
227 IProgressMonitor monitor) throws ExecutionException {
228 getControlService().destroySession(session.getName(), monitor);
229 session.removeAllChildren();
230 removeChild(session);
231 }
232 }
This page took 0.043238 seconds and 5 git commands to generate.