Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Mapping from key-codes to Commands?
Mapping from key-codes to Commands? [message #155364] Sun, 24 October 2004 18:26 Go to next message
Andreas Herz is currently offline Andreas HerzFriend
Messages: 196
Registered: July 2009
Senior Member
Hi,

I have a problem to understand the binding between the
key-codes and the generates Commands.

I have implement the DeleteCommand for some graphical GEF
objects, but the execute of the Command will not be called.

I don't understand the binding between key-codes and the Commands.
I can't fixe the bug without the required background.

I have insert the code for the KeyHandler via cut&paste in my Editor:

protected void configureGraphicalViewer()
{
//root editpart:
FreeformGraphicalRootEditPart root = new FreeformGraphicalRootEditPart();
getGraphicalViewer().setRootEditPart(root);
//keyhandler:
KeyHandler keyHandler = new KeyHandler();
keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
getActionRegistry().getAction(GEFActionConstants.DELETE));

getGraphicalViewer().setKeyHandler(new
GraphicalViewerKeyHandler(getGraphicalViewer()).setParent(ke yHandler));
}

MyDeleteCommand will be instantiated if I select the corresponding
GEF object - but if I press the DEL key nothing happens.

I have modified the "rlemaigr.classdiagrameditor.MyEditor". The DEL function of
GEF objects works fine. But I have changed some code and at the moment it is impossible
for me to fixe the error.

I NEED a background articel to understand the Action/Key/Command... handling!!!!!!!


greetings

Andreas
Re: Mapping from key-codes to Commands? [message #155394 is a reply to message #155364] Mon, 25 October 2004 03:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The workbench defines global actions which interfere with normal reception
of KeyDown events. Are you registering global action handlers for delete,
copy, paste?

Which version of Eclipse are you using. In 3.0, a disabled global action
should not intercept the event.

"FreeGroup" <a.herz@FreeGroup.de> wrote in message
news:clgrjb$1lc$1@eclipse.org...
> Hi,
>
> I have a problem to understand the binding between the
> key-codes and the generates Commands.
>
> I have implement the DeleteCommand for some graphical GEF
> objects, but the execute of the Command will not be called.
>
> I don't understand the binding between key-codes and the Commands.
> I can't fixe the bug without the required background.
>
> I have insert the code for the KeyHandler via cut&paste in my Editor:
>
> protected void configureGraphicalViewer()
> {
> //root editpart:
> FreeformGraphicalRootEditPart root = new
FreeformGraphicalRootEditPart();
> getGraphicalViewer().setRootEditPart(root);
> //keyhandler:
> KeyHandler keyHandler = new KeyHandler();
> keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
> getActionRegistry().getAction(GEFActionConstants.DELETE));
>
> getGraphicalViewer().setKeyHandler(new
> GraphicalViewerKeyHandler(getGraphicalViewer()).setParent(ke yHandler));
> }
>
> MyDeleteCommand will be instantiated if I select the corresponding
> GEF object - but if I press the DEL key nothing happens.
>
> I have modified the "rlemaigr.classdiagrameditor.MyEditor". The DEL
function of
> GEF objects works fine. But I have changed some code and at the moment it
is impossible
> for me to fixe the error.
>
> I NEED a background articel to understand the Action/Key/Command...
handling!!!!!!!
>
>
> greetings
>
> Andreas
>
Re: Mapping from key-codes to Commands? [message #155445 is a reply to message #155394] Mon, 25 October 2004 08:25 Go to previous messageGo to next message
Andreas Herz is currently offline Andreas HerzFriend
Messages: 196
Registered: July 2009
Senior Member
Hi,

I use 3.1.0 (build 200408122000)

I think I have registed the GlobalActionHandlers (I hope) with this code.

============================================================ ===============
public void <MyEditor.>createPartControl(Composite parent)
{
super.createPartControl(parent);

getEditorSite().getActionBars().setGlobalActionHandler(IWork benchActionConstants.UNDO,
getActionRegistry().getAction(GEFActionConstants.UNDO));

getEditorSite().getActionBars().setGlobalActionHandler(IWork benchActionConstants.REDO,
getActionRegistry().getAction(GEFActionConstants.REDO));

getEditorSite().getActionBars().setGlobalActionHandler(IWork benchActionConstants.DELETE,
getActionRegistry().getAction(GEFActionConstants.DELETE));
}
============================================================ ===============

UNDO/REDO work fine with all actions/changes I have done with my model.

The delete Action is always disabled in the context menu!


greetings

Andreas




Randy Hudson wrote:

> The workbench defines global actions which interfere with normal reception
> of KeyDown events. Are you registering global action handlers for delete,
> copy, paste?
>
> Which version of Eclipse are you using. In 3.0, a disabled global action
> should not intercept the event.
>
> "FreeGroup" <a.herz@FreeGroup.de> wrote in message
Re: Mapping from key-codes to Commands? [message #155452 is a reply to message #155394] Mon, 25 October 2004 09:58 Go to previous message
Andreas Herz is currently offline Andreas HerzFriend
Messages: 196
Registered: July 2009
Senior Member
Hi,

I have found the code which enables/disables my DEL-Action

If I install the "GroupComponentEditPolicy" for my Group Element
the delete of objects is now disabled.


public void <MyGroupEditPart.>createEditPolicies()
{
super.createEditPolicies();

//installEditPolicy(EditPolicy.COMPONENT_ROLE, new GroupComponentEditPolicy(){});
installEditPolicy(EditPolicy.LAYOUT_ROLE, new XYLayoutEditPolicyGroupImpl());
installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new GroupDirectEditPolicy());
}

Class structure:
----------------

(root element) (group container) (elements in the conainer)
MyFormEditPart -> MyGroupEditPart -> MyGroupElementEditPart



If I don't install the the COMPONENT_ROLE I can't move
the objects in the MyGroupEditPart via DragDrop and I can't select
the element in MyGroupEditPart!


Question: How to handle the parent/child structure with the delete support?



Greetings


Andreas
Previous Topic:How to follow RedBook GEF example
Next Topic:How to add a ConnectionAnchor to the LogicLabe l!!
Goto Forum:
  


Current Time: Tue Apr 23 11:56:59 GMT 2024

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

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

Back to the top