Deleting a connection [message #188639] |
Thu, 21 July 2005 16:12  |
Eclipse User |
|
|
|
Originally posted by: cleversons.gmail.com
Hi,
I'm trying to provide a connection removal functionality where the user
selects a connection and presses the delete key to delete it. I've
installed a ConnectionEditPolicy on my ConnectionEditPart which creates a
ConnectionDeleteCommand command. But how to link the delete key press
action to the creation of a ConnectionDeleteCommand?
Thank you
Cleverson Schmidt
|
|
|
|
|
|
|
|
|
|
|
|
Re: Deleting a connection [message #188875 is a reply to message #188852] |
Fri, 22 July 2005 15:47   |
Eclipse User |
|
|
|
Originally posted by: none.unknown.com
Okay, last guess (running out of ideas now). You must be doing something
that's preventing the workbench from handling the delete key. Maybe you're
handling the delete key in your keyhandler? Set a breakpoint in
DomainEventDispatcher#handleKeyPressed(). When that method enters,
event.doit will be true. When that method exits, event.doit should still be
true. If it is false, then that's the problem. Somebody handled the delete
key and workbench will perform no action. Just step into the code to see
where it's being handled.
"Cleverson Schmidt" <cleversons@gmail.com> wrote in message
news:48d40ec9ee8d4b850d23db38be7347ea$1@www.eclipse.org...
> Thank you again Pratik
>
> > Your ActionBarContributor is registered as the contributor class in the
> > plugin.xml?
>
> Yes it is.
>
> > If you're overriding createActions() or getAdapter() in your
> > editor, make sure you're invoking the super methods.
>
> I'm sure I am invoking the super methods.
>
> > When you select the
> > connection, see if the delete action is enabled in the edit menu. If
not,
> > your editor your editor might not be notifying the workbench of
selection
> > changes properly.
>
> When I select the connection, the delete action is enabled on the
> application menu.
>
> > Ensure that GraphicalEditor#hookGraphicalViewer is being
> > invoked.
>
> I could not find any reference to a hookGraphicalViewer in my source code.
> So, I put a call to hookGraphicalViewer in the end of
> configureGraphicalViewer() but it didn't work. I can even delete my
> connection using the delete menu, but not by pressing the delete key.
>
> Realy intrigant :(
> Any other clue?
>
> Thanks once again
>
|
|
|
|
|
|
Re: Deleting a connection [message #189049 is a reply to message #189016] |
Mon, 25 July 2005 11:41  |
Eclipse User |
|
|
|
Originally posted by: none.unknown.com
"Cleverson Schmidt" <cleversons@gmail.com> wrote in message
news:06856d9e9496e3819cd4c88457865920$1@www.eclipse.org...
> Aleluia!! It works now!!
> After scanning the source code of all examples (Flow, Logic and Shapes)
> looking for differences in how the delete key press is handled I've
> finnaly found a solution.
> In my application I was setting the KeyHandler as shown below:
>
> viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
>
> The Flow example does it slightly different:
>
> viewer.setKeyHandler(new
> GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHand ler()));
>
> I've just adapted the getCommonKeyHandler implementation as follows:
>
> protected KeyHandler getCommonKeyHandler() {
> if (sharedKeyHandler == null) {
> sharedKeyHandler = new KeyHandler();
> sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
> getActionRegistry().getAction(
> ActionFactory.DELETE.getId()));
> }
> return sharedKeyHandler;
> }
>
> Works like magic. I've got to confess I still don't know why exactly we
> have to do that. But it is ok.
You don't have to do that. The flow example's just old and a little out of
date when it comes to such things. If you want to find out why your example
was not working the way the logic example does, try what I suggested in my
last post.
>
> Thank you very much Pratik and Randy. Your help on this forum is simply
> great!
>
> Best Regards
> Cleverson Schmidt
>
|
|
|
Powered by
FUDForum. Page generated in 0.04408 seconds