ctf: Re-enable the CTF parser unit tests
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceSessionGroup.java
CommitLineData
eb1bab5b
BH
1/**********************************************************************
2 * Copyright (c) 2012 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
BH
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
115b4a01 12package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
eb1bab5b
BH
13
14import org.eclipse.core.commands.ExecutionException;
15import org.eclipse.core.runtime.IProgressMonitor;
16import org.eclipse.core.runtime.NullProgressMonitor;
9315aeee 17import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
115b4a01 18import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
eb1bab5b
BH
19
20/**
eb1bab5b
BH
21 * <p>
22 * Implementation of the trace session group.
23 * </p>
cfdb727a 24 *
dbd4432d 25 * @author Bernd Hufmann
eb1bab5b
BH
26 */
27public class TraceSessionGroup extends TraceControlComponent {
28 // ------------------------------------------------------------------------
29 // Constants
30 // ------------------------------------------------------------------------
31 /**
32 * Path to icon file for this component.
cfdb727a 33 */
eb1bab5b 34 public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$
cfdb727a 35
eb1bab5b
BH
36 // ------------------------------------------------------------------------
37 // Attributes
38 // ------------------------------------------------------------------------
cfdb727a 39
eb1bab5b
BH
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43 /**
cfdb727a 44 * Constructor
eb1bab5b
BH
45 * @param name - the name of the component.
46 * @param parent - the parent of this component.
cfdb727a 47 */
eb1bab5b
BH
48 public TraceSessionGroup(String name, ITraceControlComponent parent) {
49 super(name, parent);
50 setImage(TRACE_SESSIONS_ICON_FILE);
51 }
bbb3538a 52
eb1bab5b
BH
53 // ------------------------------------------------------------------------
54 // Accessors
55 // ------------------------------------------------------------------------
56
498704b3
BH
57 /**
58 * @return the parent target node
59 */
60 public TargetNodeComponent getTargetNode() {
61 return (TargetNodeComponent)getParent();
62 }
63
eb1bab5b
BH
64 // ------------------------------------------------------------------------
65 // Operations
66 // ------------------------------------------------------------------------
67 /**
68 * Retrieves the sessions information from the node.
cfdb727a 69 *
eb1bab5b 70 * @throws ExecutionException
cfdb727a 71 * If the command fails
eb1bab5b
BH
72 */
73 public void getSessionsFromNode() throws ExecutionException {
74 getSessionsFromNode(new NullProgressMonitor());
75 }
76
77 /**
78 * Retrieves the sessions information from the node.
cfdb727a
AM
79 *
80 * @param monitor
81 * - a progress monitor
eb1bab5b 82 * @throws ExecutionException
cfdb727a 83 * If the command fails
eb1bab5b 84 */
cfdb727a
AM
85 public void getSessionsFromNode(IProgressMonitor monitor)
86 throws ExecutionException {
eb1bab5b
BH
87 String[] sessionNames = getControlService().getSessionNames(monitor);
88 for (int i = 0; i < sessionNames.length; i++) {
cfdb727a
AM
89 TraceSessionComponent session = new TraceSessionComponent(
90 sessionNames[i], this);
eb1bab5b
BH
91 addChild(session);
92 session.getConfigurationFromNode(monitor);
93 }
94 }
bbb3538a
BH
95
96 /**
cfdb727a
AM
97 * Creates a session with given session name and location.
98 *
99 * @param sessionName
100 * - a session name to create
101 * @param sessionPath
102 * - a path for storing the traces (use null for default)
103 * @throws ExecutionException
104 * If the command fails
bbb3538a 105 */
cfdb727a
AM
106 public void createSession(String sessionName, String sessionPath)
107 throws ExecutionException {
bbb3538a
BH
108 createSession(sessionName, sessionPath, new NullProgressMonitor());
109 }
cfdb727a 110
bbb3538a 111 /**
cfdb727a
AM
112 * Creates a session with given session name and location.
113 *
114 * @param sessionName
115 * - a session name to create
116 * @param sessionPath
117 * - a path for storing the traces (use null for default)
118 * @param monitor
119 * - a progress monitor
120 * @throws ExecutionException
121 * If the command fails
bbb3538a 122 */
cfdb727a
AM
123 public void createSession(String sessionName, String sessionPath,
124 IProgressMonitor monitor) throws ExecutionException {
125 ISessionInfo sessionInfo = getControlService().createSession(
126 sessionName, sessionPath, monitor);
bbb3538a 127 if (sessionInfo != null) {
cfdb727a
AM
128 TraceSessionComponent session = new TraceSessionComponent(
129 sessionInfo.getName(), TraceSessionGroup.this);
bbb3538a
BH
130 addChild(session);
131 session.getConfigurationFromNode(monitor);
132 }
133 }
134
135 /**
cfdb727a
AM
136 * Destroys a session with given session name.
137 *
138 * @param session
139 * - a session component to destroy
140 * @throws ExecutionException
141 * If the command fails
bbb3538a 142 */
cfdb727a
AM
143 public void destroySession(TraceSessionComponent session)
144 throws ExecutionException {
6503ae0f 145 destroySession(session, new NullProgressMonitor());
bbb3538a 146 }
cfdb727a 147
bbb3538a 148 /**
cfdb727a
AM
149 * Destroys a session with given session name.
150 *
151 * @param session
152 * - a session component to destroy
153 * @param monitor
154 * - a progress monitor
155 * @throws ExecutionException
156 * If the command fails
bbb3538a 157 */
cfdb727a
AM
158 public void destroySession(TraceSessionComponent session,
159 IProgressMonitor monitor) throws ExecutionException {
6503ae0f 160 getControlService().destroySession(session.getName(), monitor);
bbb3538a
BH
161 session.removeAllChildren();
162 removeChild(session);
163 }
eb1bab5b 164}
This page took 0.039313 seconds and 5 git commands to generate.