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
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 **********************************************************************/
13package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
14
15import java.util.List;
16
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.core.runtime.IProgressMonitor;
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;
26import org.eclipse.linuxtools.internal.lttng2.ui.Activator;
27import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages;
28import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent;
29import org.eclipse.linuxtools.internal.lttng2.ui.views.control.property.TraceSessionPropertySource;
30import org.eclipse.swt.graphics.Image;
31import org.eclipse.ui.views.properties.IPropertySource;
32
33/**
34 * <p>
35 * Implementation of the trace session component.
36 * </p>
37 *
38 * @author Bernd Hufmann
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 /**
82 * Constructor
83 * @param name - the name of the component.
84 * @param parent - the parent of this component.
85 */
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);
91 fActiveImage = Activator.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_ACTIVE);
92 fDestroyedImage = Activator.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_DESTROYED);
93 }
94
95 // ------------------------------------------------------------------------
96 // Accessors
97 // ------------------------------------------------------------------------
98
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 }
108
109 return fActiveImage;
110 }
111
112 /**
113 * @return the whether the session is destroyed or not.
114 */
115 public boolean isDestroyed() {
116 return fIsDestroyed;
117 }
118
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 }
126
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 }
141
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.
159 * @param sessionPath - session path to set.
160 */
161 public void setSessionPath(String sessionPath) {
162 fSessionInfo.setSessionPath(sessionPath);
163 }
164
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
181 @Override
182 public Object getAdapter(Class adapter) {
183 if (adapter == IPropertySource.class) {
184 return new TraceSessionPropertySource(this);
185 }
186 return null;
187 }
188
189 /**
190 * @return all available domains of this session.
191 */
192 public TraceDomainComponent[] getDomains() {
193 List<ITraceControlComponent> sessions = getChildren(TraceDomainComponent.class);
194 return sessions.toArray(new TraceDomainComponent[sessions.size()]);
195 }
196
197 /**
198 * @return the parent target node
199 */
200 public TargetNodeComponent getTargetNode() {
201 return ((TraceSessionGroup)getParent()).getTargetNode();
202 }
203
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
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
221 // ------------------------------------------------------------------------
222 // Operations
223 // ------------------------------------------------------------------------
224
225 /**
226 * Retrieves the session configuration from the node.
227 *
228 * @param monitor
229 * - a progress monitor
230 * @throws ExecutionException
231 * If the command fails
232 */
233 public void getConfigurationFromNode(IProgressMonitor monitor)
234 throws ExecutionException {
235 removeAllChildren();
236 fSessionInfo = getControlService().getSession(getName(), monitor);
237 IDomainInfo[] domains = fSessionInfo.getDomains();
238 for (int i = 0; i < domains.length; i++) {
239 TraceDomainComponent domainComponent = new TraceDomainComponent(
240 domains[i].getName(), this);
241 addChild(domainComponent);
242 domainComponent.setDomainInfo(domains[i]);
243 }
244 }
245
246 /**
247 * Starts the session.
248 *
249 * @param monitor
250 * - a progress monitor
251 * @throws ExecutionException
252 * If the command fails
253 */
254 public void startSession(IProgressMonitor monitor)
255 throws ExecutionException {
256 getControlService().startSession(getName(), monitor);
257 }
258
259 /**
260 * Starts the session.
261 *
262 * @param monitor
263 * - a progress monitor
264 * @throws ExecutionException
265 * If the command fails
266 */
267 public void stopSession(IProgressMonitor monitor) throws ExecutionException {
268 getControlService().stopSession(getName(), monitor);
269 }
270
271 /**
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
285 * @throws ExecutionException
286 * If the command fails
287 */
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);
293 }
294
295 /**
296 * Enables a list of events with no additional parameters.
297 *
298 * @param eventNames
299 * - a list of event names to enabled.
300 * @param isKernel
301 * - a flag for indicating kernel or UST.
302 * @param filterExpression
303 * - a filter expression
304 * @param monitor
305 * - a progress monitor
306 * @throws ExecutionException
307 * If the command fails
308 */
309 public void enableEvents(List<String> eventNames, boolean isKernel,
310 String filterExpression, IProgressMonitor monitor) throws ExecutionException {
311 getControlService().enableEvents(getName(), null, eventNames, isKernel,
312 filterExpression, monitor);
313 }
314
315 /**
316 * Enables all syscalls (for kernel domain)
317 *
318 * @param monitor
319 * - a progress monitor
320 * @throws ExecutionException
321 * If the command fails
322 */
323 public void enableSyscalls(IProgressMonitor monitor)
324 throws ExecutionException {
325 getControlService().enableSyscalls(getName(), null, monitor);
326 }
327
328 /**
329 * Enables a dynamic probe (for kernel domain)
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
339 * @throws ExecutionException
340 * If the command fails
341 */
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);
346 }
347
348 /**
349 * Enables events using log level.
350 *
351 * @param eventName
352 * - a event name
353 * @param logLevelType
354 * - a log level type
355 * @param level
356 * - a log level
357 * @param filterExpression
358 * - a filter expression
359 * @param monitor
360 * - a progress monitor
361 * @throws ExecutionException
362 * If the command fails
363 */
364 public void enableLogLevel(String eventName, LogLevelType logLevelType,
365 TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
366 throws ExecutionException {
367 getControlService().enableLogLevel(getName(), null, eventName,
368 logLevelType, level, null, monitor);
369 }
370
371 /**
372 * Gets all available contexts to be added to channels/events.
373 *
374 * @param monitor
375 * The monitor that will indicate the progress
376 * @return the list of available contexts
377 * @throws ExecutionException
378 * If the command fails
379 */
380 public List<String> getContextList(IProgressMonitor monitor)
381 throws ExecutionException {
382 return getControlService().getContextList(monitor);
383 }
384}
This page took 0.024807 seconds and 5 git commands to generate.