1 /**********************************************************************
2 * Copyright (c) 2012 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
;
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
;
22 * Implementation of the trace session group.
25 * @author Bernd Hufmann
27 public class TraceSessionGroup
extends TraceControlComponent
{
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
32 * Path to icon file for this component.
34 public static final String TRACE_SESSIONS_ICON_FILE
= "icons/obj16/sessions.gif"; //$NON-NLS-1$
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
45 * @param name - the name of the component.
46 * @param parent - the parent of this component.
48 public TraceSessionGroup(String name
, ITraceControlComponent parent
) {
50 setImage(TRACE_SESSIONS_ICON_FILE
);
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 * @return the parent target node
60 public TargetNodeComponent
getTargetNode() {
61 return (TargetNodeComponent
)getParent();
64 // ------------------------------------------------------------------------
66 // ------------------------------------------------------------------------
68 * Retrieves the sessions information from the node.
70 * @throws ExecutionException
71 * If the command fails
73 public void getSessionsFromNode() throws ExecutionException
{
74 getSessionsFromNode(new NullProgressMonitor());
78 * Retrieves the sessions information from the node.
81 * - a progress monitor
82 * @throws ExecutionException
83 * If the command fails
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);
92 session
.getConfigurationFromNode(monitor
);
97 * Creates a session with given session name and location.
100 * - a session name to create
102 * - a path for storing the traces (use null for default)
103 * @throws ExecutionException
104 * If the command fails
106 public void createSession(String sessionName
, String sessionPath
)
107 throws ExecutionException
{
108 createSession(sessionName
, sessionPath
, new NullProgressMonitor());
112 * Creates a session with given session name and location.
115 * - a session name to create
117 * - a path for storing the traces (use null for default)
119 * - a progress monitor
120 * @throws ExecutionException
121 * If the command fails
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);
131 session
.getConfigurationFromNode(monitor
);
136 * Destroys a session with given session name.
139 * - a session component to destroy
140 * @throws ExecutionException
141 * If the command fails
143 public void destroySession(TraceSessionComponent session
)
144 throws ExecutionException
{
145 destroySession(session
, new NullProgressMonitor());
149 * Destroys a session with given session name.
152 * - a session component to destroy
154 * - a progress monitor
155 * @throws ExecutionException
156 * If the command fails
158 public void destroySession(TraceSessionComponent session
,
159 IProgressMonitor monitor
) throws ExecutionException
{
160 getControlService().destroySession(session
.getName(), monitor
);
161 session
.removeAllChildren();
162 removeChild(session
);