Update internal packages export in LTTng 2.0 control + update java doc
[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 * @throws ExecutionException
70 */
71 public void getSessionsFromNode() throws ExecutionException {
72 getSessionsFromNode(new NullProgressMonitor());
73 }
74
75 /**
76 * Retrieves the sessions information from the node.
77 * @param monitor - a progress monitor
78 * @throws ExecutionException
79 */
80 public void getSessionsFromNode(IProgressMonitor monitor) throws ExecutionException {
81 String[] sessionNames = getControlService().getSessionNames(monitor);
82 for (int i = 0; i < sessionNames.length; i++) {
83 TraceSessionComponent session = new TraceSessionComponent(sessionNames[i], this);
84 addChild(session);
85 session.getConfigurationFromNode(monitor);
86 }
87 }
88
89 /**
90 * Creates a session with given session name and location.
91 * @param sessionName - a session name to create
92 * @param sessionPath - a path for storing the traces (use null for default)
93 * @return the session information
94 * throws ExecutionExecption
95 */
96 public void createSession(String sessionName, String sessionPath) throws ExecutionException {
97 createSession(sessionName, sessionPath, new NullProgressMonitor());
98 }
99
100 /**
101 * Creates a session with given session name and location.
102 * @param sessionName - a session name to create
103 * @param sessionPath - a path for storing the traces (use null for default)
104 * @Param monitor - a progress monitor
105 * @return the session information
106 * throws ExecutionExecption
107 */
108 public void createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
109 ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
110 if (sessionInfo != null) {
111 TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
112 addChild(session);
113 session.getConfigurationFromNode(monitor);
114 }
115 }
116
117 /**
118 * Destroys a session with given session name.
119 * @param session - a session component to destroy
120 * throws ExecutionExecption
121 */
122 public void destroySession(TraceSessionComponent session) throws ExecutionException {
123 destroySession(session, new NullProgressMonitor());
124 }
125
126 /**
127 * Destroys a session with given session name.
128 * @param session - a session component to destroy
129 * @param monitor - a progress monitor
130 * throws ExecutionExecption
131 */
132 public void destroySession(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
133 getControlService().destroySession(session.getName(), monitor);
134 session.removeAllChildren();
135 removeChild(session);
136 }
137 }
This page took 0.034348 seconds and 6 git commands to generate.