Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 353097

Summary: While trying to add the GMF generated editor inside a MultiPageEditor, throws ClassCastException
Product: [Modeling] GMF-Tooling Reporter: bunta Choudhary <abhishek.choudhary>
Component: CoreAssignee: Project Inbox <gmp.gmf-tooling-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: earl.waldin
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description bunta Choudhary CLA 2011-07-26 07:48:48 EDT
Build Identifier: 

I developed a normal GMF project provided with the Shape example . 
Now I tried to add the same inside a MultiPageEditor like this inside addPage method.


editor = new ShapesDiagramEditor();
int index = addPage(editor, getEditorInput());
setPageText(index, "Design");


Page added successfully but as soon as I click on the property tab named Rulers and Grid , it throws a classcastException as -

java.lang.ClassCastException: multipageeditor.editors.MultiPageEditor cannot be cast to org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart
	at org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid.RulerGridPropertySection.initWorkspacePropertyListener(RulerGridPropertySection.java:879)
	at org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid.RulerGridPropertySection.setInput(RulerGridPropertySection.java:624)
	at org.eclipse.ui.views.properties.tabbed.TabContents$5.run(TabContents.java:181)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.ui.views.properties.tabbed.TabContents.setInput(TabContents.java:184)
	at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage$SelectionChangedListener.selectionChanged(TabbedPropertySheetPage.java:212)
	at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java:162)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:160)
	at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:2162)
	at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:1190)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:1220)
	at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:228)
	at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:222)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:389)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
	at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList.select(TabbedPropertyList.java:664)
	at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList$2.mouseUp(TabbedPropertyList.java:156)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:213)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)



Reproducible: Always

Steps to Reproduce:
1.Create a GMF Project
2.Generate the Diagram Code
3.Create a MultiPageEditor sample project provided by eclipse.
4.Inside MultiPageEditor.java , inside the method named createPage0 , I added the code as I mentioned above.
Comment 1 E. Waldin CLA 2012-03-06 06:05:47 EST
See the article 

http://www.eclipse.org/articles/article.php?file=Article-Integrating-EMF-GMF-Editors/index.html

You'll find lots of information about putting a GMF editor into a multi-page editor. In particular, you'll have to implement IDiagramWorkbenchPart as described there.