| 
| connections not reconnecting [message #65735] | Wed, 19 February 2003 11:29  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: jwoods.journee.com 
 I've got a problem with my connections not reconnecting after an undo of a
 delete command.  If I delete a connection and do an undo, the connection is
 fine.  However, if I delete a connection and then one of the nodes the
 connection was connected to and then undo both deletes - the connection's
 endpoint doesn't follow the node's figure when it is moved.  The strange
 part is that If I close/reopen the editor - it follows it fine (possibly
 understandable because I don't persist the connection anchors themselves -
 they get recreated from other data).
 
 I know for a fact the connection is still "connected" in the model, but the
 connection's UI doesn't track the node's movement like it should.  It would
 seem as if some listener isn't getting hooked back up on the undo.  But what
 listener?  I've stepped through the debugger and it appears the connection
 anchor is being added as a listener to the node's figure (ancesterListener)
 correctly - but it doesn't appear to be getting notified. ???
 
 - Jason
 |  |  |  | 
|  | 
| 
| Re: connections not reconnecting [message #65861 is a reply to message #65758] | Thu, 20 February 2003 12:01   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: jwoods.journee.com 
 OK, I know what's going on now.  Not sure if my fix is the correct one or
 not though.  Here's the deal:
 
 Problem only occurs when I delete a connection then an endpoint node and
 then undo both deletes.  What is happening is that the edit part and the
 figure for the node is getting deleted when the node is deleted.  When I
 undo that delete, the editpart and figure get recreated for the node.  When
 I undo the connection delete, the connection is reattached to the endpoints
 but reuses existing connection anchors.  These connection anchors have an
 old reference to the original node's figure - and that's what they attach
 themselves to listen to.
 
 To fix this I've added a call to anchor.setFigure(this.getFigure()) from
 within my node EditPart's
 getSource/TargetConnectionAnchor(ConnectionEditPart) methods.  This ensures
 the anchor (whether newly created or reused) is up to date.
 
 Here's what my getSourceConnectionAnchor() method currently looks like:
 
 public void getSourceConnectionAnchor(ConnectionEditPart connEditPart)
 {
 MyConnectionModelClass conn = (MyConnectionModelClass)
 connEditPart.getModel();
 AbstractConnectionAnchor anchor = (AbstractConnectionAnchor)
 conn.getSourceConnectionAnchor();
 
 if ( anchor == null )
 {
 anchor = new MyAnchor(this.getFigure(),
 conn.getSourceReferencePoint());
 conn.setSourceConnectionAnchor(anchor);
 }
 else
 {
 anchor.setFigure(this.getFigure());
 }
 
 return anchor;
 }
 
 Currently, my connection model object holds a transient reference to the
 connection anchors - these aren't persisted.  What is persisted is a Point
 object that the model object pulls out of the connection anchor whenever the
 anchors change.
 
 Would the better fix be to refactor my code to always create a new anchor
 when getSource/TargetConnectionAnchor(ConnectionEditPart) is called?  (And
 to refactor out the transient reference to the anchor from within the
 model)...
 
 If it's ok to reuse anchors, then who should keep them?  And how do/would
 they know to ensure the owner figure is up-to-date?
 
 
 - Jason
 
 
 
 "Randy Hudson" <none@us.ibm.com> wrote in message
 news:b30bpp$1gg$1@rogue.oti.com...
 > The connection anchor listens to the node figure, but does the connection
 > listen to the connection anchor?
 >
 > We recently changed setSource/TargetAnchor(ConnectionAnchor) to remove a
 > potential memory leak.  When you undo, the polylineconnection should have
 > its source/target anchors set back.  Step into setXxxConnectionAnchor to
 see
 > if hookXxxConnecitonAnchor is being called.  If it isn't, then it might be
 > called later when activateFigure adds the connection to the connection
 > layer.
 >
 > Do you override addNotify in PolylineConnection?
 >
 > "Jason Woods" <jwoods@journee.com> wrote in message
 > news:b309qv$vaa$1@rogue.oti.com...
 > > I've got a problem with my connections not reconnecting after an undo of
 a
 > > delete command.  If I delete a connection and do an undo, the connection
 > is
 > > fine.  However, if I delete a connection and then one of the nodes the
 > > connection was connected to and then undo both deletes - the
 connection's
 > > endpoint doesn't follow the node's figure when it is moved.  The strange
 > > part is that If I close/reopen the editor - it follows it fine (possibly
 > > understandable because I don't persist the connection anchors
 themselves -
 > > they get recreated from other data).
 > >
 > > I know for a fact the connection is still "connected" in the model, but
 > the
 > > connection's UI doesn't track the node's movement like it should.  It
 > would
 > > seem as if some listener isn't getting hooked back up on the undo.  But
 > what
 > > listener?  I've stepped through the debugger and it appears the
 connection
 > > anchor is being added as a listener to the node's figure
 > (ancesterListener)
 > > correctly - but it doesn't appear to be getting notified. ???
 > >
 > > - Jason
 > >
 > >
 > >
 >
 >
 |  |  |  | 
| 
| Re: connections not reconnecting [message #65913 is a reply to message #65861] | Thu, 20 February 2003 19:13  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: none.us.ibm.com 
 Your commands should not import or reference any java types from draw2d or
 gef packages.  If you need to store the anchor location, you should create
 something in your model to represent it.
 
 "Jason Woods" <jwoods@journee.com> wrote in message
 news:b3302a$2kh$1@rogue.oti.com...
 >
 > OK, I know what's going on now.  Not sure if my fix is the correct one or
 > not though.  Here's the deal:
 >
 > Problem only occurs when I delete a connection then an endpoint node and
 > then undo both deletes.  What is happening is that the edit part and the
 > figure for the node is getting deleted when the node is deleted.  When I
 > undo that delete, the editpart and figure get recreated for the node.
 When
 > I undo the connection delete, the connection is reattached to the
 endpoints
 > but reuses existing connection anchors.  These connection anchors have an
 > old reference to the original node's figure - and that's what they attach
 > themselves to listen to.
 >
 > To fix this I've added a call to anchor.setFigure(this.getFigure()) from
 > within my node EditPart's
 > getSource/TargetConnectionAnchor(ConnectionEditPart) methods.  This
 ensures
 > the anchor (whether newly created or reused) is up to date.
 >
 > Here's what my getSourceConnectionAnchor() method currently looks like:
 >
 > public void getSourceConnectionAnchor(ConnectionEditPart connEditPart)
 > {
 >     MyConnectionModelClass conn = (MyConnectionModelClass)
 > connEditPart.getModel();
 >     AbstractConnectionAnchor anchor = (AbstractConnectionAnchor)
 > conn.getSourceConnectionAnchor();
 >
 >     if ( anchor == null )
 >     {
 >         anchor = new MyAnchor(this.getFigure(),
 > conn.getSourceReferencePoint());
 >         conn.setSourceConnectionAnchor(anchor);
 >     }
 >     else
 >     {
 >         anchor.setFigure(this.getFigure());
 >     }
 >
 >     return anchor;
 > }
 >
 > Currently, my connection model object holds a transient reference to the
 > connection anchors - these aren't persisted.  What is persisted is a Point
 > object that the model object pulls out of the connection anchor whenever
 the
 > anchors change.
 >
 > Would the better fix be to refactor my code to always create a new anchor
 > when getSource/TargetConnectionAnchor(ConnectionEditPart) is called?  (And
 > to refactor out the transient reference to the anchor from within the
 > model)...
 >
 > If it's ok to reuse anchors, then who should keep them?  And how do/would
 > they know to ensure the owner figure is up-to-date?
 >
 >
 > - Jason
 >
 >
 >
 > "Randy Hudson" <none@us.ibm.com> wrote in message
 > news:b30bpp$1gg$1@rogue.oti.com...
 > > The connection anchor listens to the node figure, but does the
 connection
 > > listen to the connection anchor?
 > >
 > > We recently changed setSource/TargetAnchor(ConnectionAnchor) to remove a
 > > potential memory leak.  When you undo, the polylineconnection should
 have
 > > its source/target anchors set back.  Step into setXxxConnectionAnchor to
 > see
 > > if hookXxxConnecitonAnchor is being called.  If it isn't, then it might
 be
 > > called later when activateFigure adds the connection to the connection
 > > layer.
 > >
 > > Do you override addNotify in PolylineConnection?
 > >
 > > "Jason Woods" <jwoods@journee.com> wrote in message
 > > news:b309qv$vaa$1@rogue.oti.com...
 > > > I've got a problem with my connections not reconnecting after an undo
 of
 > a
 > > > delete command.  If I delete a connection and do an undo, the
 connection
 > > is
 > > > fine.  However, if I delete a connection and then one of the nodes the
 > > > connection was connected to and then undo both deletes - the
 > connection's
 > > > endpoint doesn't follow the node's figure when it is moved.  The
 strange
 > > > part is that If I close/reopen the editor - it follows it fine
 (possibly
 > > > understandable because I don't persist the connection anchors
 > themselves -
 > > > they get recreated from other data).
 > > >
 > > > I know for a fact the connection is still "connected" in the model,
 but
 > > the
 > > > connection's UI doesn't track the node's movement like it should.  It
 > > would
 > > > seem as if some listener isn't getting hooked back up on the undo.
 But
 > > what
 > > > listener?  I've stepped through the debugger and it appears the
 > connection
 > > > anchor is being added as a listener to the node's figure
 > > (ancesterListener)
 > > > correctly - but it doesn't appear to be getting notified. ???
 > > >
 > > > - Jason
 > > >
 > > >
 > > >
 > >
 > >
 >
 >
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03350 seconds