Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Still not solved: Semantical container != Graphical container
Still not solved: Semantical container != Graphical container [message #11801] Wed, 09 August 2006 08:17 Go to next message
Eclipse UserFriend
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 #19548 is a reply to message #11801] Tue, 15 August 2006 11:52 Go to previous messageGo to next message
Eclipse UserFriend
Hello Thomas,

> 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"
I’d suggest you to change your domain meta-model to reflect connection from
Y node to X nodes. (Add something like optional note link) this link could
be created directly in NodeItemSemanticEditPolicy for the X-nodes (AFAIU,
you’ve patched this class already) and used by CanonicalEditPolicy for diagram
to filter out unnecessary Y-nodes.
Another option (if you can not reflect this information in your domain meta-model)
is to call CanonicalEditPolicy for diagram once more after creation of Y-node
to remove unnecessary Y-node on diagram, I think.

-----------------
Alex Shatalin
Re: Still not solved: Semantical container != Graphical container [message #20024 is a reply to message #19548] Wed, 16 August 2006 03:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jw377.safe-mail.net

Hi Alex!

Alex Shatalin schrieb:
> I’d suggest you to change your domain meta-model to reflect connection
> from Y node to X nodes. (Add something like optional note link) this
> link could be created directly in NodeItemSemanticEditPolicy for the
> X-nodes (AFAIU, you’ve patched this class already) and used by
> CanonicalEditPolicy for diagram to filter out unnecessary Y-nodes.
> Another option (if you can not reflect this information in your domain
> meta-model) is to call CanonicalEditPolicy for diagram once more after
> creation of Y-node to remove unnecessary Y-node on diagram, I think.

Because I could not change my domain meta-model I found another way to
get the desired behavior:
I (temporary) deactivated the EditPolicyRoles.CANONICAL_ROLE EditPolicy
of the canvas in the getCreateCommand method of the
ItemSemanticEditPoliy of X in case the req.getElementType was C. This
way, the Y node was not added to the diagram's canvas.

Could you please explain, how/where I can "call" CanonicalEditPolicy for
the diagram once more after creation of an Y-node?

Thanks for your support.

Thomas
Re: Still not solved: Semantical container != Graphical container [message #20717 is a reply to message #20024] Wed, 16 August 2006 08:57 Go to previous messageGo to next message
Eclipse UserFriend
Hello Thomas,


> Could you please explain, how/where I can "call" CanonicalEditPolicy
> for the diagram once more after creation of an Y-node?
You can either change some properties of diagram element and cause notification
to be sent to XXXCanonicalEditPolicy or just call CanonicalEditPolicy.refresh()
method. You can get all registered CanonicalEditpolicies by calling CanonicalEditPolicy.getRegisteredEditPolicies()
with Diagram passed as parameter of this method.

-----------------
Alex Shatalin
Re: Still not solved: Semantical container != Graphical container [message #20895 is a reply to message #20717] Wed, 16 August 2006 14:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jw377.safe-mail.net

Hi Alex!

Alex Shatalin schrieb:
>> Could you please explain, how/where I can "call" CanonicalEditPolicy
>> for the diagram once more after creation of an Y-node?
> You can either change some properties of diagram element and cause
> notification to be sent to XXXCanonicalEditPolicy or just call
> CanonicalEditPolicy.refresh() method. You can get all registered
> CanonicalEditpolicies by calling
> CanonicalEditPolicy.getRegisteredEditPolicies() with Diagram passed as
> parameter of this method.

Thanks for your answer. But my problem is where to call this refresh().
If I create a Y node, the getCreateCommand of the ItemSemanticEditPolicy
is called which returns the appropriate command (and the framework
creates the node etc.). So I do not know, where I should call the refresh.

Thomas
Re: Still not solved: Semantical container != Graphical container [message #21543 is a reply to message #20895] Wed, 16 August 2006 15:13 Go to previous message
Eclipse UserFriend
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
Previous Topic:Need Help how to change color of the shape programatically
Next Topic:Custom Tabbed Properties Contribution declarations (through code instead of in the plugin.xml) ?
Goto Forum:
  


Current Time: Mon Jun 09 08:21:00 EDT 2025

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

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

Back to the top