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
.lttng
.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
.lttng
.ui
.LTTngUiPlugin
;
18 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.Messages
;
19 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.IDomainInfo
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ISessionInfo
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.ITraceControlComponent
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.TraceSessionState
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.property
.TraceSessionPropertySource
;
24 import org
.eclipse
.swt
.graphics
.Image
;
25 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
28 * <b><u>TraceSessionComponent</u></b>
30 * Implementation of the trace session component.
33 public class TraceSessionComponent
extends TraceControlComponent
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
39 * Path to icon file for this component (inactive state).
41 public static final String TRACE_SESSION_ICON_FILE_INACTIVE
= "icons/obj16/session_inactive.gif"; //$NON-NLS-1$
43 * Path to icon file for this component (active state).
45 public static final String TRACE_SESSION_ICON_FILE_ACTIVE
= "icons/obj16/session_active.gif"; //$NON-NLS-1$
47 * Path to icon file for this component (destroyed state).
49 public static final String TRACE_SESSION_ICON_FILE_DESTROYED
= "icons/obj16/session_destroyed.gif"; //$NON-NLS-1$
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
55 * The session information.
57 private ISessionInfo fSessionInfo
= null;
59 * A flag to indicate if session has been destroyed.
61 private boolean fIsDestroyed
= false;
63 * The image to be displayed in state active.
65 private Image fActiveImage
= null;
67 * The image to be displayed in state destroyed
69 private Image fDestroyedImage
= null;
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
76 * @param name - the name of the component.
77 * @param parent - the parent of this component.
79 public TraceSessionComponent(String name
, ITraceControlComponent parent
) {
81 setImage(TRACE_SESSION_ICON_FILE_INACTIVE
);
82 setToolTip(Messages
.TraceControl_SessionDisplayName
);
83 fSessionInfo
= new SessionInfo(name
);
84 fActiveImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_ACTIVE
);
85 fDestroyedImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_DESTROYED
);
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
93 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
96 public Image
getImage() {
98 return fDestroyedImage
;
101 if (fSessionInfo
.getSessionState() == TraceSessionState
.INACTIVE
) {
102 return super.getImage();
110 * @return the whether the session is destroyed or not.
112 public boolean isDestroyed() {
117 * Sets the session destroyed state to the given value.
118 * @param destroyed - value to set.
120 public void setDestroyed(boolean destroyed
) {
121 fIsDestroyed
= destroyed
;
125 * @return the session state state (active or inactive).
127 public TraceSessionState
getSessionState() {
128 return fSessionInfo
.getSessionState();
132 * Sets the session state to the given value.
133 * @param state - state to set.
135 public void setSessionState(TraceSessionState state
) {
136 fSessionInfo
.setSessionState(state
);
140 * Sets the event state to the value specified by the given name.
141 * @param stateName - state to set.
143 public void setSessionState(String stateName
) {
144 fSessionInfo
.setSessionState(stateName
);
148 * @return path string where session is located.
150 public String
getSessionPath() {
151 return fSessionInfo
.getSessionPath();
155 * Sets the path string (where session is located) to the given value.
156 * @param path - session path to set.
158 public void setSessionPath(String sessionPath
) {
159 fSessionInfo
.setSessionPath(sessionPath
);
164 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
166 @SuppressWarnings("rawtypes")
168 public Object
getAdapter(Class adapter
) {
169 if (adapter
== IPropertySource
.class) {
170 return new TraceSessionPropertySource(this);
175 // ------------------------------------------------------------------------
177 // ------------------------------------------------------------------------
179 * Retrieves the session configuration from the node.
180 * @throws ExecutionException
182 public void getConfigurationFromNode() throws ExecutionException
{
183 getConfigurationFromNode(new NullProgressMonitor());
187 * Retrieves the session configuration from the node.
188 * @param monitor - a progress monitor
189 * @throws ExecutionException
191 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
192 fSessionInfo
= getControlService().getSession(getName(), monitor
);
193 IDomainInfo
[] domains
= fSessionInfo
.getDomains();
194 for (int i
= 0; i
< domains
.length
; i
++) {
195 TraceDomainComponent domainComponenent
= new TraceDomainComponent(domains
[i
].getName(), this);
196 addChild(domainComponenent
);
197 domainComponenent
.setDomainInfo(domains
[i
]);