Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Connection creation throws exception
Connection creation throws exception [message #1219067] Sat, 30 November 2013 22:13 Go to next message
Luca Gherardi is currently offline Luca GherardiFriend
Messages: 60
Registered: November 2010
Member
Hi all,

I'm developing a GMF editor and I have an annoying problem.

I'm modeling a component based system. This is the hierarchy:

A System contains Composites and Containers.
Containers and Composites can contains AbstractComponents and EndPoints.
Component and Composite are two subclasses of AbstractComponent, which is an abstract class.
Components have input and output ports, which can be connected by means of the class Connection, which holds a reference to an input port and an output port.
Connection are stored in the classes Composite and Container, according to the connected components.

Composite and Container figures have a compartment in which I can insert the components and endpoint figures.


When I launch the editor
- I'm able to create and visualize connection between components created into a composite. The connection is stored in the composite and drawn.
- however when I try to create a connection between ports of components created into a container it throws an exception. Despite the exception the connection is actually created in the model and stored in the container, but it is not drawn in the diagram. Also if I close and reopen the diagram the connection is not visible.

This is the exception:

org.eclipse.core.commands.ExecutionException: While executing the operation, an exception occurred
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:521)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:206)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:169)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:156)
	at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:425)
	at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:438)
	at org.eclipse.gmf.runtime.diagram.ui.tools.ConnectionCreationTool.handleCreateConnection(ConnectionCreationTool.java:342)
	at org.eclipse.gmf.runtime.diagram.ui.tools.ConnectionCreationTool.handleButtonUp(ConnectionCreationTool.java:182)
	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:220)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4166)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4012)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3651)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	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:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: org.eclipse.core.runtime.AssertionFailedException: null argument:failed to create a view
	at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
	at org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand.doExecuteWithResult(CreateCommand.java:96)
	at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:134)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:134)
	at org.eclipse.gmf.runtime.common.core.command.CompositeCommand.doExecuteWithResult(CompositeCommand.java:403)
	at org.eclipse.gmf.runtime.common.core.command.AbstractCommand.execute(AbstractCommand.java:134)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:513)
	... 42 more



This is the part of the xml which model the connections between ports:

<links>
    <domainMetaElement
        href="../models/componentModel.ecore#//Connection"/>
    <labelMappings>
      <diagramLabel
          href="../../xyz/diagrams/componentModels.gmfgraph#SolidWireConnectionName"/>
    </labelMappings>
    <containmentFeature
        href="../models/componentModel.ecore#//Composite/compositeConnections"/>
    <tool
        xsi:type="gmftool:CreationTool"
        href="componentModel.gmftool#//@palette/@tools.1/@tools.1"/>
    <diagramLink
        href="../../xyz/diagrams/componentModels.gmfgraph#SolidWireConnection"/>
    <sourceMetaFeature
        xsi:type="ecore:EReference"
        href="../models/componentModel.ecore#//Connection/client"/>
    <linkMetaFeature
        xsi:type="ecore:EReference"
        href="../models/componentModel.ecore#//Connection/server"/>
    <creationConstraints>
      <sourceEnd
          body="eContainer().eContainer().oclIsKindOf(Composite)"/>
      <targetEnd
          body="eContainer().eContainer().oclIsKindOf(Composite)"/>
    </creationConstraints>
  </links>
  <links>
    <domainMetaElement
        href="../models/componentModel.ecore#//Connection"/>
    <labelMappings>
      <diagramLabel
          href="../../xyz/diagrams/componentModels.gmfgraph#SolidWireConnectionName"/>
    </labelMappings>
    <containmentFeature
        href="../models/componentModel.ecore#//Container/containerConnections"/>
    <tool
        xsi:type="gmftool:CreationTool"
        href="componentModel.gmftool#//@palette/@tools.1/@tools.1"/>
    <diagramLink
        href="../../xyz/diagrams/componentModels.gmfgraph#SolidWireConnection"/>
    <sourceMetaFeature
        xsi:type="ecore:EReference"
        href="../models/componentModel.ecore#//Connection/client"/>
    <linkMetaFeature
        xsi:type="ecore:EReference"
        href="../models/componentModel.ecore#//Connection/server"/>
    <creationConstraints>
      <sourceEnd
          body="eContainer().eContainer().oclIsKindOf(Container)"/>
      <targetEnd
          body="eContainer().eContainer().oclIsKindOf(Container)"/>
    </creationConstraints>
  </links>


Please tell me if you need further information. I really don't know what could be and couldn't be useful in the amount of information I have defined for this editor.
Thanks in advance.

[Updated on: Sun, 01 December 2013 15:25]

Report message to a moderator

Re: Connection creation throws exception [message #1219304 is a reply to message #1219067] Tue, 03 December 2013 09:06 Go to previous message
Luca Gherardi is currently offline Luca GherardiFriend
Messages: 60
Registered: November 2010
Member
Hi all,

I found at that the issue can be resolved by using two different entities for the connections.
In other words, I have defined two specializations of the class Connection and I use them, one for the composite connections and the other for the container connections.

While it works, I don't understand why I have to define two classes for representing the same exact information.

Thanks!
Previous Topic:Model transformation on EditPart
Next Topic:How to create an EReference programmatically?
Goto Forum:
  


Current Time: Mon Nov 24 14:25:47 GMT 2014

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

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