control: Base code for profile dialog window
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / model / impl / TraceSessionGroup.java
CommitLineData
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 13package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl;
eb1bab5b 14
64a37b87
BH
15import java.util.List;
16
eb1bab5b
BH
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.core.runtime.IProgressMonitor;
19import org.eclipse.core.runtime.NullProgressMonitor;
9bc60be7
AM
20import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo;
21import org.eclipse.tracecompass.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 */
30public 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
81d5dc3a
MAL
82 /**
83 * Returns if node supports live or not
84 *
85 * @return <code>true</code> if it supports live else <code>false</code>
86 */
87 public boolean isLiveSupported() {
88 return getTargetNode().isLiveSupported();
89 }
90
eb1bab5b
BH
91 // ------------------------------------------------------------------------
92 // Operations
93 // ------------------------------------------------------------------------
94 /**
95 * Retrieves the sessions information from the node.
cfdb727a 96 *
eb1bab5b 97 * @throws ExecutionException
cfdb727a 98 * If the command fails
eb1bab5b
BH
99 */
100 public void getSessionsFromNode() throws ExecutionException {
101 getSessionsFromNode(new NullProgressMonitor());
102 }
103
104 /**
105 * Retrieves the sessions information from the node.
cfdb727a
AM
106 *
107 * @param monitor
108 * - a progress monitor
eb1bab5b 109 * @throws ExecutionException
cfdb727a 110 * If the command fails
eb1bab5b 111 */
cfdb727a
AM
112 public void getSessionsFromNode(IProgressMonitor monitor)
113 throws ExecutionException {
cbc46cc9
BH
114 List<String> sessionNames = getControlService().getSessionNames(monitor);
115 for (String sessionName : sessionNames) {
116 TraceSessionComponent session =
117 new TraceSessionComponent(sessionName, this);
eb1bab5b
BH
118 addChild(session);
119 session.getConfigurationFromNode(monitor);
120 }
121 }
bbb3538a 122
bbb3538a 123 /**
cfdb727a
AM
124 * Creates a session with given session name and location.
125 *
f7d4d450
MAL
126 * @param sessionInf
127 * the session information used to create the session
f3b33d40 128 *
f3b33d40
BH
129 * @param monitor
130 * - a progress monitor
131 * @throws ExecutionException
132 * If the command fails
133 */
f7d4d450
MAL
134 public void createSession(ISessionInfo sessionInf, IProgressMonitor monitor) throws ExecutionException {
135 ISessionInfo sessionInfo = getControlService().createSession(sessionInf, monitor);
f3b33d40
BH
136
137 if (sessionInfo != null) {
6fd3c6e9 138 TraceSessionComponent session = new TraceSessionComponent(sessionInfo, TraceSessionGroup.this);
f3b33d40 139 addChild(session);
bbb3538a
BH
140 session.getConfigurationFromNode(monitor);
141 }
142 }
143
ad9972cc
PJPG
144 /**
145 * Loads a session from a path
146 *
147 * @param sessionPath
148 *
149 * @param monitor
150 * - a progress monitor
151 * @throws ExecutionException
152 * If the command fails
153 */
154 public void loadSession(String sessionPath, IProgressMonitor monitor) throws ExecutionException {
155 getControlService().loadSession(sessionPath, monitor);
156
157
158 }
159
64a37b87
BH
160 /**
161 * Command to execute a list of commands
162 * @param monitor
163 * - a progress monitor
164 * @param commands
165 * - a list of commands to execute
166 * @throws ExecutionException
167 * If the command fails
168 */
169 public void executeCommands(IProgressMonitor monitor, List<String> commands) throws ExecutionException {
170 getControlService().runCommands(monitor, commands);
171 getTargetNode().refresh();
172 }
173
bbb3538a 174 /**
cfdb727a
AM
175 * Destroys a session with given session name.
176 *
177 * @param session
178 * - a session component to destroy
179 * @param monitor
180 * - a progress monitor
181 * @throws ExecutionException
182 * If the command fails
bbb3538a 183 */
cfdb727a
AM
184 public void destroySession(TraceSessionComponent session,
185 IProgressMonitor monitor) throws ExecutionException {
6503ae0f 186 getControlService().destroySession(session.getName(), monitor);
bbb3538a
BH
187 session.removeAllChildren();
188 removeChild(session);
189 }
eb1bab5b 190}
This page took 0.079914 seconds and 5 git commands to generate.