Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
ed902a2b | 2 | * Copyright (c) 2012, 2014 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 | **********************************************************************/ |
9bc60be7 | 13 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl; |
eb1bab5b | 14 | |
64a37b87 BH |
15 | import java.util.List; |
16 | ||
eb1bab5b BH |
17 | import org.eclipse.core.commands.ExecutionException; |
18 | import org.eclipse.core.runtime.IProgressMonitor; | |
19 | import org.eclipse.core.runtime.NullProgressMonitor; | |
f4da4c59 | 20 | import org.eclipse.jdt.annotation.Nullable; |
9bc60be7 AM |
21 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo; |
22 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
eb1bab5b BH |
23 | |
24 | /** | |
eb1bab5b BH |
25 | * <p> |
26 | * Implementation of the trace session group. | |
27 | * </p> | |
cfdb727a | 28 | * |
dbd4432d | 29 | * @author Bernd Hufmann |
eb1bab5b BH |
30 | */ |
31 | public class TraceSessionGroup extends TraceControlComponent { | |
32 | // ------------------------------------------------------------------------ | |
33 | // Constants | |
34 | // ------------------------------------------------------------------------ | |
35 | /** | |
36 | * Path to icon file for this component. | |
cfdb727a | 37 | */ |
eb1bab5b | 38 | public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$ |
cfdb727a | 39 | |
eb1bab5b BH |
40 | // ------------------------------------------------------------------------ |
41 | // Attributes | |
42 | // ------------------------------------------------------------------------ | |
cfdb727a | 43 | |
eb1bab5b BH |
44 | // ------------------------------------------------------------------------ |
45 | // Constructors | |
46 | // ------------------------------------------------------------------------ | |
47 | /** | |
cfdb727a | 48 | * Constructor |
eb1bab5b BH |
49 | * @param name - the name of the component. |
50 | * @param parent - the parent of this component. | |
cfdb727a | 51 | */ |
eb1bab5b BH |
52 | public TraceSessionGroup(String name, ITraceControlComponent parent) { |
53 | super(name, parent); | |
54 | setImage(TRACE_SESSIONS_ICON_FILE); | |
55 | } | |
bbb3538a | 56 | |
eb1bab5b BH |
57 | // ------------------------------------------------------------------------ |
58 | // Accessors | |
59 | // ------------------------------------------------------------------------ | |
60 | ||
498704b3 BH |
61 | /** |
62 | * @return the parent target node | |
63 | */ | |
64 | public TargetNodeComponent getTargetNode() { | |
65 | return (TargetNodeComponent)getParent(); | |
66 | } | |
67 | ||
f3b33d40 BH |
68 | /** |
69 | * Returns if node supports networks streaming or not | |
70 | * @return <code>true</code> if node supports filtering else <code>false</code> | |
71 | */ | |
72 | public boolean isNetworkStreamingSupported() { | |
73 | return getTargetNode().isNetworkStreamingSupported(); | |
74 | } | |
589d0d33 BH |
75 | /** |
76 | * Returns if node supports snapshots or not | |
77 | * @return <code>true</code> if it supports snapshots else <code>false</code> | |
78 | * | |
79 | */ public boolean isSnapshotSupported() { | |
80 | return getTargetNode().isSnapshotSupported(); | |
81 | } | |
f3b33d40 | 82 | |
81d5dc3a MAL |
83 | /** |
84 | * Returns if node supports live or not | |
85 | * | |
86 | * @return <code>true</code> if it supports live else <code>false</code> | |
87 | */ | |
88 | public boolean isLiveSupported() { | |
89 | return getTargetNode().isLiveSupported(); | |
90 | } | |
91 | ||
eb1bab5b BH |
92 | // ------------------------------------------------------------------------ |
93 | // Operations | |
94 | // ------------------------------------------------------------------------ | |
95 | /** | |
96 | * Retrieves the sessions information from the node. | |
cfdb727a | 97 | * |
eb1bab5b | 98 | * @throws ExecutionException |
cfdb727a | 99 | * If the command fails |
eb1bab5b BH |
100 | */ |
101 | public void getSessionsFromNode() throws ExecutionException { | |
102 | getSessionsFromNode(new NullProgressMonitor()); | |
103 | } | |
104 | ||
105 | /** | |
106 | * Retrieves the sessions information from the node. | |
cfdb727a AM |
107 | * |
108 | * @param monitor | |
109 | * - a progress monitor | |
eb1bab5b | 110 | * @throws ExecutionException |
cfdb727a | 111 | * If the command fails |
eb1bab5b | 112 | */ |
cfdb727a AM |
113 | public void getSessionsFromNode(IProgressMonitor monitor) |
114 | throws ExecutionException { | |
cbc46cc9 BH |
115 | List<String> sessionNames = getControlService().getSessionNames(monitor); |
116 | for (String sessionName : sessionNames) { | |
117 | TraceSessionComponent session = | |
118 | new TraceSessionComponent(sessionName, this); | |
eb1bab5b BH |
119 | addChild(session); |
120 | session.getConfigurationFromNode(monitor); | |
121 | } | |
122 | } | |
bbb3538a | 123 | |
bbb3538a | 124 | /** |
cfdb727a AM |
125 | * Creates a session with given session name and location. |
126 | * | |
f7d4d450 MAL |
127 | * @param sessionInf |
128 | * the session information used to create the session | |
f3b33d40 | 129 | * |
f3b33d40 BH |
130 | * @param monitor |
131 | * - a progress monitor | |
132 | * @throws ExecutionException | |
133 | * If the command fails | |
134 | */ | |
f7d4d450 MAL |
135 | public void createSession(ISessionInfo sessionInf, IProgressMonitor monitor) throws ExecutionException { |
136 | ISessionInfo sessionInfo = getControlService().createSession(sessionInf, monitor); | |
f3b33d40 BH |
137 | |
138 | if (sessionInfo != null) { | |
6fd3c6e9 | 139 | TraceSessionComponent session = new TraceSessionComponent(sessionInfo, TraceSessionGroup.this); |
f3b33d40 | 140 | addChild(session); |
bbb3538a BH |
141 | session.getConfigurationFromNode(monitor); |
142 | } | |
143 | } | |
144 | ||
64a37b87 BH |
145 | /** |
146 | * Command to execute a list of commands | |
147 | * @param monitor | |
148 | * - a progress monitor | |
149 | * @param commands | |
150 | * - a list of commands to execute | |
151 | * @throws ExecutionException | |
152 | * If the command fails | |
153 | */ | |
154 | public void executeCommands(IProgressMonitor monitor, List<String> commands) throws ExecutionException { | |
155 | getControlService().runCommands(monitor, commands); | |
156 | getTargetNode().refresh(); | |
157 | } | |
158 | ||
bbb3538a | 159 | /** |
cfdb727a AM |
160 | * Destroys a session with given session name. |
161 | * | |
162 | * @param session | |
163 | * - a session component to destroy | |
164 | * @param monitor | |
165 | * - a progress monitor | |
166 | * @throws ExecutionException | |
167 | * If the command fails | |
bbb3538a | 168 | */ |
cfdb727a AM |
169 | public void destroySession(TraceSessionComponent session, |
170 | IProgressMonitor monitor) throws ExecutionException { | |
6503ae0f | 171 | getControlService().destroySession(session.getName(), monitor); |
bbb3538a BH |
172 | session.removeAllChildren(); |
173 | removeChild(session); | |
174 | } | |
f4da4c59 BH |
175 | |
176 | /** | |
177 | * Load all or a given session. | |
178 | * | |
179 | * @param inputPath | |
180 | * a input path to load session from or null for load all from default | |
181 | * @param isForce | |
182 | * flag whether to overwrite existing or not | |
183 | * @param monitor | |
184 | * a progress monitor | |
185 | * @throws ExecutionException | |
186 | * If the command fails | |
187 | */ | |
188 | public void loadSession(@Nullable String inputPath, boolean isForce, IProgressMonitor monitor) | |
189 | throws ExecutionException { | |
190 | getControlService().loadSession(inputPath, isForce, monitor); | |
191 | getTargetNode().refresh(); | |
192 | } | |
eb1bab5b | 193 | } |