From 5a840d8dafdbb828e5de0a012fadd67f8e2150c3 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Mon, 25 Feb 2019 11:25:15 +0200 Subject: [PATCH] Fix typical toolbar calculations to not throw ClassCastExceptions gitlab #264 Change-Id: I352dcf48397f76986a44c01494a7ff5c89852f4a (cherry picked from commit d8a328f8b97add888a0c89af1052978a226b7784) --- .../e4/SyncCurrentTypicalInstanceWithTemplate.java | 8 ++++++-- .../e4/SyncCurrentTypicalTemplateToInstances.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 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 9e5862480..df95cb90d 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 @@ -44,8 +44,12 @@ public class SyncCurrentTypicalInstanceWithTemplate { return false; if (DatabaseJob.inProgress()) return false; - IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput(); - return TypicalPropertyTester.isTypicalInstanceEditor(Simantics.getSession(), input.getResource()); + if (activeEditor.getEditorInput() instanceof IResourceEditorInput) { + IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput(); + return TypicalPropertyTester.isTypicalInstanceEditor(Simantics.getSession(), input.getResource()); + } else { + return false; + } } @Execute 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 3558aaa62..9936b603b 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 @@ -43,8 +43,12 @@ public class SyncCurrentTypicalTemplateToInstances { return false; if (DatabaseJob.inProgress()) return false; - IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput(); - return TypicalPropertyTester.isTypicalMasterEditor(Simantics.getSession(), input.getResource()); + if (activeEditor.getEditorInput() instanceof IResourceEditorInput) { + IResourceEditorInput input = (IResourceEditorInput) activeEditor.getEditorInput(); + return TypicalPropertyTester.isTypicalMasterEditor(Simantics.getSession(), input.getResource()); + } else { + return false; + } } @Execute -- 2.47.1