tmf: Handle 'null' active pages in views
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / TmfView.java
index bf487fd32e8ec5d5c321fa9826ceb23e9f50d3e3..04a0f9bcaad3934020f45ebd09bfd0d84dc98465 100644 (file)
@@ -1,42 +1,64 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
- * 
+ * Copyright (c) 2009, 2010, 2012 Ericsson
+ *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  * Contributors:
  *   Francois Chouinard - Initial API and implementation
+ *   Bernd Hufmann - Added possibility to pin view
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.views;
 
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
 import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
-import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.part.ViewPart;
 
 /**
- * <b><u>TmfView</u></b>
- * <p>
- * TODO: Implement me. Please.
+ * Basic abstract TMF view class implementation.
+ *
+ * It registers any sub class to the signal manager for receiving and sending
+ * TMF signals.
+ *
+ * @version 1.2
+ * @author Francois Chouinard
  */
 public abstract class TmfView extends ViewPart implements ITmfComponent {
 
        private final String fName;
-       
+       /**
+        * Action class for pinning of TmfView.
+        * @since 2.0
+        */
+       protected PinTmfViewAction fPinAction;
+
        // ------------------------------------------------------------------------
        // Constructor
        // ------------------------------------------------------------------------
 
+       /**
+        * Constructor. Creates a TMF view and registers to the signal manager.
+        *
+        * @param viewName A view name
+        */
        public TmfView(String viewName) {
                super();
                fName = viewName;
                TmfSignalManager.register(this);
        }
 
+       /**
+        * Disposes this view and de-registers itself from the signal manager
+        *
+        * @see org.eclipse.ui.part.WorkbenchPart#dispose()
+        */
        @Override
        public void dispose() {
                TmfSignalManager.deregister(this);
@@ -47,28 +69,54 @@ public abstract class TmfView extends ViewPart implements ITmfComponent {
        // ITmfComponent
        // ------------------------------------------------------------------------
 
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#getName()
+        */
        @Override
        public String getName() {
                return fName;
        }
-       
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.core.component.ITmfComponent#broadcast(org.eclipse.linuxtools.tmf.core.signal.TmfSignal)
+        */
        @Override
        public void broadcast(TmfSignal signal) {
                TmfSignalManager.dispatchSignal(signal);
        }
 
-       // ------------------------------------------------------------------------
-       // ViewPart
-       // ------------------------------------------------------------------------
-       
-       @Override
-       public void createPartControl(Composite parent) {
-               // TODO Auto-generated method stub
-       }
+    // ------------------------------------------------------------------------
+    // View pinning support
+    // ------------------------------------------------------------------------
 
-       @Override
-       public void setFocus() {
-               // TODO Auto-generated method stub
-       }
+    /**
+     * Returns whether the pin flag is set.
+     * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
+     *
+     * @return pin flag
+     * @since 2.0
+     */
+    public boolean isPinned() {
+        return ((fPinAction != null) && (fPinAction.isChecked()));
+    }
+
+    /**
+     * Method adds a pin action to the TmfView. The pin action allows to toggle the <code>fIsPinned</code> flag.
+     * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
+     *
+     * @since 2.0
+     */
+    protected void contributePinActionToToolBar() {
+        if (fPinAction == null) {
+            fPinAction = new PinTmfViewAction();
+
+            IToolBarManager toolBarManager = getViewSite().getActionBars()
+                    .getToolBarManager();
+            toolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+            toolBarManager.add(fPinAction);
+        }
+    }
 
-}
\ No newline at end of file
+}
This page took 0.04506 seconds and 5 git commands to generate.