Issues opening the correct diagram [message #1245129] |
Thu, 13 February 2014 05:36  |
Eclipse User |
|
|
|
Hello,
I am working at a DrillDown which operates by doubleclicking on an pictogramElement inside the first diagram. Then a new diagram is generated and linked to the BusinessObject related to the first pictogramElement. Now I want to open a new editor based on this diagram.
A new editor opens, but I cannot access the expected diagram, instead there is a new one with the same name and diagramTypeId.
Here is the code inside my DrillDown method for creating a new editor:
//Operating inside the first diagram
final String diagramTypeId = ...;
//the business element which is supposed to be linked to the newly opened diagram
final Behavior root = (Behavior)getBusinessObjectForPictogramElement(context.getInnerPictogramElement());
final String diagramName = root.getName();
final Diagram diagram = Graphiti.getPeCreateService().createDiagram(diagramTypeId, diagramName, true);
URI uri = root.eResource().getURI();
uri = uri.trimFragment();
uri = uri.trimFileExtension();
uri = uri.trimSegments(1);
uri = uri.appendSegment(root.getName());
uri = uri.appendFileExtension("diagram");
FileService.createEmfFileForDiagram(uri, diagram);
DiagramEditorInput editorInput = new DiagramEditorInput(uri,BehaviorDiagramTypeProvider.DIAGRAMTYPE_PROVIDER_ID);
//associates the new diagram with the business element the user clicked on
link(diagram, root);
try {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
activePage.openEditor(editorInput, DiagramEditor.DIAGRAM_EDITOR_ID);
} catch (PartInitException e) {
System.out.println("Fehler beim Öffnen des neuen Behavior Diagrams");
}
In the next steps I try to access the new diagram with getDiagram() with an unexpected effect. I find theSameRoot to be null since the Link object is not accessible and getBusinessObjectForPictogramElement() returns nothing.
//Operating inside the second diagram (opened from the first one)
Behavior theSameRoot = (Behavior) getBusinessObjectForPictogramElement(getDiagram());
I am thankful for some advice,
Dominik
[Updated on: Thu, 13 February 2014 08:17] by Moderator
|
|
|
|
Re: Issues opening the correct diagram [message #1248506 is a reply to message #1245911] |
Mon, 17 February 2014 05:38  |
Eclipse User |
|
|
|
Thank you for your reply Michael. I found my mistake. The linking between the "root Element" and the newly generated diagram works after I switched the link call to a part, before I create the file and the editorInput.
Now I can build a hierarchy between my diagrams where there is a link between each diagram and the "root BO" inside the next higher diagram. Also building the Model across several diagrams.
final String diagramName = root.getName();
final Diagram diagram = Graphiti.getPeCreateService().createDiagram(diagramTypeId, diagramName, true);
//associates the new diagram with the business element the user clicked on
link(diagram, root);
URI uri = root.eResource().getURI();
uri = uri.trimFragment();
uri = uri.trimFileExtension();
uri = uri.trimSegments(1);
uri = uri.appendSegment(root.getName());
uri = uri.appendFileExtension("diagram");
FileService.createEmfFileForDiagram(uri, diagram);
DiagramEditorInput editorInput = new DiagramEditorInput(uri,BehaviorDiagramTypeProvider.DIAGRAMTYPE_PROVIDER_ID);
|
|
|
Powered by
FUDForum. Page generated in 0.03784 seconds