Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » OpenDiagramEditPolicy
OpenDiagramEditPolicy [message #705957] Sat, 30 July 2011 16:50 Go to next message
Aris  is currently offline Aris
Messages: 14
Registered: July 2011
Junior Member
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
Re: OpenDiagramEditPolicy [message #705969 is a reply to message #705957] Sat, 30 July 2011 17:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26088
Registered: July 2009
Senior Member
Aris,

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
Re: OpenDiagramEditPolicy [message #705990 is a reply to message #705969] Sat, 30 July 2011 17:41 Go to previous messageGo to next message
Aris  is currently offline Aris
Messages: 14
Registered: July 2011
Junior Member
Hi Ed,

Thanks for the quick reply.

A similar bug there is there: https://bugs.eclipse.org/bugs/show_bug.cgi?id=306394

The stack trace is:


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 posted this because I can't understand If I am doing something wrong or there is a bug. I followed the instructions as mentioned in:
http://wiki.eclipse.org/Diagram_Partitioning#Usecase_1_.22same_type.22

Thanks again,

Aris
Re: OpenDiagramEditPolicy [message #707349 is a reply to message #705990] Mon, 01 August 2011 14:43 Go to previous messageGo to next message
Aris  is currently offline Aris
Messages: 14
Registered: July 2011
Junior Member
Hi again,

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?

Thanks,

Aris
Re: OpenDiagramEditPolicy [message #716092 is a reply to message #707349] Tue, 16 August 2011 12:48 Go to previous messageGo to next message
Aris  is currently offline Aris
Messages: 14
Registered: July 2011
Junior Member
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());

Re: OpenDiagramEditPolicy [message #918782 is a reply to message #705957] Fri, 21 September 2012 10:44 Go to previous messageGo to next message
Dan Tololoi is currently offline Dan Tololoi
Messages: 33
Registered: September 2012
Location: Iasi, Romania
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?
Re: OpenDiagramEditPolicy [message #934250 is a reply to message #918782] Fri, 05 October 2012 19:45 Go to previous messageGo to next message
Aurelien Pupier is currently offline Aurelien Pupier
Messages: 564
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

you can update the generation templates, see http://www.bonitasoft.org/blog/eclipse/customize-your-gmf-editor-by-customizing-templates/

regards,


Aurélien Pupier - Bonitasoft S.A.
My company Eclipse-related blog
Re: OpenDiagramEditPolicy [message #939107 is a reply to message #705957] Wed, 10 October 2012 12:35 Go to previous message
Dan Tololoi is currently offline Dan Tololoi
Messages: 33
Registered: September 2012
Location: Iasi, Romania
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 Sad and this was not the intention.

Previous Topic:How to get properties element in EditPart programatically?
Next Topic:Infer EReference from a CompartmentEditPart
Goto Forum:
  


Current Time: Wed Oct 01 12:19:33 GMT 2014

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

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