Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Newbie Question: Update Properties View
Newbie Question: Update Properties View [message #407907] Tue, 20 March 2007 20:41 Go to next message
Thomas Porcham is currently offline Thomas Porcham
Messages: 14
Registered: July 2009
Junior Member
Hi everybody,

I started to play around with EMF some days ago.
I like it because of the generic approach. I think I will be able to use
it in many situations.

Here comes my problem:
I created an emf editor by hand, that displays a list of objects in an
editable table. It also has a standard properties view (uses
AdapterFactoryContentProvider as PropertySourceProvider). So you can edit
properties (string properties) in the table and in the properties view.

When I edit properties in the properties view the tables content provider
gets notified and updates the table like this:

@Override
public void notifyChanged(Notification notification) {
getTableViewer().update(notification.getNotifier(), null);
}

However, when I edit a property in the table viewer the property view
won't update.
I tried to update the properties view by calling refresh():

commandStack.addCommandStackListener(new CommandStackListener() {
public void commandStackChanged(final EventObject event) {
if (propertySheetPage != null &&
propertySheetPage.getControl().isDisposed()) {
propertySheetPage.refresh();
}
}
});

But this leeds to an endless recursion. A new command gets created and
executed ,then the listener gets notified and calls refresh(); another
command gets created...

How can I update the properties view after a change of my EMF model?

TIA, cheers,

Thomas
Re: Newbie Question: Update Properties View [message #407909 is a reply to message #407907] Tue, 20 March 2007 21:06 Go to previous messageGo to next message
Steve Blass is currently offline Steve Blass
Messages: 276
Registered: July 2009
Senior Member
This quote from Ed back in May of 2005 about avoiding the recursive
looping might apply...

"... way to avoid that is perhaps to do a Display.asyncExec to ensure
that the current interaction is completed before you execute a command
and cause a notification cascade."

And this snippet from the Eclipse Help files shows the pattern for using
Display.asyncExec
// do time-intensive computations
...
// now update the UI. We don't depend on the result,
// so use async.
display.asyncExec (new Runnable () {
public void run () {
if (!myWindow.isDisposed())
myWindow.redraw ();
}
});
// now do more computations

HTH
-
Steve


Thomas Porcham wrote:
> Hi everybody,
> I started to play around with EMF some days ago.
> I like it because of the generic approach. I think I will be able to use
> it in many situations.
>
> Here comes my problem:
> I created an emf editor by hand, that displays a list of objects in an
> editable table. It also has a standard properties view (uses
> AdapterFactoryContentProvider as PropertySourceProvider). So you can
> edit properties (string properties) in the table and in the properties
> view.
>
> When I edit properties in the properties view the tables content
> provider gets notified and updates the table like this:
>
> @Override
> public void notifyChanged(Notification notification) {
> getTableViewer().update(notification.getNotifier(), null);
> }
>
> However, when I edit a property in the table viewer the property view
> won't update.
> I tried to update the properties view by calling refresh():
>
> commandStack.addCommandStackListener(new CommandStackListener() {
> public void commandStackChanged(final EventObject event) {
> if (propertySheetPage != null &&
> propertySheetPage.getControl().isDisposed()) {
> propertySheetPage.refresh();
> }
> }
> });
>
> But this leeds to an endless recursion. A new command gets created and
> executed ,then the listener gets notified and calls refresh(); another
> command gets created...
>
> How can I update the properties view after a change of my EMF model?
>
> TIA, cheers,
> Thomas
>
>
>
>
>
>
Re: Newbie Question: Update Properties View [message #407939 is a reply to message #407909] Thu, 22 March 2007 09:10 Go to previous message
Thomas Porcham is currently offline Thomas Porcham
Messages: 14
Registered: July 2009
Junior Member
Thanks for your quick reply!
I will try this.
Previous Topic:Setting xsi:schemaLocation
Next Topic:Looking exact EObject
Goto Forum:
  


Current Time: Sat Oct 25 04:19:28 GMT 2014

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

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