Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Affected tree elements
Affected tree elements [message #895777] Mon, 16 July 2012 00:28 Go to next message
Michael Spertus is currently offline Michael SpertusFriend
Messages: 78
Registered: July 2009
Member
My item provider's getText method looks at many descendants (children/great-grandchildren/etc.). If the descendant is changed, however, the item's label is not updated. I have (sort of) worked around this by modifying the arguments used to create the ViewerNotification in DescendantClassItemProvider.notifyChanged, but this breaks encapsulation horribly. Is there a recommended way of handling this?

Sorry if this is an obvious question,

Mike
Re: Affected tree elements [message #895793 is a reply to message #895777] Mon, 16 July 2012 05:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30693
Registered: July 2009
Senior Member
Mike,

Comments below.

On 16/07/2012 2:28 AM, Michael Spertus wrote:
> My item provider's getText method looks at many descendants
> (children/great-grandchildren/etc.). If the descendant is changed,
> however, the item's label is not updated. I have (sort of) worked
> around this by modifying the arguments used to create the
> ViewerNotification in DescendantClassItemProvider.notifyChanged, but
> this breaks encapsulation horribly.

It's an obvious problem, but we've not addressed this is a nice way. Do
you mean that the descendants themselves produce notifications to update
their ancestors? That's the approach I too with EGenericType. But the
problem is worse there because the labels depend on non-containment
references (names of referenced classifiers and type parameters) and
that I didn't handle at all.
> Is there a recommended way of handling this?
The nicest idea I've heard would depend on notifiers producing
read/access notifications that would allow one to determine all the
objects accessed to produce the label and attach listeners to each of
them. E.g., some type of content adapter that listens to all objects
and some thread-local logic that notices the notifications during the
label computation. Eike and I did work on a design for read/access
notification, but it's highly invasive and would require modifications
to all list implementations and all generated models...
>
> Sorry if this is an obvious question,
>
> Mike
Re: Affected tree elements [message #896003 is a reply to message #895793] Mon, 16 July 2012 20:12 Go to previous messageGo to next message
Michael Spertus is currently offline Michael SpertusFriend
Messages: 78
Registered: July 2009
Member
Thanks for your response, Ed. See below
Ed Merks wrote on Mon, 16 July 2012 01:21
Mike,

Comments below.

On 16/07/2012 2:28 AM, Michael Spertus wrote:
> My item provider's getText method looks at many descendants
> (children/great-grandchildren/etc.). If the descendant is changed,
> however, the item's label is not updated. I have (sort of) worked
> around this by modifying the arguments used to create the
> ViewerNotification in DescendantClassItemProvider.notifyChanged, but
> this breaks encapsulation horribly.

It's an obvious problem, but we've not addressed this is a nice way. Do
you mean that the descendants themselves produce notifications to update
their ancestors?

I just modified the element in the ViewerNotification constructor to be the parent of the parent of the notifier (That's such a gross hack I didn't really want to spell it out explicitly in the original post).
Quote:
That's the approach I too with EGenericType. But the
problem is worse there because the labels depend on non-containment
references (names of referenced classifiers and type parameters) and
that I didn't handle at all.
> Is there a recommended way of handling this?
The nicest idea I've heard would depend on notifiers producing
read/access notifications that would allow one to determine all the
objects accessed to produce the label and attach listeners to each of
them. E.g., some type of content adapter that listens to all objects
and some thread-local logic that notices the notifications during the
label computation. Eike and I did work on a design for read/access
notification, but it's highly invasive and would require modifications
to all list implementations and all generated models...

That's exactly what I want. Since it sounds like it's not in the cards for the foreseeable future, how hard is it for the ancestor to attach and maintain listeners to all of its descendants? Is there some sample code where this is done? Fortunately, handling containment references would meet my needs.


Thanks again,

Mike
Re: Affected tree elements [message #896053 is a reply to message #896003] Tue, 17 July 2012 05:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30693
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Michael,<br>
<br>
Comments below.<br>
<br>
<br>
<div class="moz-cite-prefix">On 16/07/2012 10:12 PM, Michael Spertus
wrote:<br>
</div>
<blockquote cite="mid:ju1sk9$t9f$1@xxxxxxxxe.org" type="cite">Thanks
for your response, Ed. See below
<br>
Ed Merks wrote on Mon, 16 July 2012 01:21
<br>
<blockquote type="cite">Mike,
<br>
<br>
Comments below.
<br>
<br>
On 16/07/2012 2:28 AM, Michael Spertus wrote:
<br>
&gt; My item provider's getText method looks at many descendants
&gt; (children/great-grandchildren/etc.). If the descendant is
changed, &gt; however, the item's label is not updated. I have
(sort of) worked &gt; around this by modifying the arguments
used to create the &gt; ViewerNotification in
DescendantClassItemProvider.notifyChanged, but &gt; this breaks
encapsulation horribly. <br>
It's an obvious problem, but we've not addressed this is a nice
way.  Do you mean that the descendants themselves produce
notifications to update their ancestors?
<br>
</blockquote>
<br>
I just modified the element in the ViewerNotification constructor
to be the parent of the parent of the notifier (That's such a
gross hack I didn't really want to spell it out explicitly in the
original post).
<br>
</blockquote>
Yes, similar to what we do in EGenericTypeItemProvider.<br>
<blockquote cite="mid:ju1sk9$t9f$1@xxxxxxxxe.org" type="cite">Quote:
<br>
<blockquote type="cite">That's the approach I too with
EGenericType.  But the problem is worse there because the labels
depend on non-containment references (names of referenced
classifiers and type parameters) and that I didn't handle at
all.
<br>
&gt; Is there a recommended way of handling this?
<br>
The nicest idea I've heard would depend on notifiers producing
read/access notifications that would allow one to determine all
the objects accessed to produce the label and attach listeners
to each of them.  E.g., some type of content adapter that
listens to all objects and some thread-local logic that notices
the notifications during the label computation.  Eike and I did
work on a design for read/access notification, but it's highly
invasive and would require modifications to all list
implementations and all generated models...
<br>
</blockquote>
<br>
That's exactly what I want. Since it sounds like it's not in the
cards for the foreseeable future, how hard is it for the ancestor
to attach and maintain listeners to all of its descendants?</blockquote>
Something like an EContentAdapter can do that automatically, though
it attaches to <b>all </b>contained objects so you might need to
specialize it to ignore things.  In any case, it's a good example.<br>
<blockquote cite="mid:ju1sk9$t9f$1@xxxxxxxxe.org" type="cite"> Is
there some sample code where this is done? Fortunately, handling
containment references would meet my needs.
<br>
</blockquote>
That certainly simplifies the problem. You have to be careful about
the appropriate times to remove such additional adapters, e.g., in
the derived ItemProviderAdapter's dispose.<br>
<blockquote cite="mid:ju1sk9$t9f$1@xxxxxxxxe.org" type="cite">
<br>
<br>
Thanks again,
<br>
<br>
Mike
<br>
</blockquote>
<br>
<br>
</body>
</html>
Re: Affected tree elements [message #896230 is a reply to message #896053] Tue, 17 July 2012 16:16 Go to previous message
Michael Spertus is currently offline Michael SpertusFriend
Messages: 78
Registered: July 2009
Member
Thanks, Ed
Previous Topic:EMF.Edit multiple editor pages setting doesn't work
Next Topic:[CDO] Unique Contraint in Eattribute Objects
Goto Forum:
  


Current Time: Sun Dec 15 15:09:49 GMT 2019

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

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

Back to the top