1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 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 * Francois Chouinard - Initial API and implementation
11 * Bernd Hufmann - Added possibility to pin view
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
;
16 import org
.eclipse
.jface
.action
.IToolBarManager
;
17 import org
.eclipse
.jface
.action
.Separator
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.component
.ITmfComponent
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignal
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalManager
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTraceManager
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.editors
.ITmfTraceEditor
;
24 import org
.eclipse
.ui
.IEditorPart
;
25 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
26 import org
.eclipse
.ui
.part
.ViewPart
;
29 * Basic abstract TMF view class implementation.
31 * It registers any sub class to the signal manager for receiving and sending
35 * @author Francois Chouinard
37 public abstract class TmfView
extends ViewPart
implements ITmfComponent
{
39 private final String fName
;
42 * Action class for pinning of TmfView.
45 protected PinTmfViewAction fPinAction
;
48 * Reference to the trace manager
51 protected final TmfTraceManager fTraceManager
;
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
58 * Constructor. Creates a TMF view and registers to the signal manager.
63 public TmfView(String viewName
) {
66 fTraceManager
= TmfTraceManager
.getInstance();
67 TmfSignalManager
.register(this);
71 * Disposes this view and de-registers itself from the signal manager
74 public void dispose() {
75 TmfSignalManager
.deregister(this);
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 public String
getName() {
89 public void broadcast(TmfSignal signal
) {
90 TmfSignalManager
.dispatchSignal(signal
);
93 // ------------------------------------------------------------------------
94 // View pinning support
95 // ------------------------------------------------------------------------
98 * Returns whether the pin flag is set.
99 * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
104 public boolean isPinned() {
105 return ((fPinAction
!= null) && (fPinAction
.isChecked()));
109 * Method adds a pin action to the TmfView. The pin action allows to toggle the <code>fIsPinned</code> flag.
110 * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
114 protected void contributePinActionToToolBar() {
115 if (fPinAction
== null) {
116 fPinAction
= new PinTmfViewAction();
118 IToolBarManager toolBarManager
= getViewSite().getActionBars()
119 .getToolBarManager();
120 toolBarManager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
121 toolBarManager
.add(fPinAction
);
126 * Get the currently selected trace, or 'null' if the active editor is not a
129 * @return The active trace, or 'null' if not a trace
132 public ITmfTrace
getActiveTrace() {
133 IEditorPart editor
= getSite().getPage().getActiveEditor();
134 if (editor
instanceof ITmfTraceEditor
) {
135 ITmfTrace trace
= ((ITmfTraceEditor
) editor
).getTrace();