joergreichert / spray

Automatically exported from code.google.com/p/spray
1 stars 2 forks source link

ClassCastException when creating new diagram shape #159

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
import BusinessDomainDsl.*

diagram mydiagram for BusinessDomainModel

   class BusinessClass icon "ecore/EClass.gif" {
    shape org.eclipselabs.spray.shapes.RectangleShape {
        name into businessClassText
    }
     behavior {
       // Enable create feature for this class and add it to the palette "Shapes"
       create into types palette "Shapes";
     }
   }

 shape RectangleShape style org.eclipselabs.spray.styles.Neu {
     rectangle style org.eclipselabs.spray.styles.Neu {
         position(x=0,y=0)
         size(width=100,height=100)
         style (background-color = org.eclipselabs.spray.styles.gradients.Neuer)
         text {
            position(x=5,y=5) 
            size(width=90,height=50)
             style (background-color=yellow)
            id = businessClassText
         }
     }
 }

style MydiagramDefaultStyle {
    description = "The default style of the mydiagram diagram type."
    // transparency = 0.95
    background-color = org.eclipselabs.spray.styles.gradients.Neuer
    // line-color = black
    // line-style = solid
    // line-width = 1
    // font-color = black
    // font-name = "Tahoma"
    font-size = 12
    // font-bold = yes
}

gradient Neuer {
    area (color=blue, offset=0.0)
    area (color=white, offset=1.0)
}

style Neu extends org.eclipselabs.spray.styles.MydiagramDefaultStyle {
    background-color = green
}

!ENTRY org.eclipse.graphiti.ui 4 0 2012-09-02 10:21:05.675
!MESSAGE GFCommandStack.execute(Command) java.lang.ClassCastException: 
org.eclipse.emf.ecore.impl.EObjectImpl cannot be cast to 
BusinessDomainDsl.BusinessDomainModel
!STACK 0
java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EObjectImpl cannot be 
cast to BusinessDomainDsl.BusinessDomainModel
    at org.eclipselabs.spray.examples.mydiagram.diagram.MydiagramModelService.getModel(MydiagramModelService.java:46)
    at org.eclipselabs.spray.examples.mydiagram.features.MydiagramCreateBusinessClassFeatureBase.createBusinessClass(MydiagramCreateBusinessClassFeatureBase.java:84)
    at org.eclipselabs.spray.examples.mydiagram.features.MydiagramCreateBusinessClassFeatureBase.create(MydiagramCreateBusinessClassFeatureBase.java:58)
    at org.eclipse.graphiti.features.impl.AbstractCreateFeature.execute(AbstractCreateFeature.java:100)
    at org.eclipse.graphiti.internal.command.GenericFeatureCommandWithContext.execute(GenericFeatureCommandWithContext.java:64)
    at org.eclipse.graphiti.internal.command.GFPreparableCommand.doExecute(GFPreparableCommand.java:37)
    at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
    at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:90)
    at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
    at org.eclipse.graphiti.internal.command.CommandExec.executeCommand(CommandExec.java:75)
    at org.eclipse.graphiti.ui.internal.command.CreateModelObjectCommand.execute(CreateModelObjectCommand.java:54)
    at org.eclipse.graphiti.ui.internal.editor.EmfOnGefCommand.execute(EmfOnGefCommand.java:59)
    at org.eclipse.graphiti.internal.command.GFPreparableCommand2.doExecute(GFPreparableCommand2.java:37)
    at org.eclipse.emf.transaction.RecordingCommand.execute(RecordingCommand.java:135)
    at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFCommandOperation.java:119)
    at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
    at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
    at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
    at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
    at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:71)
    at org.eclipse.graphiti.ui.internal.editor.GFCommandStack.execute(GFCommandStack.java:124)
    at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:425)
    at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:438)
    at org.eclipse.gef.tools.CreationTool.performCreation(CreationTool.java:269)
    at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTool.java:189)
    at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java:1200)
    at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:301)
    at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseReleased(DomainEventDispatcher.java:380)
    at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(LightweightSystem.java:548)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:219)
    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:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    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:344)
    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:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

Original issue reported on code.google.com by de.abg.r...@gmail.com on 2 Sep 2012 at 8:59

GoogleCodeExporter commented 9 years ago
This happens when you have an open diagram editor, close eclipse and open it 
again. The reference to the businessclassmodel is an EObject which seems a 
proxy to the real object and therefore the cast goes wrong. Don't know why this 
isn't simply resolved.

Original comment by joswar...@gmail.com on 19 Nov 2012 at 2:55

GoogleCodeExporter commented 9 years ago
Tried to resolve the proxy using EcoreUtil(2).resolve(object, resourceset),  
but this does not make any difference.

Original comment by joswar...@gmail.com on 19 Nov 2012 at 3:30

GoogleCodeExporter commented 9 years ago
Proxy resolved by getting the resource set and finding the object through its 
URI.

Original comment by joswar...@gmail.com on 19 Nov 2012 at 3:44