|Problem with refresh diagram programmatically [message #1773768]
||Wed, 04 October 2017 12:08
| Martin Jedlicka
Registered: January 2016
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);
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.
[Updated on: Mon, 09 October 2017 08:37]
Report message to a moderator
|Re: Problem with refresh diagram programmatically [message #1774512 is a reply to message #1774472]
||Mon, 16 October 2017 15:18
|| Maxime Porhel
Registered: July 2009
Location: Nantes, France
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);
// We are during the opening, the diagramEditPart is not
// available, but we synchronize the GMF diag
CanonicalSynchronizer canonicalSynchronizer = CanonicalSynchronizerFactory.INSTANCE.createCanonicalSynchronizer(gmfDiag);
Command synchronizeG[code][/code]MFModel = new SynchronizeGMFModelCommand(getEditingDomain(), canonicalSynchronizer);
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);
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.
Maxime Porhel - Obeo
Need training or professional services for Sirius?
Join the Sirius community at SiriusCon. Register for free: Nov. 9th Paris
Powered by FUDForum
. Page generated in 0.01989 seconds