|Re: Notifications Problem [message #425410 is a reply to message #425405]
||Tue, 25 November 2008 16:10
| Renat Zubairov
Registered: July 2009
The method eNotificationRequired returns false only because your object has
no listeners (adapters) therefore sending of notification is not reqired in
this case. Generally EMF models are subject for state of art optimization,
all possible java performace optimizations are done there, for example
notifications are not sent when it's not needed, or lists are created
So, the classes inside the Edit plugin are extending EMFContentAdapter which
automatically attach itself to all objects that are accessible from starting
object via _containment_ relations. So first of all check that your relation
is containment, then check that you are adding your new object usual way,
i.e. by fetching the children collection and adding element to it, only in
this case EMFContentAdapter will know that collection was modified and will
attach itself to newly added object.
Also, it might be not a best idea to manipulate model objects directly, the
better way is to use Commands for that. The advantage of commands is that
your changes will be integrated with another user changes therefore will be
a subject of undo/redo actions and editor dirty indicator.
On 25.11.08 10:27, in article
> I'm using an EMF Model and want to show an object within a Treeview.
> Therefor I've copied code out of the generated editor class
> and put it into my viewer class. When initially setting the Treeviewer input
> that data is displayed well.
> But there is a problem with notifications. The
> AdapterFactoryContentProvider seems not to keep track of them. It might be
> because of missing adapters. that happens when I try to create an Object from
> a job and adding it to the model like followed:
> MyObject obj = MyModelFactory.eINSTANCE.createMyObject();
> in Myadd I m calling:
> if (eNotificationRequired())
> eNotify(new ENotificationImpl(this, Notification.SET, MyModelPackage.OBJECT,
> null, obj));
> therefor eNotificationRequired always returns
> false. (There are no adapters).
> What do I have to do in order to get model changes displayed in my Treeview?
> My code in the TreeView class:
> protected ComposedAdapterFactory adapterFactory;
> AdapterFactoryLabelProvider.FontAndColorProvider(adapterFact ory,treeViewer));
> In the MyObjectItemProvider class I'm using the function @Override
> public Collection<?> getChildren(Object object)
> instead of getChildFeature
> Please help
|Re: Notifications Problem [message #425444 is a reply to message #425431]
||Wed, 26 November 2008 13:39
| Ed Merks
Registered: July 2009
> Hi Renat,
> thanks for your Reply.
> I m using maps. That means I m using collections of MapEntrys (Key, Object) and my Object that I need to add into the EMF, is an Object that has to be added into the Map. I don't know how the contentProvider actuates with maps!!!!
> Using command is the best way but i cannot use it always due of some functionality requirement of my program.
A ChangeCommand can be used to record the changes and make them undoable.
> How can I add an adapter (listener) to my object?
It seems to me if you are creating a new object, no one will know about
it until you attach it to some container object and that container
object, if it's being viewed somewhere, will already have an adapter
that will notify about the addition of the child.
> I don't want to create my own adapter, i want to use the ObjectItemProvider as a provider of notification adapters.
From what you describe though, it seems to me that it's not possible
for any view to notice the created of "obj".
> I think, It has to be something like that:
> object.eAdapter().add(xxxxxx) xxxxxx has to be something like objectItemproviderObject. how can i do that?
Normally adapters are added automatically as the objects are viewed,
i.e, as the label or content provider is asked to produce text of
children, but from what you've described I don't see how the new object
you created could affect any existing views...
Powered by FUDForum
. Page generated in 0.02330 seconds