Home » Eclipse Projects » GEF » Delete
Delete [message #22675] |
Tue, 01 October 2002 22:17 |
Eclipse User |
|
|
|
Originally posted by: jayuen.alumni.uwaterloo.ca
Hi:
I'm having some problems implementing delete functionality. I am trying to
follow the Logic example as well as going through the GEF source.
Specifically, I wanted to know:
a) Using some print statements in the TargetTool class, I've discovered that
when I click on the LogicDiagramEditPart, the target request is already set
to a DeleteRequest. Why is this and more importantly, WHERE is this set?
b) It seems like there are two ways to delete an object from the Logic
example: pressing the delete key and right clicking and selecting delete.
Where in the Logic code does this occur? Is a Tool of some sort used?? I
know that you must install a a subclass of ComponentEditPolicy in order to
handle the createDeleteCommand method. However, I am having some
difficulties locating where the method is (indirectly) called from the Logic
example.
c) If I want to delete both the glyph and the connections associated with
the glyph, how do I go about doing that? Do I need to subclass a
ContainerEditPolicy? If so, is this functionality handled in the
getDeleteDependantCommand or getOrphanChildren?
any help would be greatly appreciated, thanks!
Jason
|
|
|
Re: Delete [message #22848 is a reply to message #22675] |
Wed, 02 October 2002 14:04 |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
"Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
news:and5l4$ive$1@rogue.oti.com...
> Hi:
>
> I'm having some problems implementing delete functionality. I am trying
to
> follow the Logic example as well as going through the GEF source.
> Specifically, I wanted to know:
>
> a) Using some print statements in the TargetTool class, I've discovered
that
> when I click on the LogicDiagramEditPart, the target request is already
set
> to a DeleteRequest. Why is this and more importantly, WHERE is this set?
Are you sure this was coming from a println in a Tool? DeleteRequest is
used by the DeleteAction, not any Tools. The DeleteAction appears in a lot
of places. It (The same instance) appears in the context menu, the Global
"delete" Action on the Edit Menu, The Editor's Toolbar, and the
GraphicalViewer's KeyHandler to handle the keystroke for delete.
> b) It seems like there are two ways to delete an object from the Logic
> example: pressing the delete key and right clicking and selecting delete.
There are 4, put a breakpoint in DeleteAction.
> Where in the Logic code does this occur? Is a Tool of some sort used?? I
> know that you must install a a subclass of ComponentEditPolicy in order to
> handle the createDeleteCommand method. However, I am having some
> difficulties locating where the method is (indirectly) called from the
Logic
> example.
>
> c) If I want to delete both the glyph and the connections associated with
> the glyph, how do I go about doing that? Do I need to subclass a
> ContainerEditPolicy? If so, is this functionality handled in the
> getDeleteDependantCommand or getOrphanChildren?
You can do this a thousand ways. One way that we support, but it *ONLY*
works if you can guarantee that your glyph always performs the Delete, is to
have the "node" forward the Delete to its connections. There is a
NodeEditPolicy in GEF specifically to do this forwarding, and the Logic
example demonstrates this. The benefit of forwarding to the Connection is
that it can do additional things that the Node might not need to know about,
like deleting a connection to the connection.
Another way is to put this behavior on the Node itself. You can just
subclass NodeEditPolicy and override the method that generates the delete
command. This means the Node has to know everything about all connections.
However, the benefit is that you can use such an EditPolicy in the Outline
View. In the Outline, you typically can see nodes, but not any connection,
so there is no one to forward the delete to. The Logic Example also
demonstrates this usage in the EditParts that appear on the Tree
(LogicTreeNodeEditPolicy, "Tree" meaning it is used in the TreeViewer).
A third way is to have all EditPolicies delegate to some other "command
factory" helper. One reason for doing this might be that you have places
where Nodes can be deleted, and you aren't even using GEF or EditParts to
display the Nodes.
> any help would be greatly appreciated, thanks!
>
> Jason
>
>
|
|
|
Re: Delete [message #22891 is a reply to message #22848] |
Wed, 02 October 2002 15:58 |
Eclipse User |
|
|
|
Originally posted by: jayuen.alumni.uwaterloo.ca
Thanks for the pointers.
with respect to the "command factory" helper that you mentioned, are you
saying that I have a helper class to which the DeleteCommand.execute()
delegates? Right now, my DeleteCommand.execute() simply removes the cihld
that was set to the command in the EditPolicy from the parent that was set
to the comand in the EditPolicy.
Your suggestion was appealing because I eventually want to support the
ability to delete edit parts from other editors that are NOT gui-based
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:anet5k$h6v$1@rogue.oti.com...
> "Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
> news:and5l4$ive$1@rogue.oti.com...
> > Hi:
> >
> > I'm having some problems implementing delete functionality. I am trying
> to
> > follow the Logic example as well as going through the GEF source.
> > Specifically, I wanted to know:
> >
> > a) Using some print statements in the TargetTool class, I've discovered
> that
> > when I click on the LogicDiagramEditPart, the target request is already
> set
> > to a DeleteRequest. Why is this and more importantly, WHERE is this
set?
>
> Are you sure this was coming from a println in a Tool? DeleteRequest is
> used by the DeleteAction, not any Tools. The DeleteAction appears in a
lot
> of places. It (The same instance) appears in the context menu, the Global
> "delete" Action on the Edit Menu, The Editor's Toolbar, and the
> GraphicalViewer's KeyHandler to handle the keystroke for delete.
>
> > b) It seems like there are two ways to delete an object from the Logic
> > example: pressing the delete key and right clicking and selecting
delete.
>
> There are 4, put a breakpoint in DeleteAction.
>
> > Where in the Logic code does this occur? Is a Tool of some sort used??
I
> > know that you must install a a subclass of ComponentEditPolicy in order
to
> > handle the createDeleteCommand method. However, I am having some
> > difficulties locating where the method is (indirectly) called from the
> Logic
> > example.
> >
> > c) If I want to delete both the glyph and the connections associated
with
> > the glyph, how do I go about doing that? Do I need to subclass a
> > ContainerEditPolicy? If so, is this functionality handled in the
> > getDeleteDependantCommand or getOrphanChildren?
>
> You can do this a thousand ways. One way that we support, but it *ONLY*
> works if you can guarantee that your glyph always performs the Delete, is
to
> have the "node" forward the Delete to its connections. There is a
> NodeEditPolicy in GEF specifically to do this forwarding, and the Logic
> example demonstrates this. The benefit of forwarding to the Connection is
> that it can do additional things that the Node might not need to know
about,
> like deleting a connection to the connection.
>
> Another way is to put this behavior on the Node itself. You can just
> subclass NodeEditPolicy and override the method that generates the delete
> command. This means the Node has to know everything about all
connections.
> However, the benefit is that you can use such an EditPolicy in the Outline
> View. In the Outline, you typically can see nodes, but not any
connection,
> so there is no one to forward the delete to. The Logic Example also
> demonstrates this usage in the EditParts that appear on the Tree
> (LogicTreeNodeEditPolicy, "Tree" meaning it is used in the TreeViewer).
>
> A third way is to have all EditPolicies delegate to some other "command
> factory" helper. One reason for doing this might be that you have places
> where Nodes can be deleted, and you aren't even using GEF or EditParts to
> display the Nodes.
>
> > any help would be greatly appreciated, thanks!
> >
> > Jason
> >
> >
>
>
|
|
|
Re: Delete [message #22936 is a reply to message #22891] |
Wed, 02 October 2002 16:13 |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
> Thanks for the pointers.
>
> with respect to the "command factory" helper that you mentioned, are you
> saying that I have a helper class to which the DeleteCommand.execute()
> delegates? Right now, my DeleteCommand.execute() simply removes the cihld
No, I was suggesting that you might have a helper that does:
CommandFactory {
public Command getDeleteNodeCommand(LogicSubpart node){
CompoundCommand command = new CompoundCommand();
//Add all of the other steps necessary to delete a node,
//such as deleting its connections
return command;
}
}
And then your NodeEditPolicy.createDeleteCommand(EditPart part) looks like:
return
CommandFactory.getDeleteNodeCommand((LogicSubpart)part.getMo del());
> that was set to the command in the EditPolicy from the parent that was set
> to the comand in the EditPolicy.
>
> Your suggestion was appealing because I eventually want to support the
> ability to delete edit parts from other editors that are NOT gui-based
By gui, you mean GEF-based? Commands are still nice to use to support undo,
so you might want to use commands in you non gui-based editor as well.
>
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:anet5k$h6v$1@rogue.oti.com...
> > "Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
> > news:and5l4$ive$1@rogue.oti.com...
> > > Hi:
> > >
> > > I'm having some problems implementing delete functionality. I am
trying
> > to
> > > follow the Logic example as well as going through the GEF source.
> > > Specifically, I wanted to know:
> > >
> > > a) Using some print statements in the TargetTool class, I've
discovered
> > that
> > > when I click on the LogicDiagramEditPart, the target request is
already
> > set
> > > to a DeleteRequest. Why is this and more importantly, WHERE is this
> set?
> >
> > Are you sure this was coming from a println in a Tool? DeleteRequest is
> > used by the DeleteAction, not any Tools. The DeleteAction appears in a
> lot
> > of places. It (The same instance) appears in the context menu, the
Global
> > "delete" Action on the Edit Menu, The Editor's Toolbar, and the
> > GraphicalViewer's KeyHandler to handle the keystroke for delete.
> >
> > > b) It seems like there are two ways to delete an object from the Logic
> > > example: pressing the delete key and right clicking and selecting
> delete.
> >
> > There are 4, put a breakpoint in DeleteAction.
> >
> > > Where in the Logic code does this occur? Is a Tool of some sort
used??
> I
> > > know that you must install a a subclass of ComponentEditPolicy in
order
> to
> > > handle the createDeleteCommand method. However, I am having some
> > > difficulties locating where the method is (indirectly) called from the
> > Logic
> > > example.
> > >
> > > c) If I want to delete both the glyph and the connections associated
> with
> > > the glyph, how do I go about doing that? Do I need to subclass a
> > > ContainerEditPolicy? If so, is this functionality handled in the
> > > getDeleteDependantCommand or getOrphanChildren?
> >
> > You can do this a thousand ways. One way that we support, but it *ONLY*
> > works if you can guarantee that your glyph always performs the Delete,
is
> to
> > have the "node" forward the Delete to its connections. There is a
> > NodeEditPolicy in GEF specifically to do this forwarding, and the Logic
> > example demonstrates this. The benefit of forwarding to the Connection
is
> > that it can do additional things that the Node might not need to know
> about,
> > like deleting a connection to the connection.
> >
> > Another way is to put this behavior on the Node itself. You can just
> > subclass NodeEditPolicy and override the method that generates the
delete
> > command. This means the Node has to know everything about all
> connections.
> > However, the benefit is that you can use such an EditPolicy in the
Outline
> > View. In the Outline, you typically can see nodes, but not any
> connection,
> > so there is no one to forward the delete to. The Logic Example also
> > demonstrates this usage in the EditParts that appear on the Tree
> > (LogicTreeNodeEditPolicy, "Tree" meaning it is used in the TreeViewer).
> >
> > A third way is to have all EditPolicies delegate to some other "command
> > factory" helper. One reason for doing this might be that you have
places
> > where Nodes can be deleted, and you aren't even using GEF or EditParts
to
> > display the Nodes.
> >
> > > any help would be greatly appreciated, thanks!
> > >
> > > Jason
> > >
> > >
> >
> >
>
>
|
|
|
Re: Delete [message #22979 is a reply to message #22936] |
Wed, 02 October 2002 16:29 |
Eclipse User |
|
|
|
Originally posted by: jayuen.alumni.uwaterloo.ca
suppose that my Editor is not GEF-based but uses SWT widgets. Suppose I
have two editors opened on the same resource. If I delete/add something in
the non-GEF based Editor I want it to update my GEF-based Editor (e.g. by
adding a glyph to the GEF-editor) CanI still use GEF commands? Or is the
Request-Command architecture too tightly coupled to GEF?
JY
"Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
news:anf4nt$n01$1@rogue.oti.com...
> > Thanks for the pointers.
> >
> > with respect to the "command factory" helper that you mentioned, are you
> > saying that I have a helper class to which the DeleteCommand.execute()
> > delegates? Right now, my DeleteCommand.execute() simply removes the
cihld
>
> No, I was suggesting that you might have a helper that does:
>
> CommandFactory {
>
> public Command getDeleteNodeCommand(LogicSubpart node){
> CompoundCommand command = new CompoundCommand();
> //Add all of the other steps necessary to delete a node,
> //such as deleting its connections
> return command;
> }
>
> }
>
> And then your NodeEditPolicy.createDeleteCommand(EditPart part) looks
like:
> return
> CommandFactory.getDeleteNodeCommand((LogicSubpart)part.getMo del());
>
> > that was set to the command in the EditPolicy from the parent that was
set
> > to the comand in the EditPolicy.
> >
> > Your suggestion was appealing because I eventually want to support the
> > ability to delete edit parts from other editors that are NOT gui-based
>
> By gui, you mean GEF-based? Commands are still nice to use to support
undo,
> so you might want to use commands in you non gui-based editor as well.
>
> >
> >
> > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > news:anet5k$h6v$1@rogue.oti.com...
> > > "Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
> > > news:and5l4$ive$1@rogue.oti.com...
> > > > Hi:
> > > >
> > > > I'm having some problems implementing delete functionality. I am
> trying
> > > to
> > > > follow the Logic example as well as going through the GEF source.
> > > > Specifically, I wanted to know:
> > > >
> > > > a) Using some print statements in the TargetTool class, I've
> discovered
> > > that
> > > > when I click on the LogicDiagramEditPart, the target request is
> already
> > > set
> > > > to a DeleteRequest. Why is this and more importantly, WHERE is this
> > set?
> > >
> > > Are you sure this was coming from a println in a Tool? DeleteRequest
is
> > > used by the DeleteAction, not any Tools. The DeleteAction appears in
a
> > lot
> > > of places. It (The same instance) appears in the context menu, the
> Global
> > > "delete" Action on the Edit Menu, The Editor's Toolbar, and the
> > > GraphicalViewer's KeyHandler to handle the keystroke for delete.
> > >
> > > > b) It seems like there are two ways to delete an object from the
Logic
> > > > example: pressing the delete key and right clicking and selecting
> > delete.
> > >
> > > There are 4, put a breakpoint in DeleteAction.
> > >
> > > > Where in the Logic code does this occur? Is a Tool of some sort
> used??
> > I
> > > > know that you must install a a subclass of ComponentEditPolicy in
> order
> > to
> > > > handle the createDeleteCommand method. However, I am having some
> > > > difficulties locating where the method is (indirectly) called from
the
> > > Logic
> > > > example.
> > > >
> > > > c) If I want to delete both the glyph and the connections associated
> > with
> > > > the glyph, how do I go about doing that? Do I need to subclass a
> > > > ContainerEditPolicy? If so, is this functionality handled in the
> > > > getDeleteDependantCommand or getOrphanChildren?
> > >
> > > You can do this a thousand ways. One way that we support, but it
*ONLY*
> > > works if you can guarantee that your glyph always performs the Delete,
> is
> > to
> > > have the "node" forward the Delete to its connections. There is a
> > > NodeEditPolicy in GEF specifically to do this forwarding, and the
Logic
> > > example demonstrates this. The benefit of forwarding to the
Connection
> is
> > > that it can do additional things that the Node might not need to know
> > about,
> > > like deleting a connection to the connection.
> > >
> > > Another way is to put this behavior on the Node itself. You can just
> > > subclass NodeEditPolicy and override the method that generates the
> delete
> > > command. This means the Node has to know everything about all
> > connections.
> > > However, the benefit is that you can use such an EditPolicy in the
> Outline
> > > View. In the Outline, you typically can see nodes, but not any
> > connection,
> > > so there is no one to forward the delete to. The Logic Example also
> > > demonstrates this usage in the EditParts that appear on the Tree
> > > (LogicTreeNodeEditPolicy, "Tree" meaning it is used in the
TreeViewer).
> > >
> > > A third way is to have all EditPolicies delegate to some other
"command
> > > factory" helper. One reason for doing this might be that you have
> places
> > > where Nodes can be deleted, and you aren't even using GEF or EditParts
> to
> > > display the Nodes.
> > >
> > > > any help would be greatly appreciated, thanks!
> > > >
> > > > Jason
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Re: Delete [message #23022 is a reply to message #22979] |
Wed, 02 October 2002 17:26 |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
Yes, you can still use commands, but you have lot's of other stuff to do to
make this work. You should probably be sharing the same in-memory model
between the 2 editors. The same is done when you open the same .java file
in Eclipse. The command stacks are usually shared too, but sometimes this
is more difficult.
WSAD does this with several types of editors as well.
"Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
news:anf5jt$nk6$1@rogue.oti.com...
> suppose that my Editor is not GEF-based but uses SWT widgets. Suppose I
> have two editors opened on the same resource. If I delete/add something
in
> the non-GEF based Editor I want it to update my GEF-based Editor (e.g. by
> adding a glyph to the GEF-editor) CanI still use GEF commands? Or is the
> Request-Command architecture too tightly coupled to GEF?
>
> JY
>
> "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> news:anf4nt$n01$1@rogue.oti.com...
> > > Thanks for the pointers.
> > >
> > > with respect to the "command factory" helper that you mentioned, are
you
> > > saying that I have a helper class to which the DeleteCommand.execute()
> > > delegates? Right now, my DeleteCommand.execute() simply removes the
> cihld
> >
> > No, I was suggesting that you might have a helper that does:
> >
> > CommandFactory {
> >
> > public Command getDeleteNodeCommand(LogicSubpart node){
> > CompoundCommand command = new CompoundCommand();
> > //Add all of the other steps necessary to delete a node,
> > //such as deleting its connections
> > return command;
> > }
> >
> > }
> >
> > And then your NodeEditPolicy.createDeleteCommand(EditPart part) looks
> like:
> > return
> > CommandFactory.getDeleteNodeCommand((LogicSubpart)part.getMo del());
> >
> > > that was set to the command in the EditPolicy from the parent that was
> set
> > > to the comand in the EditPolicy.
> > >
> > > Your suggestion was appealing because I eventually want to support
the
> > > ability to delete edit parts from other editors that are NOT gui-based
> >
> > By gui, you mean GEF-based? Commands are still nice to use to support
> undo,
> > so you might want to use commands in you non gui-based editor as well.
> >
> > >
> > >
> > > "Randy Hudson" <hudsonr@us.eye-bee-em.com> wrote in message
> > > news:anet5k$h6v$1@rogue.oti.com...
> > > > "Jason Yuen" <jayuen@alumni.uwaterloo.ca> wrote in message
> > > > news:and5l4$ive$1@rogue.oti.com...
> > > > > Hi:
> > > > >
> > > > > I'm having some problems implementing delete functionality. I am
> > trying
> > > > to
> > > > > follow the Logic example as well as going through the GEF source.
> > > > > Specifically, I wanted to know:
> > > > >
> > > > > a) Using some print statements in the TargetTool class, I've
> > discovered
> > > > that
> > > > > when I click on the LogicDiagramEditPart, the target request is
> > already
> > > > set
> > > > > to a DeleteRequest. Why is this and more importantly, WHERE is
this
> > > set?
> > > >
> > > > Are you sure this was coming from a println in a Tool?
DeleteRequest
> is
> > > > used by the DeleteAction, not any Tools. The DeleteAction appears
in
> a
> > > lot
> > > > of places. It (The same instance) appears in the context menu, the
> > Global
> > > > "delete" Action on the Edit Menu, The Editor's Toolbar, and the
> > > > GraphicalViewer's KeyHandler to handle the keystroke for delete.
> > > >
> > > > > b) It seems like there are two ways to delete an object from the
> Logic
> > > > > example: pressing the delete key and right clicking and selecting
> > > delete.
> > > >
> > > > There are 4, put a breakpoint in DeleteAction.
> > > >
> > > > > Where in the Logic code does this occur? Is a Tool of some sort
> > used??
> > > I
> > > > > know that you must install a a subclass of ComponentEditPolicy in
> > order
> > > to
> > > > > handle the createDeleteCommand method. However, I am having some
> > > > > difficulties locating where the method is (indirectly) called from
> the
> > > > Logic
> > > > > example.
> > > > >
> > > > > c) If I want to delete both the glyph and the connections
associated
> > > with
> > > > > the glyph, how do I go about doing that? Do I need to subclass a
> > > > > ContainerEditPolicy? If so, is this functionality handled in the
> > > > > getDeleteDependantCommand or getOrphanChildren?
> > > >
> > > > You can do this a thousand ways. One way that we support, but it
> *ONLY*
> > > > works if you can guarantee that your glyph always performs the
Delete,
> > is
> > > to
> > > > have the "node" forward the Delete to its connections. There is a
> > > > NodeEditPolicy in GEF specifically to do this forwarding, and the
> Logic
> > > > example demonstrates this. The benefit of forwarding to the
> Connection
> > is
> > > > that it can do additional things that the Node might not need to
know
> > > about,
> > > > like deleting a connection to the connection.
> > > >
> > > > Another way is to put this behavior on the Node itself. You can
just
> > > > subclass NodeEditPolicy and override the method that generates the
> > delete
> > > > command. This means the Node has to know everything about all
> > > connections.
> > > > However, the benefit is that you can use such an EditPolicy in the
> > Outline
> > > > View. In the Outline, you typically can see nodes, but not any
> > > connection,
> > > > so there is no one to forward the delete to. The Logic Example also
> > > > demonstrates this usage in the EditParts that appear on the Tree
> > > > (LogicTreeNodeEditPolicy, "Tree" meaning it is used in the
> TreeViewer).
> > > >
> > > > A third way is to have all EditPolicies delegate to some other
> "command
> > > > factory" helper. One reason for doing this might be that you have
> > places
> > > > where Nodes can be deleted, and you aren't even using GEF or
EditParts
> > to
> > > > display the Nodes.
> > > >
> > > > > any help would be greatly appreciated, thanks!
> > > > >
> > > > > Jason
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
|
|
|
Goto Forum:
Current Time: Thu Dec 26 16:43:45 GMT 2024
Powered by FUDForum. Page generated in 0.03763 seconds
|