Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Change EMF properties and refresh Property View
Change EMF properties and refresh Property View [message #1058845] Wed, 15 May 2013 07:58 Go to next message
Federico De Meo is currently offline Federico De Meo
Messages: 3
Registered: May 2013
Junior Member
Hello, I'm new to the forum and to EMF models.
I'm working on a plug-in, initially developed by a colleague of mine, structured in three separated projects:


  • One EMF Model (autogenerated)
  • One GEF editor (autogenerated)
  • One menu



The EMF Model represent some object we want to draw in a graphical interface (along with some config values displayed in the Property View)

The GEF editor allows to draw objects and displays properties in the Property View.

The menu classes extend AbstractHandler and I want from it to change the value of config variable of the EMF Model and to automatically show the changes in the Property View.
In the AbstractHandler I'm using ResourceSet and Resource to get the instance of the EObject related to the diagram shown in the editor.
From the Resource I'm invoking the setInstantiationFiles method (b reported below) to change the variable value. The value is correctly changed but the Property VIew is not auto-refreshed.

I tried to retrive the IPropertySheetPage in order to invoke the refresh() methods but this doesn't update the Property View. I googled around and what I understood is that the setInstantiationFiles should do something more than just change an integer variable. It should invoke some sort of notification to notify the change (I suppose).
Is it correct? How can I do that?



public void setInstantiationFiles(EList<String> inst) {

    instantiationFiles = inst;
}
Re: Change EMF properties and refresh Property View [message #1059273 is a reply to message #1058845] Wed, 15 May 2013 11:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26014
Registered: July 2009
Senior Member
Federico,

Comments below.

On 15/05/2013 2:55 PM, Federico De Meo wrote:
> Hello, I'm new to the forum and to EMF models.
> I'm working on a plug-in, initially developed by a colleague of mine,
> structured in three separated projects:
>
>
> One EMF Model (autogenerated)
> One GEF editor (autogenerated)
> One menu
>
>
>
> The EMF Model represent some object we want to draw in a graphical
> interface (along with some config values displayed in the Property View)
>
> The GEF editor allows to draw objects and displays properties in the
> Property View.
>
> The menu classes extend AbstractHandler and I want from it to change
> the value of config variable of the EMF Model and to automatically
> show the changes in the Property View. In the AbstractHandler I'm
> using ResourceSet and Resource to get the instance of the EObject
> related to the diagram shown in the editor.
> From the Resource I'm invoking the setInstantiationFiles method (b
> reported below) to change the variable value.
Aren't you using a command? You'd mess up the undo state if you don't...
> The value is correctly changed but the Property VIew is not
> auto-refreshed.
In EMF's generated editor, the properties view is updated by a command
stack listener that updates it whenever a command is executed, so maybe
that's the missing part.
>
> I tried to retrive the IPropertySheetPage in order to invoke the
> refresh() methods but this doesn't update the Property View.
It does in EMF's generated editor...
> I googled around and what I understood is that the
> setInstantiationFiles should do something more than just change an
> integer variable. It should invoke some sort of notification to notify
> the change (I suppose). Is it correct? How can I do that?
If that call is on a modeled EMF object, it will automatically send out
notifications, but the properties view doesn't update based on
notifications, only by calls to refresh...
>
>
>
> public void setInstantiationFiles(EList<String> inst) {
>
> instantiationFiles = inst;
> }
Is instantiationFiles a modeled feature in the model or what?
Re: Change EMF properties and refresh Property View [message #1059326 is a reply to message #1059273] Fri, 17 May 2013 10:11 Go to previous messageGo to next message
Federico De Meo is currently offline Federico De Meo
Messages: 3
Registered: May 2013
Junior Member
I don't understand what do you mean with this.

Quote:
If that call is on a modeled EMF object, it will automatically send out
notifications, but the properties view doesn't update based on
notifications, only by calls to refresh...


Do you mean I should call a different method from the setters generated by the EMF framework?

The call to setIinstantiationFiles is in the EMF model, however I suspect that this feature was not primarily modelled in the ecore model (or at least it has been overwritten because I found @generated NOT in the code).

At this moment I'm studying the how-to guide from Vainolo I found in the GEF Tutorial page on the eclipse website (http://wiki.eclipse.org/GEF/Articles,_Tutorials,_Slides)
so as to better understand how things work.
Re: Change EMF properties and refresh Property View [message #1059350 is a reply to message #1059326] Fri, 17 May 2013 11:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26014
Registered: July 2009
Senior Member
Federico,

Comments below.

On 17/05/2013 4:11 PM, Federico De Meo wrote:
> I don't understand what do you mean with this.
>
> Quote:
>> If that call is on a modeled EMF object, it will automatically send
>> out notifications, but the properties view doesn't update based on
>> notifications, only by calls to refresh...
>
>
> Do you mean I should call a different method from the setters
> generated by the EMF framework?
No, I mean that all changes to EMF's models will automatically generate
notifications.
>
> The call to setIinstantiationFiles is in the EMF model, however I
> suspect that this feature was not primarily modelled in the ecore
> model (or at least it has been overwritten because I found @generated
> NOT in the code).
I can't comment on what people do after the code is generated, but the
frameworks will assume that all changes to the model produce
notifications so hand written modifications will need to respect that.
>
> At this moment I'm studying the how-to guide from Vainolo I found in
> the GEF Tutorial page on the eclipse website
> (http://wiki.eclipse.org/GEF/Articles,_Tutorials,_Slides)
> so as to better understand how things work.
Note that frameworks like GMF or Graphiti do a lot of things for you
automatically in terms of providing views for modeled objects...
Re: Change EMF properties and refresh Property View [message #1059383 is a reply to message #1059350] Fri, 17 May 2013 15:22 Go to previous message
Federico De Meo is currently offline Federico De Meo
Messages: 3
Registered: May 2013
Junior Member
Ok so I'm in the right direction.
If you think GMF or Graphiti are better I'll definitely give them a try.
I'm afraid that this plugin needs to be rethought from the beginning because, as far as I could see, there some other parts which have problems.

Thank you very much for you suggestions Smile
Previous Topic:[CDO] To know if a Resource is being modified by others
Next Topic:[CDO] revisions or versions list.
Goto Forum:
  


Current Time: Sat Aug 30 00:25:57 EDT 2014

Powered by FUDForum. Page generated in 0.01692 seconds