1 /*******************************************************************************
2 * Copyright (c) 2009, 2010, 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 * 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
.ui
.IWorkbenchActionConstants
;
22 import org
.eclipse
.ui
.part
.ViewPart
;
25 * Basic abstract TMF view class implementation.
27 * It registers any sub class to the signal manager for receiving and sending
31 * @author Francois Chouinard
33 public abstract class TmfView
extends ViewPart
implements ITmfComponent
{
35 private final String fName
;
37 * Action class for pinning of TmfView.
40 protected PinTmfViewAction fPinAction
;
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
47 * Constructor. Creates a TMF view and registers to the signal manager.
49 * @param viewName A view name
51 public TmfView(String viewName
) {
54 TmfSignalManager
.register(this);
58 * Disposes this view and deregisters itself from the signal manager
59 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
62 public void dispose() {
63 TmfSignalManager
.deregister(this);
67 // ------------------------------------------------------------------------
69 // ------------------------------------------------------------------------
73 * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#getName()
76 public String
getName() {
82 * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#broadcast(org.eclipse.linuxtools.tmf.core.signal.TmfSignal)
85 public void broadcast(TmfSignal signal
) {
86 TmfSignalManager
.dispatchSignal(signal
);
90 * Returns whether the pin flag is set.
91 * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
96 public boolean isPinned() {
97 return ((fPinAction
!= null) && (fPinAction
.isChecked()));
101 * Method adds a pin action to the TmfView. The pin action allows to toggle the <code>fIsPinned</code> flag.
102 * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
106 protected void contributePinActionToToolBar() {
107 if (fPinAction
== null) {
108 fPinAction
= new PinTmfViewAction();
110 IToolBarManager toolBarManager
= getViewSite().getActionBars()
111 .getToolBarManager();
112 toolBarManager
.add(new Separator(IWorkbenchActionConstants
.MB_ADDITIONS
));
113 toolBarManager
.add(fPinAction
);