Still not solved: Semantical container != Graphical container [message #11801] |
Wed, 09 August 2006 08:17  |
Eclipse User |
|
|
|
Originally posted by: jw377.safe-mail.net
Hi all!
(Sorry for being a little bit longish)
I had already discussed the following problem in a earlier thread and
thought it was solved but now I discovered that the problem still
remains (see: news://news.eclipse.org:119/easts7$92b$1@utils.eclipse.org)*.
> On top level I have the diagram canvas (corresponding to semantical
> element A). A references Elements of type B and C. Furthermore I have
> a graphical node X (for the semantical element B) and a graphical
> node Y (for the semantical element C).
>
> By following your advice I am able to create Y-nodes within X-nodes.
> But when I create this node within the X-node, another Y-node is also
> created in the canvas. So I have two Y-nodes for one C element (one
> in the X-node and one in the canvas).
>
> Any idea how to prevent the second Y-node to appear in the canvas?
I have tried to solve this problem as suggested by Dmitry Stadnik and
tried to express this situation in the CanonicalEditPolicies but I ran
into the following problem:
I added code to the method getViewChildren() of the Canvas, which
determines, if a visual child of the canvas (X-node) already contains an
Y-node. If so, this Y-node is not added to the returned list.
Now when I use the creation tool for an Y-node and click into an X-node,
the method getViewChildren() of the Canvas is called, but the Y-node
is yet not added to the X-node, so the list of visual children of X is
empty. Thus the Y-node is added to the canvas (too).
If I save this diagram (with the duplicated Y-node: one in the X-node
and one in the canvas) and reopen the diagram, the Y-node is correctly
displayed only in the X-node (and not in the diagram canvas). If I debug
getViewChildren() of the canvas in this situation, the list of visual
children of X already contains the Y-node.
Can anybody give me a hint how to change the CanonicalEditPolicy of the
Canvas, so that the Y-node is not added to the list of "visible"
children, when I create an Y-node within an X-node. At the moment I have
to close and reopen the diagram, because I did not find a place in the
generated code, where I can decide/see, if the Y-node has been/should be
added to a X-node or the canvas.
Thank you very much for your help
Thomas
*: The reason why I thought the problem was solved: In my plugin a
runtime exception was thrown in another part of the code just in the
moment the Y-node was added to the X-node, which I saw by chance when
exploring the runtime log. As a result the Y-node was (correctly) only
displayed within the X-node. When I removed the bug which lead to the
runtime exception, the Y-node again appeared within the X-node and the
canvas...
|
|
|
|
|
|
|
Re: Still not solved: Semantical container != Graphical container [message #21543 is a reply to message #20895] |
Wed, 16 August 2006 15:13  |
Eclipse User |
|
|
|
Hello Thomas,
I think you can do it after creation of corresponding notation model object.
CreationEditPolicy.getCreateElementAndViewCommand() will be called as a result
of processing request passed to the EditPart from palette tool. This method
will create composite command containing semantic creation command + view
creation command. You can add one more command executing “refresh()” method
into this composite command.
If you open XEditPart (or XYEditPart if you are using compartment for Y elements
in X) you’ll see that CreationEditPolicy is installed in createDefaultEditPolicies()
method. You can install custom subclass of CreationEditPolicy adding custom
refresh command in this method.
I suppose that there should be another way to suppress notification processing
by CanonicalEditPolicy after SemanticCreation command execution and before
ViewCreationCommand execution, but it’s better to ask runtime team how to
make it working.
-----------------
Alex Shatalin
|
|
|
Powered by
FUDForum. Page generated in 0.03949 seconds