Bug 573098 - Switching perspective gives ClassCastException
Change-Id: I8b68872ecdafa1ed5046aeb2f6869b9070eabd02
Signed-off-by: Kalyan Prasad Tatavarthi <kalyan_prasad@in.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/179713
Tested-by: Platform Bot <platform-bot@eclipse.org>
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java
index e97ba74..b318217 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CoolBarToTrimManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2017 IBM Corporation and others.
+ * Copyright (c) 2011, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -156,7 +156,8 @@
return;
}
- MToolBar toolBar = (MToolBar) modelService.find(item.getId(), window);
+ List<MToolBar> toolbars = modelService.findElements(window, item.getId(), MToolBar.class);
+ MToolBar toolBar = toolbars.isEmpty() ? null : toolbars.get(0);
boolean tbFound = toolBar != null;
if (!tbFound) {
toolBar = modelService.createModelElement(MToolBar.class);