Internalize API for trace control and move control to lttng2
[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.ui.views.control.model.ISessionInfo;
18 import org.eclipse.linuxtools.internal.lttng2.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 * @return the parent target node
58 */
59 public TargetNodeComponent getTargetNode() {
60 return (TargetNodeComponent)getParent();
61 }
62
63 // ------------------------------------------------------------------------
64 // Operations
65 // ------------------------------------------------------------------------
66 /**
67 * Retrieves the sessions information from the node.
68 * @throws ExecutionException
69 */
70 public void getSessionsFromNode() throws ExecutionException {
71 getSessionsFromNode(new NullProgressMonitor());
72 }
73
74 /**
75 * Retrieves the sessions information from the node.
76 * @param monitor - a progress monitor
77 * @throws ExecutionException
78 */
79 public void getSessionsFromNode(IProgressMonitor monitor) throws ExecutionException {
80 String[] sessionNames = getControlService().getSessionNames(monitor);
81 for (int i = 0; i < sessionNames.length; i++) {
82 TraceSessionComponent session = new TraceSessionComponent(sessionNames[i], this);
83 addChild(session);
84 session.getConfigurationFromNode(monitor);
85 }
86 }
87
88 /**
89 * Creates a session with given session name and location.
90 * @param sessionName - a session name to create
91 * @param sessionPath - a path for storing the traces (use null for default)
92 * @return the session information
93 * throws ExecutionExecption
94 */
95 public void createSession(String sessionName, String sessionPath) throws ExecutionException {
96 createSession(sessionName, sessionPath, new NullProgressMonitor());
97 }
98
99 /**
100 * Creates a session with given session name and location.
101 * @param sessionName - a session name to create
102 * @param sessionPath - a path for storing the traces (use null for default)
103 * @Param monitor - a progress monitor
104 * @return the session information
105 * throws ExecutionExecption
106 */
107 public void createSession(String sessionName, String sessionPath, IProgressMonitor monitor) throws ExecutionException {
108 ISessionInfo sessionInfo = getControlService().createSession(sessionName, sessionPath, monitor);
109 if (sessionInfo != null) {
110 TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
111 addChild(session);
112 session.getConfigurationFromNode(monitor);
113 }
114 }
115
116 /**
117 * Destroys a session with given session name.
118 * @param session - a session component to destroy
119 * throws ExecutionExecption
120 */
121 public void destroySession(TraceSessionComponent session) throws ExecutionException {
122 destroySession(session, new NullProgressMonitor());
123 }
124
125 /**
126 * Destroys a session with given session name.
127 * @param session - a session component to destroy
128 * @param monitor - a progress monitor
129 * throws ExecutionExecption
130 */
131 public void destroySession(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
132 getControlService().destroySession(session.getName(), monitor);
133 session.removeAllChildren();
134 removeChild(session);
135 }
136 }
This page took 0.035541 seconds and 5 git commands to generate.