Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Notification of changes
[CDO] Notification of changes [message #422083] Thu, 21 August 2008 12:38 Go to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
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).
- Is session.addListener() the correct way?
- Is CDOSessionInvalidationEvent the right event to watch for?
- 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()));
}

)

Note: I talk about the same session here. I am aware that changes across
different sessions are more complicated (impossible because not
communicated?)

Thanks in advance for your clarifications in that matter ...

Cheers,
Stefan
Re: [CDO] Notification of changes [message #422085 is a reply to message #422083] Thu, 21 August 2008 12:54 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
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


Re: [CDO] Notification of changes [message #422087 is a reply to message #422083] Thu, 21 August 2008 13:08 Go to previous message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Hi Stefan,

If you are using HEAD we have a new feature. It is called Change
Subscription.

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&revision=1.2&content-type=text%2F plain

Basically you could add an adapter to your objects you want to listen.
object.eAdapter().add(yourAdapter).
It will be notify for each feature changed.

Simon

"Stefan Winkler" <stefan.winkler-et@fernuni-hagen.de> a
Previous Topic:xml schema
Next Topic:EMF 2.3.0 vs 2.3.2 performance issue
Goto Forum:
  


Current Time: Fri Apr 26 13:22:38 GMT 2024

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

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

Back to the top