Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Link Connection not deleted when connected to a child of a deleted parent.
Link Connection not deleted when connected to a child of a deleted parent. [message #150922] Wed, 15 September 2004 15:06 Go to next message
Eclipse UserFriend
Originally posted by: deckerson.spss.com

I have a situation where I have gef parts to represent SQL tables and
columns. I have the columns as children of the table. The user can then
connect the tables by linking to a column. The problem is when one of the
two tables is deleted the link connection is not deleted. How can I have
the column parts delete link connections when the table is deleted? The
link connection is deleted when I delete the column part only (not the
table).

thanks...



Re: Link Connection not deleted when connected to a child of a deleted parent. [message #151085 is a reply to message #150922] Wed, 15 September 2004 15:16 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Who's doing the actual un-linking when you delete a column? The command,
right? The same thing here. Your DeleteCommand needs to be smart enough to
disconnect all children (i.e., columns) when a table is deleted.

"David" <deckerson@spss.com> wrote in message
news:ci9lhi$4r8$1@eclipse.org...
> I have a situation where I have gef parts to represent SQL tables and
> columns. I have the columns as children of the table. The user can then
> connect the tables by linking to a column. The problem is when one of the
> two tables is deleted the link connection is not deleted. How can I have
> the column parts delete link connections when the table is deleted? The
> link connection is deleted when I delete the column part only (not the
> table).
>
> thanks...
>
>
>
>
Re: Link Connection not deleted when connected to a child of a deleted parent. [message #151089 is a reply to message #151085] Wed, 15 September 2004 15:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: deckerson.spss.com

OK...

I was originally planning to add code to the DeleteCommand to iterate
through all nested children and remove any links. I thought that maybe the
Eclipse Framework may handle the removal of nested children and their links.

thanks for the help!


"Pratik Shah" <ppshah@us.ibm.com> wrote in message
news:ci9m5l$66j$1@eclipse.org...
> Who's doing the actual un-linking when you delete a column? The command,
> right? The same thing here. Your DeleteCommand needs to be smart enough
to
> disconnect all children (i.e., columns) when a table is deleted.
>
> "David" <deckerson@spss.com> wrote in message
> news:ci9lhi$4r8$1@eclipse.org...
> > I have a situation where I have gef parts to represent SQL tables and
> > columns. I have the columns as children of the table. The user can
then
> > connect the tables by linking to a column. The problem is when one of
the
> > two tables is deleted the link connection is not deleted. How can I
have
> > the column parts delete link connections when the table is deleted?
The
> > link connection is deleted when I delete the column part only (not the
> > table).
> >
> > thanks...
> >
> >
> >
> >
>
>
Re: Link Connection not deleted when connected to a child of a deleted parent. [message #151094 is a reply to message #151089] Wed, 15 September 2004 16:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

We used to have code in GEF which would dig through all of the children's
connection. This code just made GEF more confusing, and could caused
problems if:
1) Connections were filtered by the user meaning the editparts weren't
around
2) Delete occurred in a TreeViewer which does not display connections.

So, in the first open-source release this was pulled out. The result is
that your command needs to be smarted. See the logic example for how to
implement this type of connection deletion the right way. You need to be
careful if the tables at BOTH ends of the connection are being deleted.
Don't delete it twice, because on undo you will re-add it twice.

"David" <deckerson@spss.com> wrote in message
news:ci9ndk$8kn$1@eclipse.org...
> OK...
>
> I was originally planning to add code to the DeleteCommand to iterate
> through all nested children and remove any links. I thought that maybe
the
> Eclipse Framework may handle the removal of nested children and their
links.
>
> thanks for the help!
>
>
> "Pratik Shah" <ppshah@us.ibm.com> wrote in message
> news:ci9m5l$66j$1@eclipse.org...
> > Who's doing the actual un-linking when you delete a column? The
command,
> > right? The same thing here. Your DeleteCommand needs to be smart
enough
> to
> > disconnect all children (i.e., columns) when a table is deleted.
> >
> > "David" <deckerson@spss.com> wrote in message
> > news:ci9lhi$4r8$1@eclipse.org...
> > > I have a situation where I have gef parts to represent SQL tables and
> > > columns. I have the columns as children of the table. The user can
> then
> > > connect the tables by linking to a column. The problem is when one of
> the
> > > two tables is deleted the link connection is not deleted. How can I
> have
> > > the column parts delete link connections when the table is deleted?
> The
> > > link connection is deleted when I delete the column part only (not the
> > > table).
> > >
> > > thanks...
> > >
> > >
> > >
> > >
> >
> >
>
>
Re: Link Connection not deleted when connected to a child of a deleted parent. [message #151125 is a reply to message #151094] Wed, 15 September 2004 19:29 Go to previous message
Eclipse UserFriend
Originally posted by: deckerson.spss.com

Thanks for the help... I got my DeleteCommand to remove the links that are
associated with the columns (children).
It was not difficult to do. I thought that mybe I was not using the GEF
framework correctly.

Here is a snippet of code from the DeleteCommand and how I am checking
children for link connections:

public void execute()
{
redo();
}

public void redo()
{
index = ivParent.getChildren().indexOf(child);
ivParent.removeChild(child);
Links(child, DETACH_LINK);
}

public void undo()
{
ivParent.addChild(index, child);
Links(child, ATTACH_LINK);
}

/**
* This recursive method will iterate through all nested children
* to find and act on all parts that have links.
*
* @param child the child that may have links
*/
private void Links(Child child, int action)
{
if(child instanceof Linkable)
Links((Linkable) child, action);

if(child instanceof Parent)
{
List list = ((Parent)child).getChildren();
for(int idx =0; idx < list.size(); idx++)
{
if(list.get(idx) != null)
Links((Child)list.get(idx), action);
}
}
}

/**
* called to act on all links from a linkable part.
*
* @param linkable a linkable part that may have links
*/
private void Links(Linkable linkable, int action)
{
for(Iterator i=linkable.getSourceLinks().iterator(); i.hasNext();)
{
Link l = (Link)i.next();
if(action == DETACH_LINK)
l.detachTarget();
else
l.attachTarget();
}

for(Iterator i=linkable.getTargetLinks().iterator(); i.hasNext();)
{
Link l = (Link)i.next();
if(action == DETACH_LINK)
l.detachSource();
else
l.attachSource();
}
}


thanks for the help!


"Randy Hudson" <none@us.ibm.com> wrote in message
news:ci9r0f$fjb$1@eclipse.org...
> We used to have code in GEF which would dig through all of the children's
> connection. This code just made GEF more confusing, and could caused
> problems if:
> 1) Connections were filtered by the user meaning the editparts weren't
> around
> 2) Delete occurred in a TreeViewer which does not display connections.
>
> So, in the first open-source release this was pulled out. The result is
> that your command needs to be smarted. See the logic example for how to
> implement this type of connection deletion the right way. You need to be
> careful if the tables at BOTH ends of the connection are being deleted.
> Don't delete it twice, because on undo you will re-add it twice.
>
> "David" <deckerson@spss.com> wrote in message
> news:ci9ndk$8kn$1@eclipse.org...
> > OK...
> >
> > I was originally planning to add code to the DeleteCommand to iterate
> > through all nested children and remove any links. I thought that maybe
> the
> > Eclipse Framework may handle the removal of nested children and their
> links.
> >
> > thanks for the help!
> >
> >
> > "Pratik Shah" <ppshah@us.ibm.com> wrote in message
> > news:ci9m5l$66j$1@eclipse.org...
> > > Who's doing the actual un-linking when you delete a column? The
> command,
> > > right? The same thing here. Your DeleteCommand needs to be smart
> enough
> > to
> > > disconnect all children (i.e., columns) when a table is deleted.
> > >
> > > "David" <deckerson@spss.com> wrote in message
> > > news:ci9lhi$4r8$1@eclipse.org...
> > > > I have a situation where I have gef parts to represent SQL tables
and
> > > > columns. I have the columns as children of the table. The user can
> > then
> > > > connect the tables by linking to a column. The problem is when one
of
> > the
> > > > two tables is deleted the link connection is not deleted. How can I
> > have
> > > > the column parts delete link connections when the table is deleted?
> > The
> > > > link connection is deleted when I delete the column part only (not
the
> > > > table).
> > > >
> > > > thanks...
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Previous Topic:Outline View
Next Topic:PolygonFigure
Goto Forum:
  


Current Time: Sat Apr 27 03:12:04 GMT 2024

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

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

Back to the top