lttng: Fix Javadoc and formatting in lttng2.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceSessionGroup.java
1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
13
14 import org.eclipse.core.commands.ExecutionException;
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.core.runtime.NullProgressMonitor;
17 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
18 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
19
20 /**
21 * <p>
22 * Implementation of the trace session group.
23 * </p>
24 *
25 * @author Bernd Hufmann
26 */
27 public class TraceSessionGroup extends TraceControlComponent {
28 // ------------------------------------------------------------------------
29 // Constants
30 // ------------------------------------------------------------------------
31 /**
32 * Path to icon file for this component.
33 */
34 public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$
35
36 // ------------------------------------------------------------------------
37 // Attributes
38 // ------------------------------------------------------------------------
39
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43 /**
44 * Constructor
45 * @param name - the name of the component.
46 * @param parent - the parent of this component.
47 */
48 public TraceSessionGroup(String name, ITraceControlComponent parent) {
49 super(name, parent);
50 setImage(TRACE_SESSIONS_ICON_FILE);
51 }
52
53 // ------------------------------------------------------------------------
54 // Accessors
55 // ------------------------------------------------------------------------
56
57 /**
58 * @return the parent target node
59 */
60 public TargetNodeComponent getTargetNode() {
61 return (TargetNodeComponent)getParent();
62 }
63
64 // ------------------------------------------------------------------------
65 // Operations
66 // ------------------------------------------------------------------------
67 /**
68 * Retrieves the sessions information from the node.
69 *
70 * @throws ExecutionException
71 * If the command fails
72 */
73 public void getSessionsFromNode() throws ExecutionException {
74 getSessionsFromNode(new NullProgressMonitor());
75 }
76
77 /**
78 * Retrieves the sessions information from the node.
79 *
80 * @param monitor
81 * - a progress monitor
82 * @throws ExecutionException
83 * If the command fails
84 */
85 public void getSessionsFromNode(IProgressMonitor monitor)
86 throws ExecutionException {
87 String[] sessionNames = getControlService().getSessionNames(monitor);
88 for (int i = 0; i < sessionNames.length; i++) {
89 TraceSessionComponent session = new TraceSessionComponent(
90 sessionNames[i], this);
91 addChild(session);
92 session.getConfigurationFromNode(monitor);
93 }
94 }
95
96 /**
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
105 */
106 public void createSession(String sessionName, String sessionPath)
107 throws ExecutionException {
108 createSession(sessionName, sessionPath, new NullProgressMonitor());
109 }
110
111 /**
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
122 */
123 public void createSession(String sessionName, String sessionPath,
124 IProgressMonitor monitor) throws ExecutionException {
125 ISessionInfo sessionInfo = getControlService().createSession(
126 sessionName, sessionPath, monitor);
127 if (sessionInfo != null) {
128 TraceSessionComponent session = new TraceSessionComponent(
129 sessionInfo.getName(), TraceSessionGroup.this);
130 addChild(session);
131 session.getConfigurationFromNode(monitor);
132 }
133 }
134
135 /**
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
142 */
143 public void destroySession(TraceSessionComponent session)
144 throws ExecutionException {
145 destroySession(session, new NullProgressMonitor());
146 }
147
148 /**
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
157 */
158 public void destroySession(TraceSessionComponent session,
159 IProgressMonitor monitor) throws ExecutionException {
160 getControlService().destroySession(session.getName(), monitor);
161 session.removeAllChildren();
162 removeChild(session);
163 }
164 }
This page took 0.034992 seconds and 5 git commands to generate.