From: jsimomaa Date: Mon, 25 Feb 2019 09:25:15 +0000 (+0200) Subject: Fix typical toolbar calculations to not throw ClassCastExceptions X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F56%2F2856%2F1;p=simantics%2Fplatform.git Fix typical toolbar calculations to not throw ClassCastExceptions gitlab #264 Change-Id: I352dcf48397f76986a44c01494a7ff5c89852f4a (cherry picked from commit d8a328f8b97add888a0c89af1052978a226b7784) --- 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