Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to delete a figure?
How to delete a figure? [message #8758] Mon, 10 June 2002 06:05 Go to next message
Yoav Rubin is currently offline Yoav RubinFriend
Messages: 93
Registered: July 2009
Member
Hi
i'm trying to allow the users of my editorpart to delete editparts from
the canvas, i've installed an editpolicy to these editparts (the
editpolicy extends ComponentEditPolicy, and implements the method
createDeleteCommand, that returns a command that i created for that
matter), the role of the editpolicy is EditPolicy.COMPONENT_ROLE. i also
added the delete action to the cotext menu contributor and to the action
registry (and also added a key listener to the DEL key). when the context
menu opens the delete action apears there, but it is disabled. moreover,
when i press the DEL key after i select an editpart nothing happends. do
you have any ideas?
thanks
yoav
Re: How to delete a figure? [message #8769 is a reply to message #8758] Mon, 10 June 2002 07:21 Go to previous messageGo to next message
Yoav Rubin is currently offline Yoav RubinFriend
Messages: 93
Registered: July 2009
Member
ok, got it, i needed to add the line
getSite().setSelectionProvider(getPrimaryViewer()); to the init method at
my editor.

Yoav Rubin wrote:

> Hi
> i'm trying to allow the users of my editorpart to delete editparts from
> the canvas, i've installed an editpolicy to these editparts (the
> editpolicy extends ComponentEditPolicy, and implements the method
> createDeleteCommand, that returns a command that i created for that
> matter), the role of the editpolicy is EditPolicy.COMPONENT_ROLE. i also
> added the delete action to the cotext menu contributor and to the action
> registry (and also added a key listener to the DEL key). when the context
> menu opens the delete action apears there, but it is disabled. moreover,
> when i press the DEL key after i select an editpart nothing happends. do
> you have any ideas?
> thanks
> yoav
Re: How to delete a figure? [message #9249 is a reply to message #8758] Mon, 10 June 2002 13:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.ibm.com

> menu opens the delete action apears there, but it is disabled. moreover,
> when i press the DEL key after i select an editpart nothing happends. do

You shouldn't add any key listeners like this. The reason is that you will
be able to delete an object while it is being dragged. In general,
everything should be "locked" during a drag, such as Undo, Redo, Delete. No
menu accelerators function during a drag, so we're safe there. But the
canvas still gets key events.

To get this for *free*, create a GraphicalViewerKeyHandler for your
GraphicalViewer. Then, do a:
sharedKeyHandler.put(
KeyStroke.getPressed(SWT.DEL, 0),
getActionRegistry().getAction(DeleteAction.ID));

KeyHandler's will only get KeyEvents at the appropriate time. In this case,
the SelectionTool will forward the key's for you.



You can also create a common keyhandler to be used by more than one
EditPartViewer, and then 1 or more specific handler customized for each
viewer. User KeyHandler.setNext() to delegate to the common one.
Re: How to delete a figure? [message #9362 is a reply to message #9249] Mon, 10 June 2002 15:04 Go to previous messageGo to next message
Yoav Rubin is currently offline Yoav RubinFriend
Messages: 93
Registered: July 2009
Member
Hi
what is KeyHandler, or GraphicalViewerKeyHandler for that matter. i can\'t
find any reference for it in the documentation of gef.
thanks
yoav

Randy Hudson wrote:

> > menu opens the delete action apears there, but it is disabled. moreover,
> > when i press the DEL key after i select an editpart nothing happends. do

> You shouldn\'t add any key listeners like this. The reason is that you will
> be able to delete an object while it is being dragged. In general,
> everything should be \"locked\" during a drag, such as Undo, Redo, Delete.
No
> menu accelerators function during a drag, so we\'re safe there. But the
> canvas still gets key events.

> To get this for *free*, create a GraphicalViewerKeyHandler for your
> GraphicalViewer. Then, do a:
> sharedKeyHandler.put(
> KeyStroke.getPressed(SWT.DEL, 0),
> getActionRegistry().getAction(DeleteAction.ID));

> KeyHandler\'s will only get KeyEvents at the appropriate time. In this case,
> the SelectionTool will forward the key\'s for you.



> You can also create a common keyhandler to be used by more than one
> EditPartViewer, and then 1 or more specific handler customized for each
> viewer. User KeyHandler.setNext() to delegate to the common one.
Re: How to delete a figure? [message #9409 is a reply to message #9362] Mon, 10 June 2002 17:19 Go to previous message
Eclipse UserFriend
Originally posted by: none.ibm.com

It is new and undocumented.
See its usage in LogicEditor.

"Yoav Rubin" <yoav@il.ibm.com> wrote in message
news:ae2f6e$4ej$1@rogue.oti.com...
> Hi
> what is KeyHandler, or GraphicalViewerKeyHandler for that matter. i can\'t
> find any reference for it in the documentation of gef.
> thanks
> yoav
>
> Randy Hudson wrote:
>
> > > menu opens the delete action apears there, but it is disabled.
moreover,
> > > when i press the DEL key after i select an editpart nothing happends.
do
>
> > You shouldn\'t add any key listeners like this. The reason is that you
will
> > be able to delete an object while it is being dragged. In general,
> > everything should be \"locked\" during a drag, such as Undo, Redo,
Delete.
> No
> > menu accelerators function during a drag, so we\'re safe there. But the
> > canvas still gets key events.
>
> > To get this for *free*, create a GraphicalViewerKeyHandler for your
> > GraphicalViewer. Then, do a:
> > sharedKeyHandler.put(
> > KeyStroke.getPressed(SWT.DEL, 0),
> > getActionRegistry().getAction(DeleteAction.ID));
>
> > KeyHandler\'s will only get KeyEvents at the appropriate time. In this
case,
> > the SelectionTool will forward the key\'s for you.
>
>
>
> > You can also create a common keyhandler to be used by more than one
> > EditPartViewer, and then 1 or more specific handler customized for each
> > viewer. User KeyHandler.setNext() to delegate to the common one.
>
>
>
>
>
Previous Topic:Overview causing a SWTError: No more handles
Next Topic:swt widgets above the editparts
Goto Forum:
  


Current Time: Sun Oct 06 09:26:54 GMT 2024

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

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

Back to the top