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
.swt
.graphics
.Image
;
26 * <b><u>TraceSessionComponent</u></b>
28 * Implementation of the trace session component.
31 public class TraceSessionComponent
extends TraceControlComponent
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 * Path to icon file for this component (inactive state).
39 public static final String TRACE_SESSION_ICON_FILE_INACTIVE
= "icons/obj16/session_inactive.gif"; //$NON-NLS-1$
41 * Path to icon file for this component (active state).
43 public static final String TRACE_SESSION_ICON_FILE_ACTIVE
= "icons/obj16/session_active.gif"; //$NON-NLS-1$
45 * Path to icon file for this component (destroyed state).
47 public static final String TRACE_SESSION_ICON_FILE_DESTROYED
= "icons/obj16/session_destroyed.gif"; //$NON-NLS-1$
49 // ------------------------------------------------------------------------
51 // ------------------------------------------------------------------------
53 * The session information.
55 private ISessionInfo fSessionInfo
= null;
57 * A flag to indicate if session has been destroyed.
59 private boolean fIsDestroyed
= false;
61 * The image to be displayed in state active.
63 private Image fActiveImage
= null;
65 * The image to be displayed in state destroyed
67 private Image fDestroyedImage
= null;
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
74 * @param name - the name of the component.
75 * @param parent - the parent of this component.
77 public TraceSessionComponent(String name
, ITraceControlComponent parent
) {
79 setImage(TRACE_SESSION_ICON_FILE_INACTIVE
);
80 setToolTip(Messages
.TraceControl_SessionDisplayName
);
81 fSessionInfo
= new SessionInfo(name
);
82 fActiveImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_ACTIVE
);
83 fDestroyedImage
= LTTngUiPlugin
.getDefault().loadIcon(TRACE_SESSION_ICON_FILE_DESTROYED
);
86 // ------------------------------------------------------------------------
88 // ------------------------------------------------------------------------
91 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getImage()
94 public Image
getImage() {
96 return fDestroyedImage
;
99 if (fSessionInfo
.getSessionState() == TraceSessionState
.INACTIVE
) {
100 return super.getImage();
108 * @return the whether the session is destroyed or not.
110 public boolean isDestroyed() {
115 * Sets the session destroyed state to the given value.
116 * @param destroyed - value to set.
118 public void setDestroyed(boolean destroyed
) {
119 fIsDestroyed
= destroyed
;
123 * @return the session state state (active or inactive).
125 public TraceSessionState
getSessionState() {
126 return fSessionInfo
.getSessionState();
130 * Sets the session state to the given value.
131 * @param state - state to set.
133 public void setSessionState(TraceSessionState state
) {
134 fSessionInfo
.setSessionState(state
);
138 * Sets the event state to the value specified by the given name.
139 * @param stateName - state to set.
141 public void setSessionState(String stateName
) {
142 fSessionInfo
.setSessionState(stateName
);
146 * @return path string where session is located.
148 public String
getSessionPath() {
149 return fSessionInfo
.getSessionPath();
153 * Sets the path string (where session is located) to the given value.
154 * @param path - session path to set.
156 public void setSessionPath(String sessionPath
) {
157 fSessionInfo
.setSessionPath(sessionPath
);
160 // ------------------------------------------------------------------------
162 // ------------------------------------------------------------------------
164 * Retrieves the session configuration from the node.
165 * @throws ExecutionException
167 public void getConfigurationFromNode() throws ExecutionException
{
168 getConfigurationFromNode(new NullProgressMonitor());
172 * Retrieves the session configuration from the node.
173 * @param monitor - a progress monitor
174 * @throws ExecutionException
176 public void getConfigurationFromNode(IProgressMonitor monitor
) throws ExecutionException
{
177 fSessionInfo
= getControlService().getSession(getName(), monitor
);
178 IDomainInfo
[] domains
= fSessionInfo
.getDomains();
179 for (int i
= 0; i
< domains
.length
; i
++) {
180 TraceDomainComponent domainComponenent
= new TraceDomainComponent(domains
[i
].getName(), this);
181 addChild(domainComponenent
);
182 domainComponenent
.setDomainInfo(domains
[i
]);