|
Re: EMF.Edit's ItemProviders ad-hoc behavior [message #494995 is a reply to message #494950] |
Tue, 03 November 2009 13:55 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
John,
Comments below.
John S. wrote:
> Hello,
>
> I would like to monitor the notifications so i put a println method
> for the console to display it, like:
>
> public void notifyChanged(Notification notification) {
> System.out.println("TableItemProvider: " + notification);
> ..
> }
Of course this only monitors changes for objects that have been viewed.
>
> When I start a new Eclipse instance for the GMF editor to edit the
> model, I cannot always see that println method would run, because
> there is nothing on the console. It means that the notifyChanged does
> not run when for example I create a Table (this is a Model Element) on
> the diagram.
I don't think GMF is using the item providers for the diagrams
themselves, only for the outline I think...
> Sometimes when I remove than re-add the Properties view of Eclipse
> windows and create a new diagram again, it seems good (a trick, but
> not sure it is the answer for the question).
> I really don't know why I get notification in an ad-hoc way when
> something changed. The notifyChanged should be called every time when
> there is a change on the model caused by the diagram, but it doesn't
> seem to work in this way.
If you want to consistently monitor all changes, regardless of whether
the objects have been viewed, use an EContentAdapter on the resource set.
>
> Regards, John S.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
Re: EMF.Edit's ItemProviders ad-hoc behavior [message #495334 is a reply to message #495197] |
Wed, 04 November 2009 15:34 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
John,
Comments below.
John S. wrote:
> Hello,
>
>>> If you want to consistently monitor all changes, regardless of whether
>>> the objects have been viewed, use an EContentAdapter on the resource
>>> set.
>
> My code looks like this in the itemprovider of a modelelement, but it
> still doesnt monitor all the time when i create this element with the
> GMF editor.
>
> @Override
> public void notifyChanged(Notification notification) {
>
> EContentAdapter adapter = new EContentAdapter() {
> @Override
> public void notifyChanged(Notification notification) {
> super.notifyChanged(notification);
> System.out.println("Notfication received from the data
> model. Data model has changed!!!");
> }
> };
> EObject eNotifier = (EObject) notification.getNotifier();
> ResourceSet resourceSet =eNotifier.eResource().getResourceSet();
> resourceSet .eAdapters().add(adapter);
You add a new one each time you get a notification. That sounds more
than a little horrible and still leaves you with the problem of it not
being attached until the objects is viewed. You need to attach it once
when the editor is opened and the resource set is created.
> ..}
>
> I do not know what is missing.
>
> Best Regards
> John
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03384 seconds