]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/SyncCurrentTypicalInstanceWithTemplate.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / typicals / SyncCurrentTypicalInstanceWithTemplate.java
index 3b1455f37057e1f3098b81174d83f511ef069ace..e8f1eeeee33d5ee6f828efdf3a3724c5ebb7c5f7 100644 (file)
@@ -1,61 +1,61 @@
-package org.simantics.modeling.ui.typicals;\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.jface.dialogs.MessageDialog;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.IEditorPart;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.simantics.Simantics;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances;\r
-import org.simantics.modeling.ui.documents.OpenPlainTextDocumentAdapter;\r
-import org.simantics.modeling.ui.property.TypicalPropertyTester;\r
-import org.simantics.ui.workbench.IResourceEditorInput;\r
-import org.simantics.utils.ui.ErrorLogger;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- *\r
- */\r
-public class SyncCurrentTypicalInstanceWithTemplate extends AbstractHandler {\r
-\r
-    @Override\r
-    public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        Shell shell = HandlerUtil.getActiveShell(event);\r
-        IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);\r
-        IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput();\r
-        Session session = Simantics.getSession();\r
-\r
-//        if (!MessageDialog\r
-//                .openConfirm(shell,\r
-//                        "Synchronize Typical Instance With Template",\r
-//                        "Are you sure you want to synchronize this typical instance with its template?"))\r
-//            return null;\r
-\r
-        try {\r
-            if (!TypicalPropertyTester.isTypicalInstanceEditor(session, input.getResource())) {\r
-                MessageDialog.openInformation(shell, "Not Synchronizing", "Currently active editor is not a typical diagram instance editor.");\r
-                return null;\r
-            }\r
-\r
-            RuleChooserDialog.RuleResult result = RuleChooserDialog.choose(shell, "Synchronizing typical instance with its template.", new Resource[] { input.getResource() });\r
-            if(result == null) return null;\r
-\r
-            session.markUndoPoint();\r
-            SyncTypicalTemplatesToInstances req = SyncTypicalTemplatesToInstances.syncSingleInstance(result.selectedRules, input.getResource()).logging(result.logging); \r
-            session.syncRequest(req);\r
-            if (result.logging) {\r
-                for(Resource log : req.logs)\r
-                    new OpenPlainTextDocumentAdapter().openEditor(log);\r
-            }\r
-        } catch (Exception e) {\r
-            ErrorLogger.defaultLogError(e);\r
-        }\r
-        return null;\r
-        \r
-    }\r
-\r
-}\r
+package org.simantics.modeling.ui.typicals;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances;
+import org.simantics.modeling.ui.documents.OpenPlainTextDocumentAdapter;
+import org.simantics.modeling.ui.property.TypicalPropertyTester;
+import org.simantics.ui.workbench.IResourceEditorInput;
+import org.simantics.utils.ui.ErrorLogger;
+
+/**
+ * @author Tuukka Lehtonen
+ *
+ */
+public class SyncCurrentTypicalInstanceWithTemplate extends AbstractHandler {
+
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        Shell shell = HandlerUtil.getActiveShell(event);
+        IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
+        IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput();
+        Session session = Simantics.getSession();
+
+//        if (!MessageDialog
+//                .openConfirm(shell,
+//                        "Synchronize Typical Instance With Template",
+//                        "Are you sure you want to synchronize this typical instance with its template?"))
+//            return null;
+
+        try {
+            if (!TypicalPropertyTester.isTypicalInstanceEditor(session, input.getResource())) {
+                MessageDialog.openInformation(shell, "Not Synchronizing", "Currently active editor is not a typical diagram instance editor.");
+                return null;
+            }
+
+            RuleChooserDialog.RuleResult result = RuleChooserDialog.choose(shell, "Synchronizing typical instance with its template.", new Resource[] { input.getResource() });
+            if(result == null) return null;
+
+            session.markUndoPoint();
+            SyncTypicalTemplatesToInstances req = SyncTypicalTemplatesToInstances.syncSingleInstance(result.selectedRules, input.getResource()).logging(result.logging); 
+            session.syncRequest(req);
+            if (result.logging) {
+                for(Resource log : req.logs)
+                    new OpenPlainTextDocumentAdapter().openEditor(log);
+            }
+        } catch (Exception e) {
+            ErrorLogger.defaultLogError(e);
+        }
+        return null;
+        
+    }
+
+}