Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » What happens after DiagramDialectUIServices.openEditor?
What happens after DiagramDialectUIServices.openEditor? [message #1834440] Tue, 10 November 2020 12:18 Go to next message
Yufei Zhou is currently offline Yufei ZhouFriend
Messages: 44
Registered: March 2020
Member
Hi,

I am trying to create a element's representation programmatically by using the api org.eclipse.sirius.business.api.dialect.DialectManager.createRepresentation and DiagramDialectUIServices.openEditor. The api works fine and it indeed creates a diagram representation and opens it, but there's one thing strange. After I executed these methods and calls a session.save to save the current session, the opened diagram was momently saved, but after half or one second the diagram editor becomes dirty again, and a star sign(which indicates the diagram is not properly saved) appears on the editor page label.

I really wonder what happed after I called DiagramDialectUIServices.openEditor, why the editor was saved but turn dirty again? Who modified the diagram? Is there any way to make the diagram representation properly saved just after it was created and opened? It's kind of important to my application. Any hint or advice will helps.

Thanks for your help very much.
Yufei Zhou

[Updated on: Tue, 10 November 2020 12:31]

Report message to a moderator

Re: What happens after DiagramDialectUIServices.openEditor? [message #1834485 is a reply to message #1834440] Wed, 11 November 2020 09:58 Go to previous messageGo to next message
Yufei Zhou is currently offline Yufei ZhouFriend
Messages: 44
Registered: March 2020
Member
I found the method that sirius would trigger after editor open: its org.eclipse.sirius.diagram.ui.internal.refresh.layout.SiriusCanonicalLayoutCommand.executeLayoutDueToExternalChanges.

Now the problem is how to sync the model before this method triggers and save the external changes manually. I believe that just as the method's name indicating, if there is no external changes detected, then the method will not be executed. I guess there will be an api for saving the external changes after a new diagram representation is newly-created. Could someone give me a hint?
Re: What happens after DiagramDialectUIServices.openEditor? [message #1834549 is a reply to message #1834485] Thu, 12 November 2020 09:34 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 262
Registered: August 2010
Senior Member
Hi,

Indeed, the first time a diagram is opened, an arrange all is automatically launched. To detect the first opening, an adapter is added (NotYetOpenedDiagramAdapter) by calling org.eclipse.sirius.diagram.business.internal.dialect.NotYetOpenedDiagramAdapter.markAsToArrange(DDiagram).
Before calling your opening action, you can remove this adapter:
if (targetDiagram.eAdapters().contains(NotYetOpenedDiagramAdapter.INSTANCE)) {
targetDiagram.eAdapters().remove(NotYetOpenedDiagramAdapter.INSTANCE);
}

Regards,

Florian
Re: What happens after DiagramDialectUIServices.openEditor? [message #1834561 is a reply to message #1834549] Thu, 12 November 2020 13:02 Go to previous message
Yufei Zhou is currently offline Yufei ZhouFriend
Messages: 44
Registered: March 2020
Member
Thank you very much Florian, I've managed to solve this problem.
Previous Topic:How to access an EObject's position and size?
Next Topic:Accessing attributes to set up pre/post-conditions
Goto Forum:
  


Current Time: Tue Apr 20 14:24:19 GMT 2021

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

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

Back to the top