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
.ui
.views
.control
.model
.ISessionInfo
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.ITraceControlComponent
;
21 * <b><u>TraceSessionGroup</u></b>
23 * Implementation of the trace session group.
26 public class TraceSessionGroup
extends TraceControlComponent
{
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 * Path to icon file for this component.
33 public static final String TRACE_SESSIONS_ICON_FILE
= "icons/obj16/sessions.gif"; //$NON-NLS-1$
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 * @param name - the name of the component.
45 * @param parent - the parent of this component.
47 public TraceSessionGroup(String name
, ITraceControlComponent parent
) {
49 setImage(TRACE_SESSIONS_ICON_FILE
);
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
57 * @return the parent target node
59 public TargetNodeComponent
getTargetNode() {
60 return (TargetNodeComponent
)getParent();
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
67 * Retrieves the sessions information from the node.
68 * @throws ExecutionException
70 public void getSessionsFromNode() throws ExecutionException
{
71 getSessionsFromNode(new NullProgressMonitor());
75 * Retrieves the sessions information from the node.
76 * @param monitor - a progress monitor
77 * @throws ExecutionException
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);
84 session
.getConfigurationFromNode(monitor
);
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
95 public void createSession(String sessionName
, String sessionPath
) throws ExecutionException
{
96 createSession(sessionName
, sessionPath
, new NullProgressMonitor());
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
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);
112 session
.getConfigurationFromNode(monitor
);
117 * Destroys a session with given session name.
118 * @param session - a session component to destroy
119 * throws ExecutionExecption
121 public void destroySession(TraceSessionComponent session
) throws ExecutionException
{
122 destroySession(session
, new NullProgressMonitor());
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
131 public void destroySession(TraceSessionComponent session
, IProgressMonitor monitor
) throws ExecutionException
{
132 getControlService().destroySession(session
.getName(), monitor
);
133 session
.removeAllChildren();
134 removeChild(session
);