Copyright header update, 2015 edition
[deliverable/tracecompass.git] / 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 {
eb1bab5b
BH
114 String[] sessionNames = getControlService().getSessionNames(monitor);
115 for (int i = 0; i < sessionNames.length; i++) {
cfdb727a
AM
116 TraceSessionComponent session = new TraceSessionComponent(
117 sessionNames[i], 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
64a37b87
BH
144 /**
145 * Command to execute a list of commands
146 * @param monitor
147 * - a progress monitor
148 * @param commands
149 * - a list of commands to execute
150 * @throws ExecutionException
151 * If the command fails
152 */
153 public void executeCommands(IProgressMonitor monitor, List<String> commands) throws ExecutionException {
154 getControlService().runCommands(monitor, commands);
155 getTargetNode().refresh();
156 }
157
bbb3538a 158 /**
cfdb727a
AM
159 * Destroys a session with given session name.
160 *
161 * @param session
162 * - a session component to destroy
163 * @param monitor
164 * - a progress monitor
165 * @throws ExecutionException
166 * If the command fails
bbb3538a 167 */
cfdb727a
AM
168 public void destroySession(TraceSessionComponent session,
169 IProgressMonitor monitor) throws ExecutionException {
6503ae0f 170 getControlService().destroySession(session.getName(), monitor);
bbb3538a
BH
171 session.removeAllChildren();
172 removeChild(session);
173 }
eb1bab5b 174}
This page took 0.063944 seconds and 5 git commands to generate.