|
Re: EContentAdapter behavior [message #616698 is a reply to message #616697] |
Wed, 13 August 2008 13:46 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Till,
Comments below.
Till Essers wrote:
> Hi
>
> Don't know if this behavior I'm discovering comes from emf or the
> stp.bpmn modeler, so I'm posting in both newsgroups.
>
> I'm using an EContentAdapter to get notified when objects are added or
> removed from the bpmn diagram. It's working fine when adding objects.
> case Notification.ADD:
> Object obj = notification.getNotifier();
> if(obj instanceof NodeImpl)
> if(((NodeImpl)obj).getElement() instanceof Activity)
I don't imagine you should be using Impl classes in your instanceof
tests. Why aren't you using the "Node" API for testing?
>
> As you can see I'm just looking what kind of object has been added to
> the diagram. In this case we have an Activity.
> I'm doing the same on adding SequenceEdge.
> But when it comes to removing objects, I'm pretty curios about those
> objects passed around. When I'm removing a Connection for example, I
> get 2 remove notifications for the objects connected through this
> SequenceEdge, but none for the SequenceEdge itself.
Note that when an object is removed from the tree, the adapter itself is
removed from that object and from all contained children of it. The
REMOVING_ADAPTER notification will occur for those.
> Even though, when deleting a flow object from the diagram, I'm not
> receiving a notification for it.
Note also that notifications about deletion generally happen for the
containment feature of the parent not directly on the deleted object
itself (though the adapter is removed so you can detect that).
> Am I doing anything wrong?
I'm not sure. Hopefully you're calling super in your overrides so that
the normal processing happens as well...
> Or is the removed object not stored in the element?
I'm not sure what happens in this combination of diagram model and
domain model...
> Sorry for asking, but I couldn't find any documentation about the
> notifications passed around.
Generally a notification is fired by an EObject whenever the value of
one of it's features changes...
>
> Thanks in advance
> Till
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: EContentAdapter behavior [message #616700 is a reply to message #616699] |
Wed, 13 August 2008 14:50 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Till,
Are you listening to just the diagram resource or also the resource
containing the model? I'm assuming they're in different resources, but
that might be a wrong assumption. It sounds like delete is cleaning up
the node, but I would have imagined you'd have seen a notification that
the node's element was being SET to null...
Till Essers wrote:
> Ed Merks schrieb:
>> Till,
>>
>> Comments below.
>
>> I don't imagine you should be using Impl classes in your instanceof
>> tests. Why aren't you using the "Node" API for testing?
> Sure, changed this one ;)
>
>> Note that when an object is removed from the tree, the adapter itself
>> is removed from that object and from all contained children of it.
>> The REMOVING_ADAPTER notification will occur for those.
> Okay, that may change some things...
>
>> Note also that notifications about deletion generally happen for the
>> containment feature of the parent not directly on the deleted object
>> itself (though the adapter is removed so you can detect that).
> Which would explain why I got a notification telling me to delete the
> task, note the connection.
>
>> I'm not sure. Hopefully you're calling super in your overrides so
>> that the normal processing happens as well...
> Sure, the first call is the super call.
>
>> I'm not sure what happens in this combination of diagram model and
>> domain model...
> I'm absolutly unsure what happens... When the ADD notifier is called,
> I get a Node containing the new object as the element.
> When the REMOVING_ADAPTER notifier is called I get a Node containing
> null as the element.
> I don't know how I should know which object in the diagram is removed.
>
> Is it possible, that the super call sets the element of the node to null?
>
> Thanks so far
> Till
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03513 seconds