From d924aa9e2691606e0bc8044cce01aff4abcc7bc9 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Thu, 8 Nov 2018 09:03:03 +0200 Subject: [PATCH] Add DatabaseJob.inProgress() checking to certain UI-handlers gitlab #186 Change-Id: Ib8d547a54ffefde6ebf887e162d3adc8479c6de4 --- .../simantics/modeling/ui/actions/e4/EditStyleHandler.java | 4 +++- .../handlers/e4/SyncCurrentTypicalInstanceWithTemplate.java | 3 +++ .../ui/handlers/e4/SyncCurrentTypicalTemplateToInstances.java | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/e4/EditStyleHandler.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/e4/EditStyleHandler.java index 40c76d747..d02778d55 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/e4/EditStyleHandler.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/e4/EditStyleHandler.java @@ -23,6 +23,7 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.services.IServiceConstants; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor; +import org.simantics.DatabaseJob; import org.simantics.Simantics; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; @@ -59,7 +60,8 @@ public class EditStyleHandler { return false; if (s == null) return false; - + if (DatabaseJob.inProgress()) + return false; final Resource[] resources = ResourceAdaptionUtils.toResources(s); if (resources.length != 0) { if (!Arrays.equals(resources, lastResources)) { 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 0c9641a27..9e5862480 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 @@ -10,6 +10,7 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor; +import org.simantics.DatabaseJob; import org.simantics.Simantics; import org.simantics.db.Resource; import org.simantics.db.Session; @@ -41,6 +42,8 @@ public class SyncCurrentTypicalInstanceWithTemplate { } if (activeEditor == null) return false; + if (DatabaseJob.inProgress()) + return false; IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput(); return TypicalPropertyTester.isTypicalInstanceEditor(Simantics.getSession(), input.getResource()); } 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 0678d5c3b..3558aaa62 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 @@ -10,6 +10,7 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.internal.e4.compatibility.CompatibilityEditor; +import org.simantics.DatabaseJob; import org.simantics.Simantics; import org.simantics.db.Resource; import org.simantics.db.Session; @@ -40,6 +41,8 @@ public class SyncCurrentTypicalTemplateToInstances { } if (activeEditor == null) return false; + if (DatabaseJob.inProgress()) + return false; IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput(); return TypicalPropertyTester.isTypicalMasterEditor(Simantics.getSession(), input.getResource()); } -- 2.47.1