Tuesday, April 7, 2009

How to add a shortcut binding to JGrass

Alright, I wanted to be able to open the console editor by shortcut.
Here the steps to to achieve it.

1) create a command. Use the org.eclipse.ui.commands extention point to do so.

2) create a category for your new command(s) if you do not have one already. Rightclick on the extention point of point 1) , choose new and then category.

3) create a new command by rightclicking on the extention point as in point 2).

4) fill in some basic info, as name, description, category and a unique id for the command.

It should look like the following:


keep in mind the green part, we will need it later.

5) create an actionset with your action in it. Use the org.eclipse.ui.actionSets extention point.

Filling in the basic stuff will lead to the following:


Note that the blue part is the class that will actually exacute the action.

Instead the green part is the id of the command created before. The command will be the link to the shortcut binding, which we will create now.

6) create the shortcut throught the org.eclipse.ui.bindings extention point.

That would look like:



Only two things to note here:
  1. commandid, which is again the id of the command created in 1)
  2. the shortcut definition in sequence: ESC M1+E which results in a vi-like shortcut: first press ESC and then ALT-E

That should be all I think.

No comments: