Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Modify sirius model via handler
Modify sirius model via handler [message #1786104] Wed, 25 April 2018 15:49 Go to next message
Lina 20 is currently offline Lina 20Friend
Messages: 32
Registered: March 2017
Member
Hi,

I need to "animate" a sirius diagram by changing the WorkspacePath of some nodes. I have found code to do that. [1] But my problem is to acces the diagram that already existed. The example create a new diagram.

I create a new toolbar element that calls a handler who executes the code (this part works). But i do not know hot to acces the current diagram to modify some nodes.
index.php/fa/32693/0/

I think about javaservice but it need to be anchored with an element. I want the diagram to look like running a simulation engine in spite of not doing it.

I really apreciate your help! Thank you!

Lina.

[1]https://www.eclipse.org/forums/index.php/t/881677/
  • Attachment: Captura.PNG
    (Size: 10.67KB, Downloaded 401 times)
Re: Modify sirius model via handler [message #1786166 is a reply to message #1786104] Thu, 26 April 2018 11:37 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 270
Registered: August 2010
Senior Member
Hi Lina,

Why do not use conditional styles for your nodes ? If the action change the state of your model, Sirius will perform a refresh of the representation (if the auto-refresh is activated).
To answer your question, you can retrieve the diagram from the current active editor with something like that:

DiagramEditor editorPart = (DiagramEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
editorPart.getDiagram()


This project [1] may also help you if you need more information to animate your diagram.
See also [2]

[1] https://www.eclipse.org/sirius/lab.html
[2] http://gemoc.org/breathe-life-into-your-designer
Re: Modify sirius model via handler [message #1786199 is a reply to message #1786166] Thu, 26 April 2018 17:44 Go to previous messageGo to next message
Lina 20 is currently offline Lina 20Friend
Messages: 32
Registered: March 2017
Member
Hi Florian, Thanks for your answer.

I already access to the diagram but I have another trouble. When I try to modify the node property this error appear : Cannot modify resource set without a write transaction

iI find that an emf transaction must change the image path [1]. but I do not undestand how to create a command to excecute. I find this EMF commands [2]

So I am stuck with this
CommandStack cs = domain.getCommandStack();
Command cmd = domain.createCommand(SetCommand.class, new CommandParameter(richmond, EXTLibraryPackage.Literals.LIBRARY__ADDRESS, "5600 Perth St."));*
cs.execute(cmd);

* This is an example I took from a website but I do not know how to create a command class.


I appreciate your help!

Lina
[1]https://www.linuxtopia.org/online_books/eclipse_documentation/eclipse_emf_model_transaction_developer_guide/topic/org.eclipse.emf.transaction.doc/references/overview/eclipse_emf_model_transaction_creating.html

[2]http://download.eclipse.org/modeling/emf/emf/javadoc/2.4.3/org/eclipse/emf/common/command/Command.html
Re: Modify sirius model via handler [message #1786223 is a reply to message #1786199] Fri, 27 April 2018 07:28 Go to previous message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 270
Registered: August 2010
Senior Member
You have to retrieve the same editing domain than the Sirius session:
org.eclipse.sirius.business.api.session.Session.getTransactionalEditingDomain()

The current object Session can be retrieved with
org.eclipse.sirius.business.api.session.Session.of(EObject)


Regards,

Florian
Previous Topic:Delete item from custom widget of property page with toolbar button
Next Topic:Disappearing labels in custom bordered node
Goto Forum:
  


Current Time: Thu Apr 25 02:16:08 GMT 2024

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

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

Back to the top