Problem with refresh diagram programmatically [message #1773768] |
Wed, 04 October 2017 12:08 |
Martin Jedlicka Messages: 122 Registered: January 2016 |
Senior Member |
|
|
Hi,
I have a question to refresh the graphical representation programmatically.
I have two editors (xText and Sirius). If I add the node (PRC_002_O002) to diagram in xText , that node I connect to another node (create edge), and finally call programmatically refresh (see below).
1. DialectManager.INSTANCE.refresh(diagram, true, getProgressMonitor()); or
2. representation.refresh(); or
3. Command cmd = new RefreshRepresentationsCommand(domain, true, getProgressMonitor(), representation);
domain.getCommandStack().execute(cmd);
so I see in the * .aird (see PRC_002.Master.25_ERROR.aird) file that the node (PRC_002_O002) has been added to ownedDiagramElements, but the node and edge has not been added to ownedAnnotationEntries (source GMF_DIAGRAMS).
This means that when I open the diagram, at this time is added to the node and edge ownedAnnotationEntries (see PRC_002.Master.25_OK.aird).
I would need to keep the ownedAnnotationEntries (source GMF_DIAGRAMS) up to date with the first (programmatically) refresh.
How do I make a programmatically refresh to make it OK?
Thanks for every advice.
Martin
[Updated on: Mon, 09 October 2017 08:37] Report message to a moderator
|
|
|
|
Re: Problem with refresh diagram programmatically [message #1774038 is a reply to message #1774015] |
Mon, 09 October 2017 14:50 |
|
Hi
If I understand well, you create from an external editor(xtext) a semantic element (PRC_002_O002) and other semantic element which consequence should be to diplay the node PRC_002_O002 in the diagram and an edge to other represented element.
In that case, when you save your xtext editor, Sirius detects an external change, reload the changed resource and refreshes the impacted representations. Then if your mapping is synchronized or unsynchronizable with diagram synchronized, both DNode and GMFNode should be created during the refresh.
Perhaps something wrong happened during the refresh. Do you have something in your errror log?
Regards
Laurent
Laurent Fasani - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
Re: Problem with refresh diagram programmatically [message #1774512 is a reply to message #1774472] |
Mon, 16 October 2017 15:18 |
|
Hi Martin,
DDiagram.refresh() and RefreshRepresentationCommand will call DialectManager.INSTANCE.refresh(this, false, progressMonitor) (for diagrams the boolean parameter has currently no effect).
Note that in the standard lifecycle of a Sirius session, the GMF model is synchronized and updated thanks to a precommit listener.
If you look into the opening of the DDiagramEditorImpl,
org.eclipse.emf.common.command.CompoundCommand CompoundCommand compoundCommand = new CompoundCommand();
Command refreshOnOpeningCmd = new RefreshDiagramOnOpeningCommand(getEditingDomain(), dDiagram);
compoundCommand.append(refreshOnOpeningCmd);
compoundCommand.setLabel(refreshOnOpeningCmd.getLabel());
// We are during the opening, the diagramEditPart is not
// already
// available, but we synchronize the GMF diag
CanonicalSynchronizer canonicalSynchronizer = CanonicalSynchronizerFactory.INSTANCE.createCanonicalSynchronizer(gmfDiag);
Command synchronizeG[code][/code]MFModel = new SynchronizeGMFModelCommand(getEditingDomain(), canonicalSynchronizer);
compoundCommand.append(synchronizeGMFModel);
command = compoundCommand;
I am not sure you need RefreshDiagramOnOpeningCommand, a RefreshRepresentationCommand might be sufficient in your case.
On calls to DialectUIManager.export/exportWithResult methode we also resynchronize the GMF model by calling
CanonicalSynchronizer canonicalSynchronizer = CanonicalSynchronizerFactory.INSTANCE.createCanonicalSynchronizer(diagram);
canonicalSynchronizer.storeViewsToArrange(false);
canonicalSynchronizer.synchronize();
}
Regarding your context and if you are already in an EMF command, you can call the DialectManager.refresh and the synchronize methods, otherwise you will need to go with the "command" classes.
Regards
Maxime Porhel - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.06729 seconds