Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Problem with refresh diagram programmatically
Problem with refresh diagram programmatically [message #1773768] Wed, 04 October 2017 12:08 Go to next message
Martin Jedlicka is currently offline Martin JedlickaFriend
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 #1774015 is a reply to message #1773768] Mon, 09 October 2017 08:42 Go to previous messageGo to next message
Martin Jedlicka is currently offline Martin JedlickaFriend
Messages: 122
Registered: January 2016
Senior Member
Hi,

Any idea to solve my problem?

Thank you very much.

Martin
Re: Problem with refresh diagram programmatically [message #1774038 is a reply to message #1774015] Mon, 09 October 2017 14:50 Go to previous messageGo to next message
Laurent Fasani is currently offline Laurent FasaniFriend
Messages: 182
Registered: October 2014
Senior Member
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 #1774071 is a reply to message #1774038] Tue, 10 October 2017 07:59 Go to previous messageGo to next message
Martin Jedlicka is currently offline Martin JedlickaFriend
Messages: 122
Registered: January 2016
Senior Member
Hi,

- I add a node in the xText editor, but the Sirius editor is closed.
- Because the Sirius editor is closed, so I need to do a program refresh (everything is running in the background) and the updated * .aird file is being saved.
- If I open Sirius editor, so yes. Sirius detects changes and restores content, but I do not open Sirius, because everything is done only in a program, and it opens up to the end user.
- When I do program refresh, DNode is updated (added) but GMFNode is not.
- There is nothing in the error log.

I do not know where it could be a problem.

Thanks.

Martin
Re: Problem with refresh diagram programmatically [message #1774472 is a reply to message #1774038] Mon, 16 October 2017 06:08 Go to previous messageGo to next message
Martin Jedlicka is currently offline Martin JedlickaFriend
Messages: 122
Registered: January 2016
Senior Member
Hi Laurent,

Any idea to solve my problem?

Thank you very much.

Martin
Re: Problem with refresh diagram programmatically [message #1774512 is a reply to message #1774472] Mon, 16 October 2017 15:18 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
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
Re: Problem with refresh diagram programmatically [message #1774558 is a reply to message #1774512] Tue, 17 October 2017 08:49 Go to previous message
Martin Jedlicka is currently offline Martin JedlickaFriend
Messages: 122
Registered: January 2016
Senior Member
Hi Maxime,

It works OK!

Thank you very much!

Martin
Previous Topic:Sirius benchmark
Next Topic:Copy & Past Context Menu in Tree Description
Goto Forum:
  


Current Time: Thu Apr 18 23:27:25 GMT 2024

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

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

Back to the top