Prevent unnecessary read transaction for synch master typical handle 59/2959/4
authorJaniSimomaa <JaniSimomaa@mongodb-primary>
Wed, 19 Jun 2019 11:11:48 +0000 (14:11 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 19 Jun 2019 22:43:30 +0000 (22:43 +0000)
gitlab #310

Change-Id: I09105b310bc892604ddab1f661343d442538b83a

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalInstanceWithTemplate.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalTemplateToInstances.java

index df95cb90df4f31fed66fbb17a5b4a2991b59719a..714e72eb6c05b7ee19637ff533bc2f6630c5a3ac 100644 (file)
@@ -16,6 +16,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances;
+import org.simantics.modeling.ui.diagramEditor.DiagramEditor;
 import org.simantics.modeling.ui.documents.OpenPlainTextDocumentAdapter;
 import org.simantics.modeling.ui.property.TypicalPropertyTester;
 import org.simantics.modeling.ui.typicals.RuleChooserDialog;
@@ -40,7 +41,7 @@ public class SyncCurrentTypicalInstanceWithTemplate {
             // TODO: This is not good practice with E4 but an OK fallback for now
             activeEditor = WorkbenchUtils.getActiveEditor();
         }
-        if (activeEditor == null)
+        if (activeEditor == null || (!(activeEditor instanceof DiagramEditor)))
             return false;
         if (DatabaseJob.inProgress())
             return false;
index 9936b603b32395d8cd0cdd7cb69f32f58effe6fa..bbafb03e0ce201b530166609745ac243fcdd3fd8 100644 (file)
@@ -16,6 +16,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.Session;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.modeling.typicals.SyncTypicalTemplatesToInstances;
+import org.simantics.modeling.ui.diagramEditor.DiagramEditor;
 import org.simantics.modeling.ui.documents.OpenPlainTextDocumentAdapter;
 import org.simantics.modeling.ui.property.TypicalPropertyTester;
 import org.simantics.modeling.ui.typicals.RuleChooserDialog;
@@ -39,7 +40,7 @@ public class SyncCurrentTypicalTemplateToInstances {
             // TODO: This is not good practice with E4 but an OK fallback for now
             activeEditor = WorkbenchUtils.getActiveEditor();
         }
-        if (activeEditor == null)
+        if (activeEditor == null || (!(activeEditor instanceof DiagramEditor)))
             return false;
         if (DatabaseJob.inProgress())
             return false;