tmf/lttng: Remove unneeded (non-Javadoc) comments
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / ui / views / control / model / impl / TraceSessionComponent.java
CommitLineData
eb1bab5b 1/**********************************************************************
ba3a9bd2 2 * Copyright (c) 2012, 2013 Ericsson
cfdb727a 3 *
eb1bab5b
BH
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
cfdb727a
AM
8 *
9 * Contributors:
eb1bab5b 10 * Bernd Hufmann - Initial API and implementation
ba3a9bd2 11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
eb1bab5b 12 **********************************************************************/
115b4a01 13package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
eb1bab5b 14
6503ae0f
BH
15import java.util.List;
16
eb1bab5b
BH
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.core.runtime.IProgressMonitor;
9315aeee
BH
19import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
20import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
21import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
22import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
23import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
24import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
25import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
115b4a01 26import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
9315aeee 27import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
115b4a01 28import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
115b4a01 29import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceSessionPropertySource;
eb1bab5b 30import org.eclipse.swt.graphics.Image;
06b9339e 31import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
32
33/**
eb1bab5b
BH
34 * <p>
35 * Implementation of the trace session component.
36 * </p>
cfdb727a 37 *
dbd4432d 38 * @author Bernd Hufmann
eb1bab5b
BH
39 */
40public class TraceSessionComponent extends TraceControlComponent {
41
42 // ------------------------------------------------------------------------
43 // Constants
44 // ------------------------------------------------------------------------
45 /**
46 * Path to icon file for this component (inactive state).
47 */
48 public static final String TRACE_SESSION_ICON_FILE_INACTIVE = "icons/obj16/session_inactive.gif"; //$NON-NLS-1$
49 /**
50 * Path to icon file for this component (active state).
51 */
52 public static final String TRACE_SESSION_ICON_FILE_ACTIVE = "icons/obj16/session_active.gif"; //$NON-NLS-1$
53 /**
54 * Path to icon file for this component (destroyed state).
55 */
56 public static final String TRACE_SESSION_ICON_FILE_DESTROYED = "icons/obj16/session_destroyed.gif"; //$NON-NLS-1$
57
58 // ------------------------------------------------------------------------
59 // Attributes
60 // ------------------------------------------------------------------------
61 /**
62 * The session information.
63 */
64 private ISessionInfo fSessionInfo = null;
65 /**
66 * A flag to indicate if session has been destroyed.
67 */
68 private boolean fIsDestroyed = false;
69 /**
70 * The image to be displayed in state active.
71 */
72 private Image fActiveImage = null;
73 /**
74 * The image to be displayed in state destroyed
75 */
76 private Image fDestroyedImage = null;
77
78 // ------------------------------------------------------------------------
79 // Constructors
80 // ------------------------------------------------------------------------
81 /**
cfdb727a 82 * Constructor
eb1bab5b
BH
83 * @param name - the name of the component.
84 * @param parent - the parent of this component.
cfdb727a 85 */
eb1bab5b
BH
86 public TraceSessionComponent(String name, ITraceControlComponent parent) {
87 super(name, parent);
88 setImage(TRACE_SESSION_ICON_FILE_INACTIVE);
89 setToolTip(Messages.TraceControl_SessionDisplayName);
90 fSessionInfo = new SessionInfo(name);
31a6a4e4
BH
91 fActiveImage = Activator.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_ACTIVE);
92 fDestroyedImage = Activator.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_DESTROYED);
eb1bab5b
BH
93 }
94
95 // ------------------------------------------------------------------------
96 // Accessors
97 // ------------------------------------------------------------------------
11252342 98
eb1bab5b
BH
99 @Override
100 public Image getImage() {
101 if (fIsDestroyed) {
102 return fDestroyedImage;
103 }
104
105 if (fSessionInfo.getSessionState() == TraceSessionState.INACTIVE) {
106 return super.getImage();
107 }
cfdb727a 108
eb1bab5b
BH
109 return fActiveImage;
110 }
111
eb1bab5b
BH
112 /**
113 * @return the whether the session is destroyed or not.
114 */
115 public boolean isDestroyed() {
116 return fIsDestroyed;
117 }
bbb3538a 118
eb1bab5b
BH
119 /**
120 * Sets the session destroyed state to the given value.
121 * @param destroyed - value to set.
122 */
123 public void setDestroyed(boolean destroyed) {
124 fIsDestroyed = destroyed;
125 }
bbb3538a 126
eb1bab5b
BH
127 /**
128 * @return the session state state (active or inactive).
129 */
130 public TraceSessionState getSessionState() {
131 return fSessionInfo.getSessionState();
132 }
133
134 /**
135 * Sets the session state to the given value.
136 * @param state - state to set.
137 */
138 public void setSessionState(TraceSessionState state) {
139 fSessionInfo.setSessionState(state);
140 }
bbb3538a 141
eb1bab5b
BH
142 /**
143 * Sets the event state to the value specified by the given name.
144 * @param stateName - state to set.
145 */
146 public void setSessionState(String stateName) {
147 fSessionInfo.setSessionState(stateName);
148 }
149
150 /**
151 * @return path string where session is located.
152 */
153 public String getSessionPath() {
154 return fSessionInfo.getSessionPath();
155 }
156
157 /**
158 * Sets the path string (where session is located) to the given value.
cfdb727a 159 * @param sessionPath - session path to set.
eb1bab5b
BH
160 */
161 public void setSessionPath(String sessionPath) {
162 fSessionInfo.setSessionPath(sessionPath);
163 }
164
f3b33d40
BH
165 /**
166 * Returns if session is streamed over network
167 * @return <code>true</code> if streamed over network else <code>false</code>
168 */
169 public boolean isStreamedTrace() {
170 return fSessionInfo.isStreamedTrace();
171 }
172
173 /**
174 * Sets whether the trace is streamed or not
175 * @param isStreamedTrace <code>true</code> if streamed over network else <code>false</code>
176 */
177 public void setIsStreamedTrace(boolean isStreamedTrace) {
178 fSessionInfo.setStreamedTrace(isStreamedTrace);
179 }
180
06b9339e
BH
181 @Override
182 public Object getAdapter(Class adapter) {
183 if (adapter == IPropertySource.class) {
184 return new TraceSessionPropertySource(this);
185 }
186 return null;
cfdb727a 187 }
bbb3538a 188
6503ae0f
BH
189 /**
190 * @return all available domains of this session.
191 */
192 public TraceDomainComponent[] getDomains() {
193 List<ITraceControlComponent> sessions = getChildren(TraceDomainComponent.class);
cfdb727a 194 return sessions.toArray(new TraceDomainComponent[sessions.size()]);
6503ae0f 195 }
cfdb727a 196
498704b3
BH
197 /**
198 * @return the parent target node
199 */
200 public TargetNodeComponent getTargetNode() {
201 return ((TraceSessionGroup)getParent()).getTargetNode();
202 }
cfdb727a 203
a07c7629
BH
204 /**
205 * Returns whether the kernel provider is available or not
206 * @return <code>true</code> if kernel provide is available or <code>false</code>
207 */
208 public boolean hasKernelProvider() {
209 List<ITraceControlComponent> providerGroups = getTargetNode().getChildren(TraceProviderGroup.class);
210 return (!providerGroups.isEmpty() ? ((TraceProviderGroup) providerGroups.get(0)).hasKernelProvider() : false);
211 }
212
d4514365
BH
213 /**
214 * Returns if node supports filtering of events
215 * @return <code>true</code> if node supports filtering else <code>false</code>
216 */
217 public boolean isEventFilteringSupported() {
218 return ((TargetNodeComponent)getParent().getParent()).isEventFilteringSupported();
219 }
220
eb1bab5b
BH
221 // ------------------------------------------------------------------------
222 // Operations
223 // ------------------------------------------------------------------------
cfdb727a 224
eb1bab5b 225 /**
cfdb727a
AM
226 * Retrieves the session configuration from the node.
227 *
228 * @param monitor
229 * - a progress monitor
eb1bab5b 230 * @throws ExecutionException
cfdb727a 231 * If the command fails
eb1bab5b 232 */
cfdb727a
AM
233 public void getConfigurationFromNode(IProgressMonitor monitor)
234 throws ExecutionException {
bbb3538a 235 removeAllChildren();
eb1bab5b
BH
236 fSessionInfo = getControlService().getSession(getName(), monitor);
237 IDomainInfo[] domains = fSessionInfo.getDomains();
238 for (int i = 0; i < domains.length; i++) {
cfdb727a
AM
239 TraceDomainComponent domainComponent = new TraceDomainComponent(
240 domains[i].getName(), this);
bbb3538a
BH
241 addChild(domainComponent);
242 domainComponent.setDomainInfo(domains[i]);
eb1bab5b
BH
243 }
244 }
cfdb727a 245
bbb3538a
BH
246 /**
247 * Starts the session.
cfdb727a
AM
248 *
249 * @param monitor
250 * - a progress monitor
251 * @throws ExecutionException
252 * If the command fails
bbb3538a 253 */
cfdb727a
AM
254 public void startSession(IProgressMonitor monitor)
255 throws ExecutionException {
bbb3538a
BH
256 getControlService().startSession(getName(), monitor);
257 }
cfdb727a 258
bbb3538a
BH
259 /**
260 * Starts the session.
cfdb727a
AM
261 *
262 * @param monitor
263 * - a progress monitor
264 * @throws ExecutionException
265 * If the command fails
bbb3538a
BH
266 */
267 public void stopSession(IProgressMonitor monitor) throws ExecutionException {
268 getControlService().stopSession(getName(), monitor);
269 }
270
c56972bb 271 /**
cfdb727a
AM
272 * Enables channels with given names which are part of this domain. If a
273 * given channel doesn't exists it creates a new channel with the given
274 * parameters (or default values if given parameter is null).
275 *
276 * @param channelNames
277 * - a list of channel names to enable on this domain
278 * @param info
279 * - channel information to set for the channel (use null for
280 * default)
281 * @param isKernel
282 * - a flag for indicating kernel or UST.
283 * @param monitor
284 * - a progress monitor
c56972bb 285 * @throws ExecutionException
cfdb727a 286 * If the command fails
c56972bb 287 */
cfdb727a
AM
288 public void enableChannels(List<String> channelNames, IChannelInfo info,
289 boolean isKernel, IProgressMonitor monitor)
290 throws ExecutionException {
291 getControlService().enableChannels(getName(), channelNames, isKernel,
292 info, monitor);
c56972bb 293 }
cfdb727a 294
6503ae0f
BH
295 /**
296 * Enables a list of events with no additional parameters.
cfdb727a
AM
297 *
298 * @param eventNames
299 * - a list of event names to enabled.
300 * @param isKernel
301 * - a flag for indicating kernel or UST.
d4514365
BH
302 * @param filterExpression
303 * - a filter expression
cfdb727a
AM
304 * @param monitor
305 * - a progress monitor
6503ae0f 306 * @throws ExecutionException
cfdb727a 307 * If the command fails
6503ae0f 308 */
cfdb727a 309 public void enableEvents(List<String> eventNames, boolean isKernel,
d4514365 310 String filterExpression, IProgressMonitor monitor) throws ExecutionException {
cfdb727a 311 getControlService().enableEvents(getName(), null, eventNames, isKernel,
d4514365 312 filterExpression, monitor);
498704b3
BH
313 }
314
498704b3
BH
315 /**
316 * Enables all syscalls (for kernel domain)
cfdb727a
AM
317 *
318 * @param monitor
319 * - a progress monitor
498704b3 320 * @throws ExecutionException
cfdb727a 321 * If the command fails
498704b3 322 */
cfdb727a
AM
323 public void enableSyscalls(IProgressMonitor monitor)
324 throws ExecutionException {
498704b3
BH
325 getControlService().enableSyscalls(getName(), null, monitor);
326 }
327
498704b3
BH
328 /**
329 * Enables a dynamic probe (for kernel domain)
cfdb727a
AM
330 *
331 * @param eventName
332 * - event name for probe
333 * @param isFunction
334 * - true for dynamic function entry/return probe else false
335 * @param probe
336 * - the actual probe
337 * @param monitor
338 * - a progress monitor
498704b3 339 * @throws ExecutionException
cfdb727a 340 * If the command fails
498704b3 341 */
cfdb727a
AM
342 public void enableProbe(String eventName, boolean isFunction, String probe,
343 IProgressMonitor monitor) throws ExecutionException {
344 getControlService().enableProbe(getName(), null, eventName, isFunction,
345 probe, monitor);
6503ae0f 346 }
cfdb727a 347
ccc66d01
BH
348 /**
349 * Enables events using log level.
cfdb727a
AM
350 *
351 * @param eventName
352 * - a event name
353 * @param logLevelType
354 * - a log level type
355 * @param level
356 * - a log level
d4514365
BH
357 * @param filterExpression
358 * - a filter expression
cfdb727a
AM
359 * @param monitor
360 * - a progress monitor
ccc66d01 361 * @throws ExecutionException
cfdb727a 362 * If the command fails
ccc66d01 363 */
cfdb727a 364 public void enableLogLevel(String eventName, LogLevelType logLevelType,
d4514365 365 TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
cfdb727a
AM
366 throws ExecutionException {
367 getControlService().enableLogLevel(getName(), null, eventName,
d4514365 368 logLevelType, level, null, monitor);
ccc66d01 369 }
cfdb727a 370
b793fbe1
BH
371 /**
372 * Gets all available contexts to be added to channels/events.
cfdb727a 373 *
b793fbe1 374 * @param monitor
cfdb727a 375 * The monitor that will indicate the progress
b793fbe1 376 * @return the list of available contexts
cfdb727a
AM
377 * @throws ExecutionException
378 * If the command fails
b793fbe1 379 */
cfdb727a
AM
380 public List<String> getContextList(IProgressMonitor monitor)
381 throws ExecutionException {
b793fbe1
BH
382 return getControlService().getContextList(monitor);
383 }
eb1bab5b 384}
This page took 0.053586 seconds and 5 git commands to generate.