Fix 2 actions that had old identifiers
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / TmfView.java
CommitLineData
b0d3496e 1/*******************************************************************************
2f2265e2 2 * Copyright (c) 2009, 2010, 2012 Ericsson
db59ddc2 3 *
b0d3496e
ASL
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
013a5f1c 8 *
b0d3496e
ASL
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
db59ddc2 11 * Bernd Hufmann - Added possibility to pin view
b0d3496e
ASL
12 *******************************************************************************/
13
14package org.eclipse.linuxtools.tmf.ui.views;
15
db59ddc2
BH
16import org.eclipse.jface.action.IToolBarManager;
17import org.eclipse.jface.action.Separator;
6c13869b
FC
18import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;
19import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
20import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
db59ddc2 21import org.eclipse.ui.IWorkbenchActionConstants;
b0d3496e
ASL
22import org.eclipse.ui.part.ViewPart;
23
24/**
2f2265e2 25 * Basic abstract TMF view class implementation.
db59ddc2 26 *
2f2265e2 27 * It registers any sub class to the signal manager for receiving and sending
db59ddc2
BH
28 * TMF signals.
29 *
30 * @version 1.2
2f2265e2 31 * @author Francois Chouinard
b0d3496e
ASL
32 */
33public abstract class TmfView extends ViewPart implements ITmfComponent {
34
fc6ccf6f 35 private final String fName;
db59ddc2
BH
36 /**
37 * Action class for pinning of TmfView.
9da25000 38 * @since 2.0
db59ddc2
BH
39 */
40 protected PinTmfViewAction fPinAction;
013a5f1c 41
e31e01e8
FC
42 // ------------------------------------------------------------------------
43 // Constructor
44 // ------------------------------------------------------------------------
45
2f2265e2
BH
46 /**
47 * Constructor. Creates a TMF view and registers to the signal manager.
db59ddc2 48 *
2f2265e2
BH
49 * @param viewName A view name
50 */
fc6ccf6f 51 public TmfView(String viewName) {
e31e01e8 52 super();
fc6ccf6f 53 fName = viewName;
2fb2eb37 54 TmfSignalManager.register(this);
b0d3496e
ASL
55 }
56
2f2265e2 57 /**
db59ddc2 58 * Disposes this view and deregisters itself from the signal manager
2f2265e2
BH
59 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
60 */
8f50c396
FC
61 @Override
62 public void dispose() {
2fb2eb37 63 TmfSignalManager.deregister(this);
8f50c396
FC
64 super.dispose();
65 }
66
e31e01e8
FC
67 // ------------------------------------------------------------------------
68 // ITmfComponent
69 // ------------------------------------------------------------------------
70
2f2265e2
BH
71 /*
72 * (non-Javadoc)
73 * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#getName()
74 */
d4011df2 75 @Override
fc6ccf6f
FC
76 public String getName() {
77 return fName;
78 }
013a5f1c 79
2f2265e2
BH
80 /*
81 * (non-Javadoc)
82 * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#broadcast(org.eclipse.linuxtools.tmf.core.signal.TmfSignal)
83 */
d4011df2 84 @Override
e31e01e8 85 public void broadcast(TmfSignal signal) {
8d2e2848
FC
86 TmfSignalManager.dispatchSignal(signal);
87 }
88
db59ddc2
BH
89 /**
90 * Returns whether the pin flag is set.
91 * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
92 *
93 * @return pin flag
9da25000 94 * @since 2.0
db59ddc2
BH
95 */
96 public boolean isPinned() {
97 return ((fPinAction != null) && (fPinAction.isChecked()));
98 }
99
100 /**
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.
103 *
9da25000 104 * @since 2.0
db59ddc2
BH
105 */
106 protected void contributePinActionToToolBar() {
107 if (fPinAction == null) {
108 fPinAction = new PinTmfViewAction();
109
110 IToolBarManager toolBarManager = getViewSite().getActionBars()
111 .getToolBarManager();
112 toolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
113 toolBarManager.add(fPinAction);
114 }
115 }
013a5f1c 116}
This page took 0.04306 seconds and 5 git commands to generate.