Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Edit the actions to do when a property is changed(How can I get the diagram automatically updated as happens when I close an open it again?)
Edit the actions to do when a property is changed [message #752822] Wed, 26 October 2011 14:31 Go to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Hi everybody,

Where can I edit the activities to do when a property of a block is changed? The property I am talking about is not an attribute, is a reference to another block, so it does not appear in the *.diagram.edit.parts as a BlockAttributeEditPart.java file.

In my project, I have some objects called "task", which have a reference to another object called "customtask". The reference appears in properties to the "task" object, so the user has to specify it by selecting one of the declared "customtask"s of in the properties window.

Till now, I managed to do it by editing the "SetReference" command in the TaskImpl.java file in the "MyProgram" directory, but now I need to call a command that is placed in the "MyProgram.diagram" directory, so I need one of the followings:

a) Make an Import to a file that is outside the "MyProgram" directory, and then call the required command.
b) Edit the code of a file in the MyProgram.diagram directory instead of the one in "TaskImpl.java" file, in case it exists a code which is called every time a change is made in a property (take into account that the property is not changed directly in the diagram, but in the properties window).

Does anybody know how to do any of these?

[Updated on: Wed, 02 November 2011 11:24]

Report message to a moderator

Re: Edit the actions to do when a property is changed [message #753425 is a reply to message #752822] Thu, 27 October 2011 08:24 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi

did you try this to react on model changes? http://wiki.eclipse.org/GMF/Tips#Making_figures_sensitive_to_attributes_of_semantic_elements

Ralph
Re: How to refresh the diagram [message #753701 is a reply to message #753425] Fri, 28 October 2011 12:24 Go to previous messageGo to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Thank you Ralph!! The information in the link you provided helped me a lot!!

Now I have another question:
how can I update a diagram when I want? With the code I wrote, my model gets ok when I change a property, but my diagram is not automatically updated, so I have to close and open it again to get it updated. Wich command do I have to call to do that automatically? I've tried with "getFigure().repaint()" and with "refresh()" but none of them works.

Thanks!
Re: How to refresh the diagram [message #753986 is a reply to message #753701] Mon, 31 October 2011 11:07 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
Hi,

try this code on your editpart:

performRequest(new Request(RequestConstants.REQ_REFRESH))


You should also consider to use one of GMF extensibility mechanism for your changes. You can either provide custom templates to get your code generated when generating code from your gmfgen diagram or use the extensionpoints provided by gmf.

Ralph
Re: How to refresh the diagram [message #754331 is a reply to message #753986] Wed, 02 November 2011 08:19 Go to previous messageGo to next message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Hi Ralph,

I tried with those:

refreshChildren();
this.refresh();
this.getFigure().repaint();
this.getContentPane().repaint();
performRequest(new Request(RequestConstants.REQ_REFRESH));
performRequest(new Request(RequestConstants.REQ_REFRESH_CONNECTIONS));


but none of them works. Any other suggestion?

Thanks!!

[Updated on: Wed, 02 November 2011 08:53]

Report message to a moderator

Re: How to refresh the diagram [message #754372 is a reply to message #754331] Wed, 02 November 2011 11:21 Go to previous message
Iban Ayestaran is currently offline Iban AyestaranFriend
Messages: 58
Registered: September 2011
Member
Hello,

I have noticed that the following behaves as pressing the F5 button, so I can use it sometimes:

((ModuleCanonicalEditPolicy)(this.getParent().getEditPolicy(EditPolicyRoles.CANONICAL_ROLE))).refresh();


but in some other cases, F5 does not update the diagram (so the former code doesn't either), and I need to close and open the diagram again to get it updated. Does anybody know which code updates the diagram as closing and opening it again does?

Thanks in advance,

Iban
Previous Topic:Message: "Top-level diagram container must be concrete"
Next Topic:[SOLVED] How to integrate the State Diagram into the example in GMF Tutorial?
Goto Forum:
  


Current Time: Thu Apr 18 03:31:59 GMT 2024

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

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

Back to the top