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 | **********************************************************************/ |
8e8c0226 | 13 | package org.eclipse.linuxtools.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; | |
8e8c0226 AM |
20 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.ISessionInfo; |
21 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
eb1bab5b BH |
22 | |
23 | /** | |
eb1bab5b BH |
24 | * <p> |
25 | * Implementation of the trace session group. | |
26 | * </p> | |
cfdb727a | 27 | * |
dbd4432d | 28 | * @author Bernd Hufmann |
eb1bab5b BH |
29 | */ |
30 | public class TraceSessionGroup extends TraceControlComponent { | |
31 | // ------------------------------------------------------------------------ | |
32 | // Constants | |
33 | // ------------------------------------------------------------------------ | |
34 | /** | |
35 | * Path to icon file for this component. | |
cfdb727a | 36 | */ |
eb1bab5b | 37 | public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$ |
cfdb727a | 38 | |
eb1bab5b BH |
39 | // ------------------------------------------------------------------------ |
40 | // Attributes | |
41 | // ------------------------------------------------------------------------ | |
cfdb727a | 42 | |
eb1bab5b BH |
43 | // ------------------------------------------------------------------------ |
44 | // Constructors | |
45 | // ------------------------------------------------------------------------ | |
46 | /** | |
cfdb727a | 47 | * Constructor |
eb1bab5b BH |
48 | * @param name - the name of the component. |
49 | * @param parent - the parent of this component. | |
cfdb727a | 50 | */ |
eb1bab5b BH |
51 | public TraceSessionGroup(String name, ITraceControlComponent parent) { |
52 | super(name, parent); | |
53 | setImage(TRACE_SESSIONS_ICON_FILE); | |
54 | } | |
bbb3538a | 55 | |
eb1bab5b BH |
56 | // ------------------------------------------------------------------------ |
57 | // Accessors | |
58 | // ------------------------------------------------------------------------ | |
59 | ||
498704b3 BH |
60 | /** |
61 | * @return the parent target node | |
62 | */ | |
63 | public TargetNodeComponent getTargetNode() { | |
64 | return (TargetNodeComponent)getParent(); | |
65 | } | |
66 | ||
f3b33d40 BH |
67 | /** |
68 | * Returns if node supports networks streaming or not | |
69 | * @return <code>true</code> if node supports filtering else <code>false</code> | |
70 | */ | |
71 | public boolean isNetworkStreamingSupported() { | |
72 | return getTargetNode().isNetworkStreamingSupported(); | |
73 | } | |
589d0d33 BH |
74 | /** |
75 | * Returns if node supports snapshots or not | |
76 | * @return <code>true</code> if it supports snapshots else <code>false</code> | |
77 | * | |
78 | */ public boolean isSnapshotSupported() { | |
79 | return getTargetNode().isSnapshotSupported(); | |
80 | } | |
f3b33d40 | 81 | |
eb1bab5b BH |
82 | // ------------------------------------------------------------------------ |
83 | // Operations | |
84 | // ------------------------------------------------------------------------ | |
85 | /** | |
86 | * Retrieves the sessions information from the node. | |
cfdb727a | 87 | * |
eb1bab5b | 88 | * @throws ExecutionException |
cfdb727a | 89 | * If the command fails |
eb1bab5b BH |
90 | */ |
91 | public void getSessionsFromNode() throws ExecutionException { | |
92 | getSessionsFromNode(new NullProgressMonitor()); | |
93 | } | |
94 | ||
95 | /** | |
96 | * Retrieves the sessions information from the node. | |
cfdb727a AM |
97 | * |
98 | * @param monitor | |
99 | * - a progress monitor | |
eb1bab5b | 100 | * @throws ExecutionException |
cfdb727a | 101 | * If the command fails |
eb1bab5b | 102 | */ |
cfdb727a AM |
103 | public void getSessionsFromNode(IProgressMonitor monitor) |
104 | throws ExecutionException { | |
eb1bab5b BH |
105 | String[] sessionNames = getControlService().getSessionNames(monitor); |
106 | for (int i = 0; i < sessionNames.length; i++) { | |
cfdb727a AM |
107 | TraceSessionComponent session = new TraceSessionComponent( |
108 | sessionNames[i], this); | |
eb1bab5b BH |
109 | addChild(session); |
110 | session.getConfigurationFromNode(monitor); | |
111 | } | |
112 | } | |
bbb3538a | 113 | |
bbb3538a | 114 | /** |
cfdb727a AM |
115 | * Creates a session with given session name and location. |
116 | * | |
f7d4d450 MAL |
117 | * @param sessionInf |
118 | * the session information used to create the session | |
f3b33d40 | 119 | * |
f3b33d40 BH |
120 | * @param monitor |
121 | * - a progress monitor | |
122 | * @throws ExecutionException | |
123 | * If the command fails | |
124 | */ | |
f7d4d450 MAL |
125 | public void createSession(ISessionInfo sessionInf, IProgressMonitor monitor) throws ExecutionException { |
126 | ISessionInfo sessionInfo = getControlService().createSession(sessionInf, monitor); | |
f3b33d40 BH |
127 | |
128 | if (sessionInfo != null) { | |
129 | TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this); | |
130 | addChild(session); | |
bbb3538a BH |
131 | session.getConfigurationFromNode(monitor); |
132 | } | |
133 | } | |
134 | ||
64a37b87 BH |
135 | /** |
136 | * Command to execute a list of commands | |
137 | * @param monitor | |
138 | * - a progress monitor | |
139 | * @param commands | |
140 | * - a list of commands to execute | |
141 | * @throws ExecutionException | |
142 | * If the command fails | |
143 | */ | |
144 | public void executeCommands(IProgressMonitor monitor, List<String> commands) throws ExecutionException { | |
145 | getControlService().runCommands(monitor, commands); | |
146 | getTargetNode().refresh(); | |
147 | } | |
148 | ||
bbb3538a | 149 | /** |
cfdb727a AM |
150 | * Destroys a session with given session name. |
151 | * | |
152 | * @param session | |
153 | * - a session component to destroy | |
154 | * @param monitor | |
155 | * - a progress monitor | |
156 | * @throws ExecutionException | |
157 | * If the command fails | |
bbb3538a | 158 | */ |
cfdb727a AM |
159 | public void destroySession(TraceSessionComponent session, |
160 | IProgressMonitor monitor) throws ExecutionException { | |
6503ae0f | 161 | getControlService().destroySession(session.getName(), monitor); |
bbb3538a BH |
162 | session.removeAllChildren(); |
163 | removeChild(session); | |
164 | } | |
eb1bab5b | 165 | } |