]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.simulation.ui/src/org/simantics/simulation/ui/handlers/Reload.java
Remove usage of deprecated SimanticsUI-methods
[simantics/platform.git] / bundles / org.simantics.simulation.ui / src / org / simantics / simulation / ui / handlers / Reload.java
index 0f9699a1f1070f629872334a667401f6c7160a69..335023b8f27c792e18f995c041d096c34dcb60c7 100644 (file)
@@ -1,67 +1,68 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.simulation.ui.handlers;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.core.runtime.Status;\r
-import org.eclipse.core.runtime.jobs.Job;\r
-import org.simantics.ObjectIdentitySchedulingRule;\r
-import org.simantics.simulation.experiment.IExperiment;\r
-import org.simantics.simulation.project.IExperimentManager;\r
-import org.simantics.simulation.ui.Activator;\r
-import org.simantics.ui.SimanticsUI;\r
-\r
-public class Reload extends AbstractHandler {\r
-\r
-    @Override\r
-    public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        IExperimentManager manager =\r
-            SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
-        IExperiment experiment = manager.getActiveExperiment();\r
-        if (experiment != null) {\r
-            Job j = new RefreshJob(experiment);\r
-            j.setRule(new ObjectIdentitySchedulingRule(experiment));\r
-            j.schedule();\r
-        }\r
-        return null;\r
-    }\r
-\r
-    static class RefreshJob extends Job {\r
-        private final IExperiment experiment;\r
-\r
-        public RefreshJob(IExperiment experiment) {\r
-            super("Refresh Experiment");\r
-            this.experiment = experiment;\r
-        }\r
-\r
-        @Override\r
-        protected IStatus run(IProgressMonitor monitor) {\r
-            try {\r
-                monitor.beginTask("", IProgressMonitor.UNKNOWN);\r
-                experiment.refresh(SimanticsUI.getSession());\r
-                if (monitor.isCanceled())\r
-                    return Status.CANCEL_STATUS;\r
-                return Status.OK_STATUS;\r
-            } catch (Throwable t) {\r
-                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to refresh experiment "\r
-                        + experiment + " with ID " + experiment.getIdentifier(), t);\r
-            } finally {\r
-                monitor.done();\r
-            }\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * 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:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.simulation.ui.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.simantics.ObjectIdentitySchedulingRule;
+import org.simantics.Simantics;
+import org.simantics.simulation.experiment.IExperiment;
+import org.simantics.simulation.project.IExperimentManager;
+import org.simantics.simulation.ui.Activator;
+import org.simantics.ui.SimanticsUI;
+
+public class Reload extends AbstractHandler {
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        IExperimentManager manager =
+            Simantics.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);
+        IExperiment experiment = manager.getActiveExperiment();
+        if (experiment != null) {
+            Job j = new RefreshJob(experiment);
+            j.setRule(new ObjectIdentitySchedulingRule(experiment));
+            j.schedule();
+        }
+        return null;
+    }
+
+    static class RefreshJob extends Job {
+        private final IExperiment experiment;
+
+        public RefreshJob(IExperiment experiment) {
+            super("Refresh Experiment");
+            this.experiment = experiment;
+        }
+
+        @Override
+        protected IStatus run(IProgressMonitor monitor) {
+            try {
+                monitor.beginTask("", IProgressMonitor.UNKNOWN);
+                experiment.refresh(Simantics.getSession());
+                if (monitor.isCanceled())
+                    return Status.CANCEL_STATUS;
+                return Status.OK_STATUS;
+            } catch (Throwable t) {
+                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to refresh experiment "
+                        + experiment + " with ID " + experiment.getIdentifier(), t);
+            } finally {
+                monitor.done();
+            }
+        }
+    }
+
+}