Project: Eclipse_Platform_UI
Bug 43581 [MPE] MultiPageEditorPart has class cast error in pageChange
Reported: 2003-09-24 11:20:49 | Status: verified fixed

I have attached a GEF GraphicalEditor to a tab in a MultipageEditor (as generated by EMF). import org.eclipse.gef.ui.parts.GraphicalEditor; protected GraphicalEditor gefEditor; ... addPage(gefEditor, gefEditor.getEditorInput()); ... When I select the tab with the GraphicalEditor I get the a class cast exception in the following line in MultiPageEditorPart. ((MultiPageSelectionProvider) getSite().getSelectionProvider()).fireSelectionChanged(event); getSelectionProvider is expected to return an ISelectionProvider, so the cast ought to be subject to an instanceof first IMO. Or there should be some way of preventing non-proficient eclipse programmers attaching something that is not an MultiPageSelectionProvider. Perhaps I am just missing out on something, configuring the right selection provider for the gef editor, perhaps, but I cannot see any setSelectionProvider() method on the GraphicalEditor. The stacktrace is here: !ENTRY org.eclipse.ui 4 4 sep 24, 2003 16:28:52.703 !MESSAGE Unhandled exception caught in event loop. !ENTRY org.eclipse.ui 4 0 sep 24, 2003 16:28:52.718 !MESSAGE java.lang.ClassCastException !STACK 0 java.lang.ClassCastException at org.eclipse.ui.part.MultiPageEditorPart.pageChange(MultiPageEditorPart.java:414) at com.nds.core.epg.designer.model.presentation.ModelEditor.pageChange(ModelEditor.java:1005) at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:133) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:848) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:872) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:665) at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:1742) at org.eclipse.swt.custom.CTabFolder.onMouseDown(CTabFolder.java:1930) at org.eclipse.swt.custom.CTabFolder.access$4(CTabFolder.java:1922) at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:201) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:848) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2188) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1878) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1680) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1663) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java