Faster bounds calculation for zoom to selection and navigate to target
[simantics/platform.git] / bundles / org.simantics.charts / src / org / simantics / charts / editor / e4 / MoveHairlineHandler.java
index 1d0508d5799de4bb89f2366366a483e2620f964b..62d7955a2f4a0d5cc2f4bc43104ba5b66be6cd13 100644 (file)
@@ -1,81 +1,81 @@
-package org.simantics.charts.editor.e4;\r
-\r
-import java.util.List;\r
-\r
-import javax.inject.Named;\r
-\r
-import org.eclipse.e4.core.di.annotations.CanExecute;\r
-import org.eclipse.e4.core.di.annotations.Execute;\r
-import org.eclipse.e4.ui.di.AboutToHide;\r
-import org.eclipse.e4.ui.di.AboutToShow;\r
-import org.eclipse.e4.ui.model.application.ui.basic.MPart;\r
-import org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem;\r
-import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;\r
-import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;\r
-import org.eclipse.e4.ui.services.IServiceConstants;\r
-import org.simantics.charts.editor.TrackExperimentTimeAction;\r
-import org.simantics.trend.configuration.TrendSpec;\r
-import org.simantics.trend.impl.ItemNode;\r
-import org.simantics.trend.impl.TrendNode;\r
-import org.simantics.trend.impl.TrendParticipant;\r
-\r
-public class MoveHairlineHandler {\r
-\r
-    @AboutToShow\r
-    public void aboutToShow(List<MMenuElement> items) {\r
-        MDirectMenuItem menuItem = MMenuFactory.INSTANCE.createDirectMenuItem();\r
-        menuItem.setContributionURI("bundleclass://org.simantics.charts/org.simantics.charts.editor.e4.MoveHairlineHandler");\r
-        menuItem.setLabel("Move Hairline Here");\r
-        items.add(menuItem);\r
-    }\r
-    \r
-    @AboutToHide\r
-    public void aboutToHide() {\r
-        \r
-    }\r
-    \r
-    @CanExecute\r
-    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {\r
-        if (activePart != null && activePart.getObject() instanceof TimeSeriesEditor) {\r
-            TimeSeriesEditor editor = (TimeSeriesEditor) activePart.getObject();\r
-            \r
-            TrendNode trendNode = editor.trendNode;\r
-            TrendParticipant tp = editor.tp;\r
-            if (trendNode == null || tp == null)\r
-                return false;\r
-            \r
-            TrendSpec trendSpec = trendNode.getTrendSpec();\r
-            boolean hairlineMovementAllowed =\r
-                    !(trendSpec.experimentIsRunning &&\r
-                      trendSpec.viewProfile.trackExperimentTime);\r
-            \r
-            return hairlineMovementAllowed;\r
-        }\r
-        return false;\r
-    }\r
-    \r
-    @Execute\r
-    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {\r
-        if (activePart.getObject() instanceof TimeSeriesEditor) {\r
-            TimeSeriesEditor editor = (TimeSeriesEditor) activePart.getObject();\r
-            \r
-            TrendNode trendNode = editor.trendNode;\r
-            TrendParticipant tp = editor.tp;\r
-            if (trendNode == null || tp == null)\r
-                return;\r
-\r
-            TrendSpec trendSpec = trendNode.getTrendSpec();\r
-            ItemNode hoverItem = tp.hoveringItem;\r
-            \r
-            // #TODO Finish this when we are fully in E4 workbench\r
-            \r
-//            trend.valueTipTime = time;\r
-//            trend.repaint();\r
-//            if (setTrackExperimentTime != null) {\r
-//                TrackExperimentTimeAction.setTracking(chart, setTrackExperimentTime);\r
-//            }\r
-            \r
-        }\r
-    }\r
-\r
-}\r
+package org.simantics.charts.editor.e4;
+
+import java.util.List;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.CanExecute;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.di.AboutToHide;
+import org.eclipse.e4.ui.di.AboutToShow;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MDirectMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.simantics.charts.editor.TrackExperimentTimeAction;
+import org.simantics.trend.configuration.TrendSpec;
+import org.simantics.trend.impl.ItemNode;
+import org.simantics.trend.impl.TrendNode;
+import org.simantics.trend.impl.TrendParticipant;
+
+public class MoveHairlineHandler {
+
+    @AboutToShow
+    public void aboutToShow(List<MMenuElement> items) {
+        MDirectMenuItem menuItem = MMenuFactory.INSTANCE.createDirectMenuItem();
+        menuItem.setContributionURI("bundleclass://org.simantics.charts/org.simantics.charts.editor.e4.MoveHairlineHandler");
+        menuItem.setLabel("Move Hairline Here");
+        items.add(menuItem);
+    }
+    
+    @AboutToHide
+    public void aboutToHide() {
+        
+    }
+    
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {
+        if (activePart != null && activePart.getObject() instanceof TimeSeriesEditor) {
+            TimeSeriesEditor editor = (TimeSeriesEditor) activePart.getObject();
+            
+            TrendNode trendNode = editor.trendNode;
+            TrendParticipant tp = editor.tp;
+            if (trendNode == null || tp == null)
+                return false;
+            
+            TrendSpec trendSpec = trendNode.getTrendSpec();
+            boolean hairlineMovementAllowed =
+                    !(trendSpec.experimentIsRunning &&
+                      trendSpec.viewProfile.trackExperimentTime);
+            
+            return hairlineMovementAllowed;
+        }
+        return false;
+    }
+    
+    @Execute
+    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {
+        if (activePart.getObject() instanceof TimeSeriesEditor) {
+            TimeSeriesEditor editor = (TimeSeriesEditor) activePart.getObject();
+            
+            TrendNode trendNode = editor.trendNode;
+            TrendParticipant tp = editor.tp;
+            if (trendNode == null || tp == null)
+                return;
+
+            TrendSpec trendSpec = trendNode.getTrendSpec();
+            ItemNode hoverItem = tp.hoveringItem;
+            
+            // #TODO Finish this when we are fully in E4 workbench
+            
+//            trend.valueTipTime = time;
+//            trend.repaint();
+//            if (setTrackExperimentTime != null) {
+//                TrackExperimentTimeAction.setTracking(chart, setTrackExperimentTime);
+//            }
+            
+        }
+    }
+
+}