Force pin action on all views
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 26 Oct 2016 23:14:10 +0000 (19:14 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 11 Nov 2016 15:36:07 +0000 (10:36 -0500)
From now on all views should show/act on a pin button by default.

For now override canBePinned to return false so no view shows the button.

Let's hope more views get this implemented in the future.

Change-Id: Ib312622a8dc8a926932639e6a5dc87f54db01456
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
25 files changed:
analysis/org.eclipse.tracecompass.analysis.graph.ui/src/org/eclipse/tracecompass/internal/analysis/graph/ui/criticalpath/view/CriticalPathView.java
analysis/org.eclipse.tracecompass.analysis.lami.ui/src/org/eclipse/tracecompass/internal/provisional/analysis/lami/ui/views/LamiReportView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/controlflow/ControlFlowView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyDensityView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/statistics/SystemCallLatencyStatisticsView.java
analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/resources/ResourcesView.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/density/AbstractSegmentStoreDensityView.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/statistics/AbstractSegmentStoreStatisticsView.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/table/SegmentStoreTableView.java
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/internal/analysis/timing/ui/flamegraph/FlameGraphView.java
lttng/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/vm/vcpuview/VirtualMachineView.java
lttng/org.eclipse.tracecompass.lttng2.ust.ui.swtbot.tests/src/org/eclipse/tracecompass/lttng2/ust/ui/swtbot/tests/CallStackViewTest.java
pcap/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/stream/StreamListView.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/latency/PatternLatencyTableView.java
tmf/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/views/statistics/TmfStatisticsViewImpl.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfChartView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/TmfView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/callstack/CallStackView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/colors/ColorsView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/filter/FilterView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/HistogramView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/statesystem/TmfStateSystemExplorer.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/synchronization/TmfSynchronizationView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java

index ce4cff904a61545c21764e9fa10412a1e551c096..cab40437bd2025463bab38a2cf1d5e9eed1ea8e1 100644 (file)
@@ -637,4 +637,9 @@ public class CriticalPathView extends AbstractTimeGraphView {
         setEndTime(end);
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index ed38dd6c26f529bea50e8f2c33a9785208b4ddbf..9fc4bd77e5dcd9dcfd04df2a52d7acde2da8853e 100644 (file)
@@ -188,4 +188,9 @@ public final class LamiReportView extends TmfView {
         return fTabPages.get(idx);
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index c135bef5fc3aca19d0355f855cb784c1e86e5884..6b36a97192516e8640db302022f6ea31a9f1bc17 100644 (file)
@@ -1053,4 +1053,11 @@ public class ControlFlowView extends AbstractStateSystemTimeGraphView {
         }
         return null;
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
+
 }
index a51d637b8e380e045bea454a56dd8d2af23e1223..c8ac12f1fd8ba116364129dabbfa1cfcc65b007a 100644 (file)
@@ -440,4 +440,9 @@ public class ResourcesView extends AbstractStateSystemTimeGraphView {
         ctx.setData(RESOURCES_FOLLOW_CPU, data);
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index b92e254676407dba55917491c774a86304564eda..3f5619738b5264ab2d4ec4f3c812eb144b5144ff 100644 (file)
@@ -144,4 +144,10 @@ public abstract class AbstractSegmentStoreDensityView extends TmfView {
     AbstractSegmentStoreDensityViewer getDensityViewer() {
         return fDensityViewer;
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
\ No newline at end of file
index 2c248c69a3a863566639578d8fcbaf6983086092..ebd79ad593271b596cd1373559cafe4b90173d26 100644 (file)
@@ -41,4 +41,10 @@ public class SegmentStoreTableView extends AbstractSegmentStoreTableView {
         String analysisId = NonNullUtils.nullToEmptyString(getViewSite().getSecondaryId());
         return new SegmentStoreTableViewer(tableViewer, analysisId);
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index 463b901a7c07660898ecad120d9a406915f5bf38..a4fee6a59f2975cb0edfebcce7600de006fd6da6 100644 (file)
@@ -447,4 +447,10 @@ public class FlameGraphView extends TmfView {
         }
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
+
 }
index 5b56d3075164db9bdffbbeefb398e896b7cca623..46a56ed28a731811b9a04f2efcac8e61447b28ca 100644 (file)
@@ -475,4 +475,9 @@ public class VirtualMachineView extends AbstractTimeGraphView {
         return Collections.singleton(trace);
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index de4ce52a3f7d1aaba00b00d4b05cb9885be5b6b3..bd95f8897d5ed1ce6c3c1b7b996ee1177b142031 100644 (file)
@@ -131,8 +131,11 @@ public class CallStackViewTest {
     private static final @NonNull String ZOOM_IN = "Zoom In";
     private static final @NonNull String ZOOM_OUT = "Zoom Out";
     // Separator
-    private static final String PIN_VIEW = "Pin View";
+    private static final @NonNull String PIN_VIEW = "Pin View";
+
     private static final List<String> TOOLBAR_BUTTONS_TOOLTIPS = ImmutableList.of(
+            PIN_VIEW,
+            "",
             ALIGN_VIEWS, CONFIGURE_SYMBOL_PROVIDERS,
             "",
             SORT_BY_NAME, SORT_BY_ID, SORT_BY_START,
@@ -143,9 +146,7 @@ public class CallStackViewTest {
             "",
             ADD_BOOKMARK, PREVIOUS_MARKER, NEXT_MARKER,
             "",
-            SELECT_PREVIOUS_ITEM, SELECT_NEXT_ITEM, ZOOM_IN, ZOOM_OUT,
-            "",
-            PIN_VIEW);
+            SELECT_PREVIOUS_ITEM, SELECT_NEXT_ITEM, ZOOM_IN, ZOOM_OUT);
 
     /**
      * Initialization
@@ -359,4 +360,4 @@ public class CallStackViewTest {
         }
         assertEquals(TOOLBAR_BUTTONS_TOOLTIPS, buttons);
     }
-}
\ No newline at end of file
+}
index 9f1326a434b97c33d69c385b07ae62cfca8f3ca2..5e2f91a6644032dac8307bf13b8fba0846f250dd 100644 (file)
@@ -509,4 +509,10 @@ public class StreamListView extends TmfView {
         }
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
+
 }
index 1324fbdb2f31c85337f722591a7dc812b943b9d3..b2317b2584037e2be5408d8b6b16160f70f88566 100644 (file)
@@ -580,4 +580,10 @@ public class XmlTimeGraphView extends AbstractTimeGraphView {
         return (trace != null) ? Collections.singleton(trace) : Collections.EMPTY_LIST;
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
+
 }
index bc817276e3afb81cf25ff176bc8e677fc39b1888..20c0a9e23739d5beaa4007fb5810b1c2e4a443b8 100755 (executable)
@@ -214,4 +214,10 @@ public class TmfStatisticsViewImpl extends TmfView {
         // Makes the global viewer visible
         fStatsViewers.setSelection(0);
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index b480b03a98b558452793f9371b4ca75908e655fd..07095d0e9c93671b4bd0b7dea26d4645439a66a0 100644 (file)
@@ -280,4 +280,10 @@ public abstract class TmfChartView extends TmfView implements ITmfTimeAligned {
         }
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
+
 }
index c9a3ab3cc01a13bd596c0858c46c0fae283afdbe..5a87af91757adb1cf27a80c67e41cd224bb2860b 100644 (file)
 
 package org.eclipse.tracecompass.tmf.ui.views;
 
+import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.events.ControlAdapter;
 import org.eclipse.swt.events.ControlEvent;
 import org.eclipse.swt.widgets.Composite;
@@ -108,18 +111,20 @@ public abstract class TmfView extends ViewPart implements ITmfComponent {
     // ------------------------------------------------------------------------
 
     /**
-     * Returns whether the pin flag is set.
-     * For example, this flag can be used to ignore time synchronization signals from other TmfViews.
+     * Returns whether the view is pinned.
      *
-     * @return pin flag
+     * @return if the view is pinned
      */
     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.
+     * Method adds a pin action to the TmfView. For example, this action can be
+     * used to ignore time synchronization signals from other TmfViews. <br>
+     *
+     * Uses {@link TmfView#setPinned(boolean)} to propagate the state of the
+     * action button.
      */
     protected void contributePinActionToToolBar() {
         if (fPinAction == null) {
@@ -130,11 +135,56 @@ public abstract class TmfView extends ViewPart implements ITmfComponent {
             toolBarManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
             toolBarManager.add(fPinAction);
         }
+
+        fPinAction.addPropertyChangeListener(new IPropertyChangeListener() {
+            @Override
+            public void propertyChange(PropertyChangeEvent event) {
+                if (IAction.CHECKED.equals(event.getProperty())) {
+                    /* Take action on the pin state */
+                    Object value = event.getNewValue();
+                    if (!(value instanceof Boolean)) {
+                        throw new IllegalStateException();
+                    }
+                    setPinned((Boolean) value);
+                }
+            }
+        });
+    }
+
+    /**
+     * TODO: change to abstract on API break <br>
+     * <br>
+     * When this method return <code>True</code> a toggle button is added to the
+     * view toolbar.<br>
+     * <br>
+     * One should implement {@link TmfView#setPinned(boolean)} to take action on state change.
+     *
+     * @return if the view can be pined
+     * @since 2.2
+     */
+    protected boolean canBePinned() {
+        return true;
+    }
+
+    /**
+     * TODO: change to abstract on API break
+     * Actions to take on pin property change.
+     * @param pinned
+     *            The pin state to take action on
+     * @since 2.2
+     */
+    protected synchronized void setPinned(boolean pinned) {
+        /** Do nothing by default */
     }
 
     @Override
     public void createPartControl(final Composite parent) {
         fParentComposite = parent;
+
+        if (canBePinned()) {
+            contributePinActionToToolBar();
+        }
+
         if (this instanceof ITmfTimeAligned) {
             contributeAlignViewsActionToToolbar();
 
index 6b2aa2484a89a786aad28a5e3707d938c9c9da55..b9e844997b075bf125d55c5b3b17413dcadcc16e 100644 (file)
@@ -35,8 +35,6 @@ import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.jface.viewers.DoubleClickEvent;
 import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelection;
@@ -422,7 +420,6 @@ public class CallStackView extends AbstractTimeGraphView {
             }
         });
 
-        contributeToActionBars();
         loadSortOption();
 
         IEditorPart editor = getSite().getPage().getActiveEditor();
@@ -909,27 +906,25 @@ public class CallStackView extends AbstractTimeGraphView {
         fNextItemAction.setToolTipText(Messages.TmfTimeGraphViewer_NextItemActionToolTipText);
     }
 
-    private void contributeToActionBars() {
-        // Create pin action
-        contributePinActionToToolBar();
-        fPinAction.addPropertyChangeListener(new IPropertyChangeListener() {
-            @Override
-            public void propertyChange(PropertyChangeEvent event) {
-                if (IAction.CHECKED.equals(event.getProperty()) && !isPinned()) {
-                    if (fSavedRangeSyncSignal != null) {
-                        windowRangeUpdated(fSavedRangeSyncSignal);
-                        fSavedRangeSyncSignal = null;
-                    }
-
-                    if (fSavedTimeSyncSignal != null) {
-                        selectionRangeUpdated(fSavedTimeSyncSignal);
-                        fSavedTimeSyncSignal = null;
-                    }
-                }
-            }
-        });
+    /**
+     * @since 2.2
+     */
+    @Override
+    protected synchronized void setPinned(boolean pinned) {
+       if (!pinned) {
+           if (fSavedRangeSyncSignal != null) {
+               windowRangeUpdated(fSavedRangeSyncSignal);
+               fSavedRangeSyncSignal = null;
+           }
+
+           if (fSavedTimeSyncSignal != null) {
+               selectionRangeUpdated(fSavedTimeSyncSignal);
+               fSavedTimeSyncSignal = null;
+           }
+       }
     }
 
+
     /**
      * @since 1.2
      */
index 6ec9935a5fd68688db2fcbac4a2251411297fcf1..2534d293db19ea86bd5b0fb6ceea232a5d79d2ef 100644 (file)
@@ -590,4 +590,10 @@ public class ColorsView extends TmfView {
         }
 
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index 6a0b872bb352979df6eaa15e7a3136d60ef7c713..d2cfbee758b3b411573044653b8debedf29be54f 100644 (file)
@@ -319,4 +319,10 @@ public class FilterView extends TmfView {
         }
     }
 
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
+
 }
\ No newline at end of file
index a580e02f4ab80781b3b541234c07e75ea9acb7e2..6ebf6b5df4d8d187c306306a6f363fc761329718 100644 (file)
@@ -1020,4 +1020,10 @@ public class HistogramView extends TmfView implements ITmfTimeAligned {
             return point;
         }
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index 88a4719b2aad047fb671bf7a17e0d2a01c1da425..dec18cfb01ebf8f54fa94aa7a8dd14c3a9cae887 100644 (file)
@@ -105,4 +105,10 @@ public class TmfStateSystemExplorer extends TmfView {
             fViewer.dispose();
         }
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index 0f5c16233dfb2a9d791003c6ff0182cac8146a0d..20ea05dc9d2d260121cb1d9c7aa04072d6b7be96 100644 (file)
@@ -151,4 +151,10 @@ public class TmfSynchronizationView extends TmfView {
             });
         }
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
index 28a198ed714d7b8a1f129b92c51b882066cd7220..8e5da70f6a59ca4270fa0f5eb81c044de3c26cd4 100644 (file)
@@ -814,4 +814,10 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
     public void performAlign(int offset, int width) {
         fViewer.performAlign(offset, width);
     }
+
+    @Override
+    protected boolean canBePinned() {
+        //TODO: actionPin is not defined
+        return false;
+    }
 }
This page took 0.036296 seconds and 5 git commands to generate.