Navigate through diagrams of different types [message #835654] |
Tue, 03 April 2012 14:02 |
Laurent Le Moux Messages: 184 Registered: September 2011 |
Senior Member |
|
|
Hi there,
I defined two different models and the corresponding diagrams.
The first model / diagram called 'Device Overview' (DO) lets me describe a 'device' that may use a 'component'.
The component itself is described in a 'Component Detail' (CD) model / diagram.
The plug-in works fine and - thanks to the help of this forum - I can even drag a component from a CD model and drop it on a DO diagram.
Now I would like to double-click on the component shortcut in the DO diagram, to open the correponding CD diagram.
I had a look to several posts and also the Jevon diagram partitionning tutorial.
I did the following actions :
1. I loaded the CD.gmfmap file as a resource for the DO.gmfmap.
2. In the DO.gmfmap, there's a declaration for a Component Top Node Reference.
At that level, I modified the Node Mapping 'Misc/Related Diagrams' property.
I selected the CD.gmfmap canvas.
3. I regenerated the corresponding DO.gmfgen file. The generator adds an 'open diagram behaviour' in Gen Diagram -> Gen Top Level Component.
So far so good...
4. I then modified the 'Diagram kind' and 'Editor ID' as requested by selecting the corresponding values in CD.gmfgen.
After regenerating the DO.diagram project, I get the following exception when double-clicking on the component shorcut in the DO diagram.
org.eclipse.core.commands.ExecutionException: Can't open diagram
at deviceoverview.diagram.edit.policies.OpenDiagramEditPolicy$OpenDiagramCommand.doExecuteWithResult(OpenDiagramEditPolicy.java:106)
and then :
Caused by: org.eclipse.core.commands.ExecutionException: Can't create diagram of 'ComponentDetail' kind
at deviceoverview.diagram.edit.policies.OpenDiagramEditPolicy$OpenDiagramCommand.intializeNewDiagram(OpenDiagramEditPolicy.java:124)
at deviceoverview.diagram.edit.policies.OpenDiagramEditPolicy$OpenDiagramCommand.doExecuteWithResult(OpenDiagramEditPolicy.java:95)
I had a look to the generated OpenDiagramEditPolicy.java file and more precisely to the following doExecuteWithResult method :
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
try {
Diagram diagram = getDiagramToOpen();
if (diagram == null) {
diagram = intializeNewDiagram();
}
URI uri = EcoreUtil.getURI(diagram);
String editorName = uri.lastSegment() + '#'
+ diagram.eResource().getContents().indexOf(diagram);
IEditorInput editorInput = new URIEditorInput(uri, editorName);
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
page.openEditor(editorInput, getEditorID());
return CommandResult.newOKCommandResult();
} catch (Exception ex) {
throw new ExecutionException("Can't open diagram", ex);
}
}
It appears that the program fails to get the diagram to open. It then tries to initialize a new diagram that also fails.
I don't want a new diagram to be created but the right and existing one to be opened .
So I had a closer look to getDiagramToOpen. It simply returns the value of the 'diagramLink' attribute from the 'diagramFacet' object.
But, strange enough, this diagram link is null and I don't understand why.
Could anybody tell me what's wrong ?
The gmfgraph and gmfgen files are in the DeviceCore project.
I also upload the plug-in directory with the sample models.
Regards,
Laurent
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02795 seconds