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.
69 * @throws ExecutionException
71 public void getSessionsFromNode() throws ExecutionException
{
72 getSessionsFromNode(new NullProgressMonitor());
76 * Retrieves the sessions information from the node.
77 * @param monitor - a progress monitor
78 * @throws ExecutionException
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);
85 session
.getConfigurationFromNode(monitor
);
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
96 public void createSession(String sessionName
, String sessionPath
) throws ExecutionException
{
97 createSession(sessionName
, sessionPath
, new NullProgressMonitor());
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
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);
113 session
.getConfigurationFromNode(monitor
);
118 * Destroys a session with given session name.
119 * @param session - a session component to destroy
120 * throws ExecutionExecption
122 public void destroySession(TraceSessionComponent session
) throws ExecutionException
{
123 destroySession(session
, new NullProgressMonitor());
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
132 public void destroySession(TraceSessionComponent session
, IProgressMonitor monitor
) throws ExecutionException
{
133 getControlService().destroySession(session
.getName(), monitor
);
134 session
.removeAllChildren();
135 removeChild(session
);