Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / 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.lttng.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.lttng.ui.views.control.model.ISessionInfo;
18 import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent;
19
20 /**
21 * <b><u>TraceSessionGroup</u></b>
22 * <p>
23 * Implementation of the trace session group.
24 * </p>
25 */
26 public class TraceSessionGroup extends TraceControlComponent {
27 // ------------------------------------------------------------------------
28 // Constants
29 // ------------------------------------------------------------------------
30 /**
31 * Path to icon file for this component.
32 */
33 public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$
34
35 // ------------------------------------------------------------------------
36 // Attributes
37 // ------------------------------------------------------------------------
38
39 // ------------------------------------------------------------------------
40 // Constructors
41 // ------------------------------------------------------------------------
42 /**
43 * Constructor
44 * @param name - the name of the component.
45 * @param parent - the parent of this component.
46 */
47 public TraceSessionGroup(String name, ITraceControlComponent parent) {
48 super(name, parent);
49 setImage(TRACE_SESSIONS_ICON_FILE);
50 }
51
52 // ------------------------------------------------------------------------
53 // Accessors
54 // ------------------------------------------------------------------------
55
56 // ------------------------------------------------------------------------
57 // Operations
58 // ------------------------------------------------------------------------
59 /**
60 * Retrieves the sessions information from the node.
61 * @throws ExecutionException
62 */
63 public void getSessionsFromNode() throws ExecutionException {
64 getSessionsFromNode(new NullProgressMonitor());
65 }
66
67 /**
68 * Retrieves the sessions information from the node.
69 * @param monitor - a progress monitor
70 * @throws ExecutionException
71 */
72 public void getSessionsFromNode(IProgressMonitor monitor) throws ExecutionException {
73 String[] sessionNames = getControlService().getSessionNames(monitor);
74 for (int i = 0; i < sessionNames.length; i++) {
75 TraceSessionComponent session = new TraceSessionComponent(sessionNames[i], this);
76 addChild(session);
77 session.getConfigurationFromNode(monitor);
78 }
79 }
80
81 /**
82 * Creates a session with given session name and location.
83 * @param sessionName - a session name to create
84 * @param sessionPath - a path for storing the traces (use null for default)
85 * @return the session information
86 * throws ExecutionExecption
87 */
88 public void createSession(final String sessionName, final String sessionPath) throws ExecutionException {
89 createSession(sessionName, sessionPath, new NullProgressMonitor());
90 }
91
92 /**
93 * Creates a session with given session name and location.
94 * @param sessionName - a session name to create
95 * @param sessionPath - a path for storing the traces (use null for default)
96 * @Param monitor - a progress monitor
97 * @return the session information
98 * throws ExecutionExecption
99 */
100 public void createSession(final String sessionName, final String sessionPath, IProgressMonitor monitor) throws ExecutionException {
101 ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
102 if (sessionInfo != null) {
103 TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
104 addChild(session);
105 session.getConfigurationFromNode(monitor);
106 }
107 }
108
109 /**
110 * Destroys a session with given session name.
111 * @param sessionName - a session name to destroy
112 * throws ExecutionExecption
113 */
114 public void destroySession(final String sessionName) throws ExecutionException {
115 destroySession(sessionName, new NullProgressMonitor());
116 }
117
118 /**
119 * Destroys a session with given session name.
120 * @param sessionName - a session name to destroy
121 * @param monitor - a progress monitor
122 * throws ExecutionExecption
123 */
124 public void destroySession(final String sessionName, IProgressMonitor monitor) throws ExecutionException {
125 getControlService().destroySession(sessionName, monitor);
126 ITraceControlComponent session = getChild(sessionName);
127 session.removeAllChildren();
128 removeChild(session);
129 }
130 }
This page took 0.035134 seconds and 6 git commands to generate.