From 95144e3b879f0a10715927027bb9a7aa8e05bdeb Mon Sep 17 00:00:00 2001 From: JaniSimomaa Date: Wed, 19 Jun 2019 14:11:48 +0300 Subject: [PATCH] Prevent unnecessary read transaction for synch master typical handle gitlab #310 Change-Id: I09105b310bc892604ddab1f661343d442538b83a --- .../ui/handlers/e4/SyncCurrentTypicalInstanceWithTemplate.java | 3 ++- .../ui/handlers/e4/SyncCurrentTypicalTemplateToInstances.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalInstanceWithTemplate.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalInstanceWithTemplate.java index df95cb90d..714e72eb6 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalInstanceWithTemplate.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalInstanceWithTemplate.java @@ -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; diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalTemplateToInstances.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalTemplateToInstances.java index 9936b603b..bbafb03e0 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalTemplateToInstances.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/handlers/e4/SyncCurrentTypicalTemplateToInstances.java @@ -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; -- 2.47.1