Deletion of reference does also delete containment [message #222873] |
Thu, 26 March 2009 10:24  |
Eclipse User |
|
|
|
Hi everyone.
I have a model where my objects A are stored as containments under the
diagram root node.
Also contained in the root node are some objects B which hold references
to some of the elements A.
My problem: Each time I delete a reference in B the original element A
which is contained in the root node is also deleted. The same happens if
I delete one of the B's. All of the referenced A's are also deleted.
Does anybody know a way how this could be bypassed? The optimal solution
would be, that on deletion of a reference, a check would be triggerd if
there is still another reference to A. If there is one, A would stay
untouched, but if this was the last reference, A would also be deleted
from the containment (and thus from the model)
Thanks in advance,
Daniel
|
|
|
|
|
|
Re: Deletion of reference does also delete containment [message #223651 is a reply to message #223572] |
Tue, 31 March 2009 08:28   |
Eclipse User |
|
|
|
Hi Alex,
yes you are right, acutally I use a ChildReference to access the
Properties, and to put them in the according compartment. The
ChildReference has set Containment on the DiagramRoots containment and
ChildrenFeature on the Node_Objects non-containment-reference.
My actual Model looks like:
TopNode Node_Object
|- Compartment
|- ChildReference Property (Containment:
DiagramRoot.PropertyContainment/ChildrenFeature: Node_Object.Properties)
There are some other TopNodes (witch are rather similar to the
Node_Object) and one Link Maping for the associations that could be
drawn in the model.
I have tried to use a Top Node Reference to define the Properties, but
then I'm not sure how to create them correctly (using Node_Objects
childreference and setting Referenced Child to the top node does only
create the property in the Root-Containment and then crashes when trying
to add it to the Node_Object (again it tries to cast to both from
getElementToEdit() )
I'm not sure how I could create a Link Maping, using the non containment
relationship as containment feature, or how i could include a link in an
compartment. My situation is the following: I want to create something
that looks similar to the uml class. Box (Node_Object) with an
compartment of referenced Properties (Each displayed in a shared
WrappingLabel). These properties are contained in the DiagramRoot
because I need to have a complete list of all of them, and because the
Node_Object should only use references to the object, so that changing
one of them also influences and updates the other references (this works
fine)
Alex Shatalin schrieb:
> Hello Daniel,
>
> Looks like Property is described as a child element of Node_Object in
> your .gmfmap model (otherwise why generated Property2CreateCommand
> casting element to edit to Node_Object..)
>
> Can you please briefly explain me a structure of mapping model in this
> situation? In general if you are describing a node and child
> elements/links from this node then corresponding children/link domain
> model element should be deleted from morel on deleting the node…
> Looking on your model structure I propose following mapping:
> - TopNodeMapping for Node_Object
> - TopNodeMapping for Property
> - LinkMapping with LinkMetaFeature set to a reference from Node_Object
> to Property
> In this case Property should not be removed on deleting a link from
> Node_Object to Property or NodeObject itself..
>
> -----------------
> Alex Shatalin
>
>
>
|
|
|
|
|
Re: Deletion of reference does also delete containment [message #223890 is a reply to message #223805] |
Wed, 01 April 2009 08:16  |
Eclipse User |
|
|
|
Hello Daniel,
> The problem remaines when on the diagram clicking on a property in a
> compartment, and pressing the DEL-Key on the keyboard. Then the
> original property object is destroyed as well and all other
> references are pointing to nowhere, displaying sometihing like
> ...Propert@d4rv2323 and some empty boxes as title (reference to a type
Try .. modifying PropertyItemSemanticEditPolicy.getDestroyElementCommand()
and write some custom code deleting the property from it's container only
in the situation then there are no other references to this property object.
:-)
> Is there any way to disable the deletion of properties in a
> compartment? If so the user could use the property sheets mechanism do
There should be a way to "decontribute" delete action from the particular
diagram element - see generated plugin.xml as a hint (we are "decontributing"
some actions there).
> To the link: I'm not sure what exacly you mean with it I can't create
> a link mapping for this reference or can I? I've tried, but Link
> Mappings always require to have a class and a containment feature for
> the link.
There are two types of links supported by GMF: Type-based and Feature-based.
First one is a diagram link associated with domain model element. This domain
model element should be contained in a link source domain model element and
point to the link destination one.
Second is just a reference drom source domain model element to the target
one.
To use second approach you should leave all teh fields blank in a link mapping
(domain element, containment feature) and specify only link feature (target
feature) and link diagram element. Using this approach you can link Node
diagram element with top-level Properties. This will be a different diagram
notation - you are representing association from Node to Property by a link
instead of visualizing corresponding properties in a Node's compartment,
but i can understand that sometimes requirements are a little bit different.
-----------------
Alex Shatalin
|
|
|
Powered by
FUDForum. Page generated in 0.07075 seconds