I am trying to enable double click in a node in order to open a new diagram of the same type. I made the appropriate changes in .gmfmap and .gmfgen. However when i double click the node I always get the following exception:
org.eclipse.core.commands.ExecutionException: Can't open diagram
The stack trace doesn't give you a clue? You've used the debugger to
trace the logic that leads to this exception?
On 30/07/2011 9:50 AM, Aris wrote:
> Hi,
>
> I am trying to enable double click in a node in order to open a new
> diagram of the same type. I made the appropriate changes in .gmfmap
> and .gmfgen. However when i double click the node I always get the
> following exception:
>
> org.eclipse.core.commands.ExecutionException: Can't open diagram
>
> Any ideas if I am doing something wrong?
>
> Thanks in advance,
>
> Aris
org.eclipse.core.commands.ExecutionException: Can't open diagram
at GSN1.diagram.edit.policies.OpenDiagramEditPolicy$OpenDiagramCommand.doExecuteWithResult(OpenDiagramEditPolicy.java:111)
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.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511)
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.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.performRequest(GraphicalEditPart.java:1125)
at org.eclipse.gef.tools.SelectEditPartTracker.performOpen(SelectEditPartTracker.java:194)
at org.eclipse.gef.tools.SelectEditPartTracker.handleDoubleClick(SelectEditPartTracker.java:137)
at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.handleDoubleClick(DragEditPartsTrackerEx.java:242)
at org.eclipse.gef.tools.AbstractTool.mouseDoubleClick(AbstractTool.java:1069)
at org.eclipse.gef.tools.SelectionTool.mouseDoubleClick(SelectionTool.java:525)
at org.eclipse.gef.EditDomain.mouseDoubleClick(EditDomain.java:231)
at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseDoubleClicked(DomainEventDispatcher.java:291)
at org.eclipse.draw2d.LightweightSystem$EventHandler.mouseDoubleClick(LightweightSystem.java:518)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:189)
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:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
Caused by: org.eclipse.core.commands.ExecutionException: Can't create diagram of 'GSN1' kind
at GSN1.diagram.edit.policies.OpenDiagramEditPolicy$OpenDiagramCommand.intializeNewDiagram(OpenDiagramEditPolicy.java:130)
at GSN1.diagram.edit.policies.OpenDiagramEditPolicy$OpenDiagramCommand.doExecuteWithResult(OpenDiagramEditPolicy.java:100)
... 41 more
I found where exactly the problem is, however I can't do something for that.
The problem is in the method getDiagramDomainElement() in class OpenDiagramEditPolicy. The URI that is related with the EObject which the getDiagramDomainElement() returns is something like this: platform:/resource/GSN/default.gsn1.
I created manually an EObject using an absolute URI and it works fine.
Any ideas how this can be fixed?
Hi again.
The problem was remained. So I change a bit the generated code to solve it. Spicifically the initialzeNewDiagram function in OpenDiagramEditPolicy class.
Below is the change I made:
I replaced the:
Diagram d = ViewService.createDiagram(getDiagramDomainElement(),
getDiagramKind(), getPreferencesHint());
with:
EObject domainRoot = null;
//load the domain model resource
ResourceSet domainResourceSet =new ResourceSetImpl();
domainResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
URI dU=getDiagramDomainElement().eResource().getURI();
Resource domainResource =domainResourceSet.getResource(dU, true);
domainRoot =(EObject) domainResource.getContents().get(0);
Diagram d = ViewService.createDiagram(domainRoot,getDiagramKind(), getPreferencesHint());
Dan Tololoi Messages: 21 Registered: September 2012 Location: Iasi, Romania
Junior Member
Indeed this also solves my "same" problem. Thanks for this solution.
Is there a way to integrate this piece of code to the generated? I mean to have it customized in this desired way at the generation time?
Dan Tololoi Messages: 21 Registered: September 2012 Location: Iasi, Romania
Junior Member
Ok. That will be a nice solution to have the customized code to the generated one. I did it already for emf using templates. Thanks!
Coming to the opening, the code modified above only opens a new editor , I add there elements and I expect that the new diagram will be saved ( to a generated name) . But the behavior I have is that all the elements in the sub-diagram appear in the initial one and this was not the intention.