Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Issues opening the correct diagram(.. the expected diagram is not opened)
Issues opening the correct diagram [message #1245129] Thu, 13 February 2014 10:36 Go to next message
Dominik Schwindling is currently offline Dominik SchwindlingFriend
Messages: 3
Registered: July 2013
Location: Germany
Junior Member
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 13:17]

Report message to a moderator

Re: Issues opening the correct diagram [message #1245911 is a reply to message #1245129] Fri, 14 February 2014 12:48 Go to previous messageGo to next message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Dominik,

I guess the reason for this is that Graphiti uses a new
TransactionalEditingDomain for each editor. Each editing domain has its own
ResourceSet with its own Resouces and EObjects. So for each new editor you
will end up with a different intances of your diagram (resolved within the
editing domain of the editor).

Is that what you meant with "new one"?

Michael
Re: Issues opening the correct diagram [message #1248506 is a reply to message #1245911] Mon, 17 February 2014 10:38 Go to previous message
Dominik Schwindling is currently offline Dominik SchwindlingFriend
Messages: 3
Registered: July 2013
Location: Germany
Junior Member
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); 
		
Previous Topic:Flyout Palette
Next Topic:The diagramUpdateFeature ignores isAutoUpdateAtRuntime
Goto Forum:
  


Current Time: Fri Apr 19 23:23:18 GMT 2024

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

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

Back to the top