Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Propagating EObject status to all referencing EObjects
Propagating EObject status to all referencing EObjects [message #1376235] Fri, 23 May 2014 10:14 Go to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
I have a complex model with many elements that are deriving from a basic
"Identifiable" EClass.

Identifiable has a status (myStatus) and an Operation (Status
getStatus()) checking myStatus and all statuses of referenced Identifiables.

Current code (still untested!) is:

public Status getStatus() {
Status st = getMyStatus();
for (EReference r : eClass().getEReferences()) {
Object o = eGet(r);
if (o instanceof Identifiable) {
Identifiable id = (Identifiable) o;
Status s = id.getStatus();
if (s.getValue() > st.getValue())
st = s;
}
}
return st;
}

This should be used to display some warning/error indication on the
whole tree (not only in containment, but also in references); something
similar to error/warning indication in eclipse PackageExplorer.

QUESTION:
Is there an (easy) way to get notification when a certain
Identifiable.getStatus()changes it's value?
I'm not interested in local (myStatus), but in the computed one.
I think this would mean to propagate statuses along the reference links
(backward) instead of computing them on request, but I did not find a
reasonable way to do it.
Re: Propagating EObject status to all referencing EObjects [message #1376297 is a reply to message #1376235] Fri, 23 May 2014 10:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Mauro,

Comments below.

On 23/05/2014 12:14 PM, Mauro Condarelli wrote:
> I have a complex model with many elements that are deriving from a
> basic "Identifiable" EClass.
>
> Identifiable has a status (myStatus) and an Operation (Status
> getStatus()) checking myStatus and all statuses of referenced
> Identifiables.
>
> Current code (still untested!) is:
>
> public Status getStatus() {
> Status st = getMyStatus();
> for (EReference r : eClass().getEReferences()) {
> Object o = eGet(r);
> if (o instanceof Identifiable) {
> Identifiable id = (Identifiable) o;
> Status s = id.getStatus();
> if (s.getValue() > st.getValue())
> st = s;
> }
> }
> return st;
> }
>
> This should be used to display some warning/error indication on the
> whole tree (not only in containment, but also in references);
> something similar to error/warning indication in eclipse PackageExplorer.
This sounds similar to what's already supported via "Live Validation"
support. It also sounds similar to what's supported via the validation
framework where problems are represented as Diagnostics and are used by
Live Validation to decorate the tree...
>
> QUESTION:
> Is there an (easy) way to get notification when a certain
> Identifiable.getStatus()changes it's value?
No.
> I'm not interested in local (myStatus), but in the computed one.
> I think this would mean to propagate statuses along the reference
> links (backward) instead of computing them on request, but I did not
> find a reasonable way to do it.
It sounds like you're trying to replicate much of what's already
supported more directly in the framework. I would expect you'd declare
constraints that are validated by the generated validator, and by
changing the Decorator property in the GenModel's Editor section from
"None" to "Live" you'd have a generated editor that would automatically
invoke the validator each time a command is executed and would
automatically decorate the tree with problem indicators. Of course that
decorator could be used a the Common Navigator framework as well (though
I've not done that and don't know all the details)...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Propagating EObject status to all referencing EObjects [message #1376347 is a reply to message #1376297] Fri, 23 May 2014 11:19 Go to previous messageGo to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
Thanks for the fast answer, Ed.
Comments below.

Il 23/05/2014 12:46, Ed Merks ha scritto:
> Mauro,
>
> Comments below.
>
> On 23/05/2014 12:14 PM, Mauro Condarelli wrote:
>> I have a complex model with many elements that are deriving from a
>> basic "Identifiable" EClass.
>>
>> Identifiable has a status (myStatus) and an Operation (Status
>> getStatus()) checking myStatus and all statuses of referenced
>> Identifiables.
>>
>> Current code (still untested!) is:
>>
>> public Status getStatus() {
>> Status st = getMyStatus();
>> for (EReference r : eClass().getEReferences()) {
>> Object o = eGet(r);
>> if (o instanceof Identifiable) {
>> Identifiable id = (Identifiable) o;
>> Status s = id.getStatus();
>> if (s.getValue() > st.getValue())
>> st = s;
>> }
>> }
>> return st;
>> }
>>
>> This should be used to display some warning/error indication on the
>> whole tree (not only in containment, but also in references);
>> something similar to error/warning indication in eclipse PackageExplorer.
> This sounds similar to what's already supported via "Live Validation"
> support. It also sounds similar to what's supported via the validation
> framework where problems are represented as Diagnostics and are used by
> Live Validation to decorate the tree...
Unfortunately I don't know how to use that framework.
Problem is I'm *not* using full eclipse; I'm using EMF in Standalone
mode with an application written using JavaFX. This means I'm using
neither Edit nor Editor (nor Test).
Is there some way to use "Live Validation" in such a scenario?
If so: how?
I would rather not use explicit binding (i.e.: adding ChangeListeners to
all ERefernces), if at all possible.

>>
>> QUESTION:
>> Is there an (easy) way to get notification when a certain
>> Identifiable.getStatus()changes it's value?
> No.
I assume I would have to manually maintain a list of listeners to all
Identifiable EReferences to do obtain that effect, right?
That, in turn, would mean to hook to all ELists to watch for
insertion/deletions and to simple references for changes.
Correct?

>> I'm not interested in local (myStatus), but in the computed one.
>> I think this would mean to propagate statuses along the reference
>> links (backward) instead of computing them on request, but I did not
>> find a reasonable way to do it.
> It sounds like you're trying to replicate much of what's already
> supported more directly in the framework. I would expect you'd declare
> constraints that are validated by the generated validator, and by
> changing the Decorator property in the GenModel's Editor section from
> "None" to "Live" you'd have a generated editor that would automatically
> invoke the validator each time a command is executed and would
> automatically decorate the tree with problem indicators. Of course that
Is there some way to hook unto that and "just" get a notification?
If Validator could be convinced to call a generic Callback (or Runnable,
or whatever) I could use it.

> decorator could be used a the Common Navigator framework as well (though
> I've not done that and don't know all the details)...
>
TiA
Re: Propagating EObject status to all referencing EObjects [message #1376389 is a reply to message #1376347] Fri, 23 May 2014 11:43 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Mauro,

Comments below.

On 23/05/2014 1:19 PM, Mauro Condarelli wrote:
> Thanks for the fast answer, Ed.
> Comments below.
>
> Il 23/05/2014 12:46, Ed Merks ha scritto:
>> Mauro,
>>
>> Comments below.
>>
>> On 23/05/2014 12:14 PM, Mauro Condarelli wrote:
>>> I have a complex model with many elements that are deriving from a
>>> basic "Identifiable" EClass.
>>>
>>> Identifiable has a status (myStatus) and an Operation (Status
>>> getStatus()) checking myStatus and all statuses of referenced
>>> Identifiables.
>>>
>>> Current code (still untested!) is:
>>>
>>> public Status getStatus() {
>>> Status st = getMyStatus();
>>> for (EReference r : eClass().getEReferences()) {
>>> Object o = eGet(r);
>>> if (o instanceof Identifiable) {
>>> Identifiable id = (Identifiable) o;
>>> Status s = id.getStatus();
>>> if (s.getValue() > st.getValue())
>>> st = s;
>>> }
>>> }
>>> return st;
>>> }
>>>
>>> This should be used to display some warning/error indication on the
>>> whole tree (not only in containment, but also in references);
>>> something similar to error/warning indication in eclipse
>>> PackageExplorer.
>> This sounds similar to what's already supported via "Live Validation"
>> support. It also sounds similar to what's supported via the validation
>> framework where problems are represented as Diagnostics and are used by
>> Live Validation to decorate the tree...
> Unfortunately I don't know how to use that framework.
> Problem is I'm *not* using full eclipse; I'm using EMF in Standalone
> mode with an application written using JavaFX. This means I'm using
> neither Edit nor Editor (nor Test).
Oh.
> Is there some way to use "Live Validation" in such a scenario?
The entire EMF.Edit layer, including the generated item providers can be
used stand alone. But of course all the integration with Eclipse tree
viewers, including support for hovers and all that depends on Eclipse...
> If so: how?
> I would rather not use explicit binding (i.e.: adding ChangeListeners
> to all ERefernces), if at all possible.
In the end, that's the only thing possible.... Of course you might use
an approach like attaching an EContentAdapter to the resource set so you
listen to all changes on all objects from a single adapter...
>
>>>
>>> QUESTION:
>>> Is there an (easy) way to get notification when a certain
>>> Identifiable.getStatus()changes it's value?
>> No.
> I assume I would have to manually maintain a list of listeners to all
> Identifiable EReferences to do obtain that effect, right?
Yes, pretty much.
> That, in turn, would mean to hook to all ELists to watch for
> insertion/deletions and to simple references for changes.
> Correct?
Yes.
>
>>> I'm not interested in local (myStatus), but in the computed one.
>>> I think this would mean to propagate statuses along the reference
>>> links (backward) instead of computing them on request, but I did not
>>> find a reasonable way to do it.
>> It sounds like you're trying to replicate much of what's already
>> supported more directly in the framework. I would expect you'd declare
>> constraints that are validated by the generated validator, and by
>> changing the Decorator property in the GenModel's Editor section from
>> "None" to "Live" you'd have a generated editor that would automatically
>> invoke the validator each time a command is executed and would
>> automatically decorate the tree with problem indicators. Of course that
> Is there some way to hook unto that and "just" get a notification?
> If Validator could be convinced to call a generic Callback (or
> Runnable, or whatever) I could use it.
The "Live Validator" approach listens to the command stack and
revalidates whenever a command is executed (i.e., whenever some set of
changes has completed)...
>
>> decorator could be used a the Common Navigator framework as well (though
>> I've not done that and don't know all the details)...
>>
> TiA


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:URI#createFileURI() does not add the file scheme Windows?!
Next Topic:Errors in generated java code when extending Xcore
Goto Forum:
  


Current Time: Thu Apr 25 16:59:45 GMT 2024

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

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

Back to the top