|
Re: [CDO] Notification of changes [message #422085 is a reply to message #422083] |
Thu, 21 August 2008 12:54 |
|
Stefan Winkler schrieb:
> Hi Eike,
>
> short question: what is the recommended way to get notified of a
> change of - in my case - a resource's contents?
>
>
> Context:
>
> One session (1) - Several transactions/views.
>
> One of the CDOViews is attached (as Resource (2) in an EditingDomain)
> to a (JFace) TreeViewer (3) shown in an (Eclipse-)View.
> If a transaction (in a wizard) modifies the contents of the same
> resource (2), the TreeViewer (3) is not updated automatically.
> So the TreeViewer (3) has to be notified of the modification somehow.
>
>
> My current Solution (working):
>
> I register a org.eclipse.net4j.util.event.IListener implementation
> using session(1).addListener() and implement it so that
> if(event instanceof CDOSessionInvalidationEvent) triggers a
> TreeViewer(3).refresh();
>
>
> Questions in detail:
> - Isn't the EMF notification mechanism supposed to solve this
> automatically (I guess no, because we have different views/transactions).
Yes, you can also call CDOView.setInvalidationNotificationsEnabled(true)
to turn on EMF notifications.
But please keep in mind that these special notifications don't carry
feature change information!
Only recently Simon implemented this feature:
233490: Change Subscription
https://bugs.eclipse.org/bugs/show_bug.cgi?id=233490
It changed some things WRT. notifications.
Here's a preview of the New&Noteworthy:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf.cdo/doc/org.eclipse.emf.cdo.doc/new/new.htm?roo t=Modeling_Project&view=co
> - Is session.addListener() the correct way?
If you want to go this way, yes.
> - Is CDOSessionInvalidationEvent the right event to watch for?
Yes.
> - Is there any way to do this more efficiently (I guess yes - by
> replacing the general refresh() call by
>
> for(CDOIDAndVersion id : e.getDirtyOIDs()) {
> treeViewer.refresh(cdoView.getObject(id.getID()));
> }
>
> )
Hmm, have you had a look at the CDOEventHandler that is used in the
CDOEditor?
IIRC. it encapsulates a lot of the refresh logic and makes it reusable
for other tree viewers.
But I guess you should first ask Simon about the new ChangeSubscription
feature (I only reviewd the code but did not experiment with it, yet)
>
> Note: I talk about the same session here. I am aware that changes
> across different sessions are more complicated (impossible because not
> communicated?)
No, they are also communicated throught the repository!
Depending on the used network connection with a bit of a latency, however.
Did that help?
Cheers
/Eike
>
> Thanks in advance for your clarifications in that matter ...
>
> Cheers,
> Stefan
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Powered by
FUDForum. Page generated in 0.03280 seconds