Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
a30e79fe | 2 | * Copyright (c) 2012, 2013 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 | 10 | * Bernd Hufmann - Initial API and implementation |
a30e79fe | 11 | * Bernd Hufmann - Updated for support of LTTng Tools 2.1 |
eb1bab5b | 12 | **********************************************************************/ |
115b4a01 | 13 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
eb1bab5b BH |
14 | |
15 | import org.eclipse.core.commands.ExecutionException; | |
16 | import org.eclipse.core.runtime.IProgressMonitor; | |
17 | import org.eclipse.core.runtime.NullProgressMonitor; | |
9315aeee | 18 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo; |
115b4a01 | 19 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
eb1bab5b BH |
20 | |
21 | /** | |
eb1bab5b BH |
22 | * <p> |
23 | * Implementation of the trace session group. | |
24 | * </p> | |
cfdb727a | 25 | * |
dbd4432d | 26 | * @author Bernd Hufmann |
eb1bab5b BH |
27 | */ |
28 | public class TraceSessionGroup extends TraceControlComponent { | |
29 | // ------------------------------------------------------------------------ | |
30 | // Constants | |
31 | // ------------------------------------------------------------------------ | |
32 | /** | |
33 | * Path to icon file for this component. | |
cfdb727a | 34 | */ |
eb1bab5b | 35 | public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$ |
cfdb727a | 36 | |
eb1bab5b BH |
37 | // ------------------------------------------------------------------------ |
38 | // Attributes | |
39 | // ------------------------------------------------------------------------ | |
cfdb727a | 40 | |
eb1bab5b BH |
41 | // ------------------------------------------------------------------------ |
42 | // Constructors | |
43 | // ------------------------------------------------------------------------ | |
44 | /** | |
cfdb727a | 45 | * Constructor |
eb1bab5b BH |
46 | * @param name - the name of the component. |
47 | * @param parent - the parent of this component. | |
cfdb727a | 48 | */ |
eb1bab5b BH |
49 | public TraceSessionGroup(String name, ITraceControlComponent parent) { |
50 | super(name, parent); | |
51 | setImage(TRACE_SESSIONS_ICON_FILE); | |
52 | } | |
bbb3538a | 53 | |
eb1bab5b BH |
54 | // ------------------------------------------------------------------------ |
55 | // Accessors | |
56 | // ------------------------------------------------------------------------ | |
57 | ||
498704b3 BH |
58 | /** |
59 | * @return the parent target node | |
60 | */ | |
61 | public TargetNodeComponent getTargetNode() { | |
62 | return (TargetNodeComponent)getParent(); | |
63 | } | |
64 | ||
f3b33d40 BH |
65 | /** |
66 | * Returns if node supports networks streaming or not | |
67 | * @return <code>true</code> if node supports filtering else <code>false</code> | |
68 | */ | |
69 | public boolean isNetworkStreamingSupported() { | |
70 | return getTargetNode().isNetworkStreamingSupported(); | |
71 | } | |
589d0d33 BH |
72 | /** |
73 | * Returns if node supports snapshots or not | |
74 | * @return <code>true</code> if it supports snapshots else <code>false</code> | |
75 | * | |
76 | */ public boolean isSnapshotSupported() { | |
77 | return getTargetNode().isSnapshotSupported(); | |
78 | } | |
f3b33d40 | 79 | |
eb1bab5b BH |
80 | // ------------------------------------------------------------------------ |
81 | // Operations | |
82 | // ------------------------------------------------------------------------ | |
83 | /** | |
84 | * Retrieves the sessions information from the node. | |
cfdb727a | 85 | * |
eb1bab5b | 86 | * @throws ExecutionException |
cfdb727a | 87 | * If the command fails |
eb1bab5b BH |
88 | */ |
89 | public void getSessionsFromNode() throws ExecutionException { | |
90 | getSessionsFromNode(new NullProgressMonitor()); | |
91 | } | |
92 | ||
93 | /** | |
94 | * Retrieves the sessions information from the node. | |
cfdb727a AM |
95 | * |
96 | * @param monitor | |
97 | * - a progress monitor | |
eb1bab5b | 98 | * @throws ExecutionException |
cfdb727a | 99 | * If the command fails |
eb1bab5b | 100 | */ |
cfdb727a AM |
101 | public void getSessionsFromNode(IProgressMonitor monitor) |
102 | throws ExecutionException { | |
eb1bab5b BH |
103 | String[] sessionNames = getControlService().getSessionNames(monitor); |
104 | for (int i = 0; i < sessionNames.length; i++) { | |
cfdb727a AM |
105 | TraceSessionComponent session = new TraceSessionComponent( |
106 | sessionNames[i], this); | |
eb1bab5b BH |
107 | addChild(session); |
108 | session.getConfigurationFromNode(monitor); | |
109 | } | |
110 | } | |
bbb3538a | 111 | |
bbb3538a | 112 | /** |
cfdb727a AM |
113 | * Creates a session with given session name and location. |
114 | * | |
115 | * @param sessionName | |
116 | * - a session name to create | |
117 | * @param sessionPath | |
118 | * - a path for storing the traces (use null for default) | |
589d0d33 BH |
119 | * @param isSnapshot |
120 | * - true for snapshot session else false | |
cfdb727a AM |
121 | * @param monitor |
122 | * - a progress monitor | |
123 | * @throws ExecutionException | |
124 | * If the command fails | |
bbb3538a | 125 | */ |
589d0d33 BH |
126 | public void createSession(String sessionName, String sessionPath, boolean isSnapshot, IProgressMonitor monitor) throws ExecutionException { |
127 | ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, isSnapshot, monitor); | |
f3b33d40 | 128 | |
bbb3538a | 129 | if (sessionInfo != null) { |
cfdb727a AM |
130 | TraceSessionComponent session = new TraceSessionComponent( |
131 | sessionInfo.getName(), TraceSessionGroup.this); | |
bbb3538a | 132 | addChild(session); |
f3b33d40 BH |
133 | session.getConfigurationFromNode(monitor); |
134 | } | |
135 | } | |
136 | ||
f3b33d40 BH |
137 | /** |
138 | * Creates a session with given session name and location. | |
139 | * | |
140 | * @param sessionName | |
141 | * - a session name to create | |
142 | * @param networkUrl | |
143 | * - a network URL for common definition of data and control channel | |
144 | * or null if separate definition of data and control channel | |
145 | * @param controlUrl | |
146 | * - a URL for control channel (networkUrl has to be null, dataUrl has to be set) | |
147 | * @param dataUrl | |
148 | * - a URL for data channel (networkUrl has to be null, controlUrl has to be set) | |
589d0d33 BH |
149 | * @param isSnapshot |
150 | * - true for snapshot session else false | |
f3b33d40 BH |
151 | * @param monitor |
152 | * - a progress monitor | |
153 | * @throws ExecutionException | |
154 | * If the command fails | |
155 | */ | |
589d0d33 BH |
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); | |
f3b33d40 BH |
158 | |
159 | if (sessionInfo != null) { | |
160 | TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this); | |
161 | addChild(session); | |
bbb3538a BH |
162 | session.getConfigurationFromNode(monitor); |
163 | } | |
164 | } | |
165 | ||
bbb3538a | 166 | /** |
cfdb727a AM |
167 | * Destroys a session with given session name. |
168 | * | |
169 | * @param session | |
170 | * - a session component to destroy | |
171 | * @param monitor | |
172 | * - a progress monitor | |
173 | * @throws ExecutionException | |
174 | * If the command fails | |
bbb3538a | 175 | */ |
cfdb727a AM |
176 | public void destroySession(TraceSessionComponent session, |
177 | IProgressMonitor monitor) throws ExecutionException { | |
6503ae0f | 178 | getControlService().destroySession(session.getName(), monitor); |
bbb3538a BH |
179 | session.removeAllChildren(); |
180 | removeChild(session); | |
181 | } | |
eb1bab5b | 182 | } |