Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Passing Connections to Parent
Passing Connections to Parent [message #186960] Thu, 07 July 2005 21:28 Go to next message
Eclipse UserFriend
Originally posted by: mbernst.stanford.edu

I'm working on an application which involves several child figures living
within a parent. Imagine an iPod figure with several button figures (play,
pause, etc.) living within it. I'd like to create connections between
several iPod figures, but have these connections "originate" from a button.
That is, I'd like to create the connection by clicking on a button and then
on a destination iPod, but when I see the connections I want it to be as if
the iPods themselves (and not the child figures) are connected.

I've attempted to do this by having my buttonEditParts install a
GraphicalNodeEditPolicy and pass the commands up to their parents, who also
have the edit policy installed (which works). Here's the button's code:
protected Command getConnectionCreateCommand(CreateConnectionRequest
request) {
request.setTargetEditPart(getHost().getParent());
Command returnedCommand =
getHost().getParent().getCommand(request);
return returnedCommand;
}

This, however, is causing unusual behavior: the connection is being drawn
from some point around (100, 100) to (0, 0). My other attempt was to deal
with the command myself and not pass it to the parent:

protected Command getConnectionCreateCommand(CreateConnectionRequest
request) {
request.setSourceEditPart(getHost().getParent());
request.setTargetEditPart(getHost().getParent());
ShapeModel source = (ShapeModel) getHost().getParent().getModel();
System.out.println("Source: " + source);
int style = ((Integer) request.getNewObjectType())
.intValue();
ConnectionCreateCommand cmd = new ConnectionCreateCommand(
source, style, ((InputComponent)
getCastedModel().getComponent()));
request.setStartCommand(cmd);
return cmd;
}

Same result. Is there some better way to do what I'm attempting to do?
- Michael
Re: Passing Connections to Parent [message #187134 is a reply to message #186960] Fri, 08 July 2005 15:44 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

You are not implementing NodeEditPart completely on your target/source
nodes.

"Michael Bernstein" <mbernst@stanford.edu> wrote in message
news:dak6pr$n70$1@news.eclipse.org...
> I'm working on an application which involves several child figures living
> within a parent. Imagine an iPod figure with several button figures
> (play, pause, etc.) living within it. I'd like to create connections
> between several iPod figures, but have these connections "originate" from
> a button. That is, I'd like to create the connection by clicking on a
> button and then on a destination iPod, but when I see the connections I
> want it to be as if the iPods themselves (and not the child figures) are
> connected.
>
> I've attempted to do this by having my buttonEditParts install a
> GraphicalNodeEditPolicy and pass the commands up to their parents, who
> also have the edit policy installed (which works). Here's the button's
> code:
> protected Command getConnectionCreateCommand(CreateConnectionRequest
> request) {
> request.setTargetEditPart(getHost().getParent());
> Command returnedCommand =
> getHost().getParent().getCommand(request);
> return returnedCommand;
> }
>
> This, however, is causing unusual behavior: the connection is being drawn
> from some point around (100, 100) to (0, 0). My other attempt was to deal
> with the command myself and not pass it to the parent:
>
> protected Command getConnectionCreateCommand(CreateConnectionRequest
> request) {
> request.setSourceEditPart(getHost().getParent());
> request.setTargetEditPart(getHost().getParent());
> ShapeModel source = (ShapeModel)
> getHost().getParent().getModel();
> System.out.println("Source: " + source);
> int style = ((Integer) request.getNewObjectType())
> .intValue();
> ConnectionCreateCommand cmd = new ConnectionCreateCommand(
> source, style, ((InputComponent)
> getCastedModel().getComponent()));
> request.setStartCommand(cmd);
> return cmd;
> }
>
> Same result. Is there some better way to do what I'm attempting to do?
> - Michael
>
Previous Topic:KeyBindings
Next Topic:Printing logic diagram sample in 3.1
Goto Forum:
  


Current Time: Fri Apr 26 04:52:29 GMT 2024

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

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

Back to the top