Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » DiagramImpl ClassCastException
DiagramImpl ClassCastException [message #196977] Mon, 14 July 2008 18:38 Go to next message
Eclipse UserFriend
Originally posted by: dkdlel.gmail.com

I got an ClasCastingException on the below code. I tried to cast the
return value of getModel but it generated exception.


public class DiagramEditPart extends
org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart {

private Diagram getCastedModel() {
return (Diagram) getModel();
}

..
..
}



java.lang.ClassCastException:
org.eclipse.gmf.runtime.notation.impl.DiagramImpl cannot be cast to
Test.Diagram
at
Test.diagram.edit.parts.DiagramEditPart.getCastedModel(Diagr amEditPart.java:122)
at
Test.diagram.edit.parts.DiagramEditPart.getModelChildren(Dia gramEditPart.java:81)
at
org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:709)
at
org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractE ditPart.java:677)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh( AbstractGraphicalEditPart.java:571)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$3(GraphicalEditPart.java:1)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt$3.run(GraphicalEditPart.java:839)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:289)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.refresh(GraphicalEditPart.java:829)
at
org.eclipse.gef.editparts.AbstractEditPart.addNotify(Abstrac tEditPart.java:235)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotif y(AbstractGraphicalEditPart.java:219)
at
org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:198)
at
org.eclipse.gef.editparts.SimpleRootEditPart.setContents(Sim pleRootEditPart.java:101)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:601)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer.setContents(DiagramGraphicalViewer.java:378)
at
org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents( AbstractEditPartViewer.java:610)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewerContents(DiagramEditor.java:868)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.initi alizeGraphicalViewer(DiagramEditor.java:861)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.initializeGraphicalViewer(DiagramEditorWithFlyOu tPalette.java:116)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat eGraphicalViewer(DiagramEditor.java:805)
at
org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(G raphicalEditor.java:163)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.creat ePartControl(DiagramEditor.java:1550)
at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFl yOutPalette.createPartControl(DiagramEditorWithFlyOutPalette .java:328)
at
org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.Di agramDocumentEditor.createPartControl(DiagramDocumentEditor. java:1459)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:661)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
at
org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(Ed itorAreaHelper.java:263)
at
org.eclipse.ui.internal.EditorManager.setVisibleEditor(Edito rManager.java:1410)
at
org.eclipse.ui.internal.EditorManager$5.runWithException(Edi torManager.java:944)
at
org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:132)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3759)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3384)
at
org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:803)
at
org.eclipse.ui.internal.Workbench$27.runWithException(Workbe nch.java:1365)
at
org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:132)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3759)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3384)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2305)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 10)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:494)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:489)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:112)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
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(EclipseS tarter.java:379)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.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: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Re: DiagramImpl ClassCastException [message #197321 is a reply to message #196977] Wed, 16 July 2008 10:05 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Mel,

Looks like you've used incorrect "Diagram" class (you have two classes with
this name in different packages). You should use org.eclipse.gmf.runtime.notation.Diagram
instead of Test.Diagram.

-----------------
Alex Shatalin
Previous Topic:bug on generation
Next Topic:Which environment for GMF development ?
Goto Forum:
  


Current Time: Mon May 25 06:04:41 GMT 2020

Powered by FUDForum. Page generated in 0.02529 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top