Bug 391957 - [Contributions] ClassCastException with action sets:OpaqueToolItemImpl cannot be cast to MTrimElement Change-Id: I3501f1bfe17aff65645ea27b8f77d1f2ebe53493 Also-by: Daniel Rolka <daniel.rolka@pl.ibm.com> Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
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 9fb812c..ffd511e 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, 2013 IBM Corporation and others. + * Copyright (c) 2011, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -263,11 +263,12 @@ * @see org.eclipse.jface.action.IContributionManager#find(java.lang.String) */ public IContributionItem find(String id) { - MTrimElement el = (MTrimElement) modelService.find(id, window); - if (el == null || !(el instanceof MToolBar)) + List<MToolBar> toolbars = modelService.findElements(window, id, MToolBar.class, null); + if (toolbars.isEmpty()) { return null; + } - final MToolBar model = (MToolBar) el; + final MToolBar model = toolbars.get(0); if (model.getTransientData().get(OBJECT) != null) { return (IContributionItem) model.getTransientData().get(OBJECT); }