tmf: Improve histogram responsiveness
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / TmfView.java
CommitLineData
b0d3496e 1/*******************************************************************************
c8422608 2 * Copyright (c) 2009, 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 /**
ea279a69
FC
58 * Disposes this view and de-registers itself from the signal manager
59 *
2f2265e2
BH
60 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
61 */
8f50c396
FC
62 @Override
63 public void dispose() {
2fb2eb37 64 TmfSignalManager.deregister(this);
8f50c396
FC
65 super.dispose();
66 }
67
e31e01e8
FC
68 // ------------------------------------------------------------------------
69 // ITmfComponent
70 // ------------------------------------------------------------------------
71
2f2265e2
BH
72 /*
73 * (non-Javadoc)
74 * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#getName()
75 */
d4011df2 76 @Override
fc6ccf6f
FC
77 public String getName() {
78 return fName;
79 }
013a5f1c 80
2f2265e2
BH
81 /*
82 * (non-Javadoc)
83 * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#broadcast(org.eclipse.linuxtools.tmf.core.signal.TmfSignal)
84 */
d4011df2 85 @Override
e31e01e8 86 public void broadcast(TmfSignal signal) {
8d2e2848
FC
87 TmfSignalManager.dispatchSignal(signal);
88 }
89
ea279a69
FC
90 // ------------------------------------------------------------------------
91 // View pinning support
92 // ------------------------------------------------------------------------
93
db59ddc2
BH
94 /**
95 * Returns whether the pin flag is set.
96 * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
97 *
98 * @return pin flag
9da25000 99 * @since 2.0
db59ddc2
BH
100 */
101 public boolean isPinned() {
102 return ((fPinAction != null) && (fPinAction.isChecked()));
103 }
104
105 /**
106 * Method adds a pin action to the TmfView. The pin action allows to toggle the <code>fIsPinned</code> flag.
107 * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
108 *
9da25000 109 * @since 2.0
db59ddc2
BH
110 */
111 protected void contributePinActionToToolBar() {
112 if (fPinAction == null) {
113 fPinAction = new PinTmfViewAction();
114
115 IToolBarManager toolBarManager = getViewSite().getActionBars()
116 .getToolBarManager();
117 toolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
118 toolBarManager.add(fPinAction);
119 }
120 }
ea279a69 121
013a5f1c 122}
This page took 0.047111 seconds and 5 git commands to generate.