Problem with refresh diagram programmatically [message #1773768] |
Wed, 04 October 2017 08:08  |
Eclipse User |
|
|
|
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 04:37] by Moderator
|
|
|
|
|
|
|
Re: Problem with refresh diagram programmatically [message #1774512 is a reply to message #1774472] |
Mon, 16 October 2017 11:18   |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.04099 seconds