fafa425a26715d7613764587aadb52f38f092141
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.ui / src / org / eclipse / linuxtools / internal / lttng2 / control / ui / views / model / impl / TraceSessionGroup.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl;
14
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.core.runtime.NullProgressMonitor;
18 import org.eclipse.linuxtools.internal.lttng2.control.core.model.ISessionInfo;
19 import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent;
20
21 /**
22 * <p>
23 * Implementation of the trace session group.
24 * </p>
25 *
26 * @author Bernd Hufmann
27 */
28 public class TraceSessionGroup extends TraceControlComponent {
29 // ------------------------------------------------------------------------
30 // Constants
31 // ------------------------------------------------------------------------
32 /**
33 * Path to icon file for this component.
34 */
35 public static final String TRACE_SESSIONS_ICON_FILE = "icons/obj16/sessions.gif"; //$NON-NLS-1$
36
37 // ------------------------------------------------------------------------
38 // Attributes
39 // ------------------------------------------------------------------------
40
41 // ------------------------------------------------------------------------
42 // Constructors
43 // ------------------------------------------------------------------------
44 /**
45 * Constructor
46 * @param name - the name of the component.
47 * @param parent - the parent of this component.
48 */
49 public TraceSessionGroup(String name, ITraceControlComponent parent) {
50 super(name, parent);
51 setImage(TRACE_SESSIONS_ICON_FILE);
52 }
53
54 // ------------------------------------------------------------------------
55 // Accessors
56 // ------------------------------------------------------------------------
57
58 /**
59 * @return the parent target node
60 */
61 public TargetNodeComponent getTargetNode() {
62 return (TargetNodeComponent)getParent();
63 }
64
65 /**
66 * Returns if node supports networks streaming or not
67 * @return <code>true</code> if node supports filtering else <code>false</code>
68 */
69 public boolean isNetworkStreamingSupported() {
70 return getTargetNode().isNetworkStreamingSupported();
71 }
72 /**
73 * Returns if node supports snapshots or not
74 * @return <code>true</code> if it supports snapshots else <code>false</code>
75 *
76 */ public boolean isSnapshotSupported() {
77 return getTargetNode().isSnapshotSupported();
78 }
79
80 // ------------------------------------------------------------------------
81 // Operations
82 // ------------------------------------------------------------------------
83 /**
84 * Retrieves the sessions information from the node.
85 *
86 * @throws ExecutionException
87 * If the command fails
88 */
89 public void getSessionsFromNode() throws ExecutionException {
90 getSessionsFromNode(new NullProgressMonitor());
91 }
92
93 /**
94 * Retrieves the sessions information from the node.
95 *
96 * @param monitor
97 * - a progress monitor
98 * @throws ExecutionException
99 * If the command fails
100 */
101 public void getSessionsFromNode(IProgressMonitor monitor)
102 throws ExecutionException {
103 String[] sessionNames = getControlService().getSessionNames(monitor);
104 for (int i = 0; i < sessionNames.length; i++) {
105 TraceSessionComponent session = new TraceSessionComponent(
106 sessionNames[i], this);
107 addChild(session);
108 session.getConfigurationFromNode(monitor);
109 }
110 }
111
112 /**
113 * Creates a session with given session name and location.
114 *
115 * @param sessionInf
116 * the session information used to create the session
117 *
118 * @param monitor
119 * - a progress monitor
120 * @throws ExecutionException
121 * If the command fails
122 */
123 public void createSession(ISessionInfo sessionInf, IProgressMonitor monitor) throws ExecutionException {
124 ISessionInfo sessionInfo = getControlService().createSession(sessionInf, monitor);
125
126 if (sessionInfo != null) {
127 TraceSessionComponent session = new TraceSessionComponent(sessionInfo.getName(), TraceSessionGroup.this);
128 addChild(session);
129 session.getConfigurationFromNode(monitor);
130 }
131 }
132
133 /**
134 * Destroys a session with given session name.
135 *
136 * @param session
137 * - a session component to destroy
138 * @param monitor
139 * - a progress monitor
140 * @throws ExecutionException
141 * If the command fails
142 */
143 public void destroySession(TraceSessionComponent session,
144 IProgressMonitor monitor) throws ExecutionException {
145 getControlService().destroySession(session.getName(), monitor);
146 session.removeAllChildren();
147 removeChild(session);
148 }
149 }
This page took 0.033113 seconds and 5 git commands to generate.