Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » emf.edit question (AdapterFactoryContentProvider)
emf.edit question (AdapterFactoryContentProvider) [message #424837] Thu, 06 November 2008 13:44 Go to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Hello,

I've a question concerning viewer updates when using an
AdapterFactoryContentProvider.
In my EMF model I've a class 'Task'. Task has a reference to statisitcs an
instanceof my emf modelled 'Statistic' class.

In my treeviewer I display a list of tasks. I'm showing the tasks name and
its statistics using columns. When I change a tasks attribute such as its
name for instance ther viewer reflects this change immediately. I also
want changes of a tasks statistics to be show. Unfortunately this does not
work.

Is there any way to change my model so that change notifications of a
class references are delivered to it?

Thank you,
Jan Kohnert
Re: emf.edit question (AdapterFactoryContentProvider) [message #424838 is a reply to message #424837] Thu, 06 November 2008 13:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Jan,

Comments below.

Jan Kohnert wrote:
> Hello,
>
> I've a question concerning viewer updates when using an
> AdapterFactoryContentProvider. In my EMF model I've a class 'Task'.
> Task has a reference to statisitcs an instanceof my emf modelled
> 'Statistic' class.
>
> In my treeviewer I display a list of tasks. I'm showing the tasks name
> and its statistics using columns. When I change a tasks attribute such
> as its name for instance ther viewer reflects this change immediately.
> I also want changes of a tasks statistics to be show. Unfortunately
> this does not work.
> Is there any way to change my model so that change notifications of a
> class references are delivered to it?
It sounds like perhaps you need for changes that are being notified on
the Statistic's item provider to look also like a label change for the
Task. Have a look in the debugger at how notifyChanged is handled in
each one's item provider. Likely you can create additional viewer
notifications in the Statistic's item provider substituting the parent
Task as the one originating the notification...
> Thank you,
> Jan Kohnert
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: emf.edit question (AdapterFactoryContentProvider) [message #424901 is a reply to message #424838] Mon, 10 November 2008 12:17 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Ed,

this topic developed some complexity over the time. I've tried to fire a
notification event myself, but since the viewer uses a filter for
Statistic elements no adapters where found to pass the notification event
to.
Using the adapters of the Statistics parent Task failed because
notification.getFeatureID() inside the itemProviders
notifyChanged(Notification notification) methods can only handel
attributes of its own class.

At the moment I'm doing it simply this way:
treeViewer.setContentProvider(new
AdapterFactoryContentProvider(adapterFactory){
@Override
public void notifyChanged(Notification notification) {
Display.getDefault().asyncExec(new Runnable(){
@Override
public void run() {
if (!treeViewer.getTree().isDisposed()){
treeViewer.refresh(true);
}
}
});
}
});

But thats just the seconds worst way after using a timer object :)

I've thought the simples way to solve my problem is to use the
contentprovider. It takes care managing adaprers and delegating events to
the propper UI part. But before I'm getting to involved into this I wanted
to ask how this problem is normally solved.

Jan
Re: emf.edit question (AdapterFactoryContentProvider) [message #424902 is a reply to message #424901] Mon, 10 November 2008 12:25 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Jan,

Comments below.


Jan Kohnert wrote:
> Ed,
>
> this topic developed some complexity over the time. I've tried to fire
> a notification event myself, but since the viewer uses a filter for
> Statistic elements no adapters where found to pass the notification
> event to.
You could use a stateful Task adapter and have it attach adapters to its
Statistic children as it computes information about that child...
> Using the adapters of the Statistics parent Task failed because
> notification.getFeatureID() inside the itemProviders
> notifyChanged(Notification notification) methods can only handel
> attributes of its own class.
>
> At the moment I'm doing it simply this way:
> treeViewer.setContentProvider(new
> AdapterFactoryContentProvider(adapterFactory){
> @Override
> public void notifyChanged(Notification notification) {
> Display.getDefault().asyncExec(new Runnable(){
> @Override
> public void run() {
> if (!treeViewer.getTree().isDisposed()){
> treeViewer.refresh(true);
> } }
> });
> }
> });
>
> But thats just the seconds worst way after using a timer object :)
Brute force. :-P You might as well just call refresh once whenever a
command is executed like we do for the properties view, which doesn't
have fine-grained update capability.
>
> I've thought the simples way to solve my problem is to use the
> contentprovider. It takes care managing adaprers and delegating events
> to the propper UI part. But before I'm getting to involved into this I
> wanted to ask how this problem is normally solved.
Adapters is the only way. With the work in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=247130
in combination with data binding (see Boris' attachment) we could do
some interesting things where all the objects accessed to compute a
value are automatically tracked so that notification of changes to a
computed value automagically just happen...
> Jan
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Editor
Next Topic:Can GenModel generate TreeNodeItemProvider?
Goto Forum:
  


Current Time: Thu Apr 25 16:00:17 GMT 2024

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

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

Back to the top