Changing the Spoon shortcut keys

by Andrew Cave
April 4, 2017
As a programmer (and the lonely Windows hold-out at Bizcubed), I have a strong habit of hitting ctrl+s to save whatever I am working on, early and often.  As a wobbly typist, I also have a tendency to sometimes clip the wrong key.  So what’s next to the ‘S’?   The ‘D’ key.  And what does ctrl+d do in Spoon in versions 5 and 6?  Close the repository immediately without saving your work and losing all your context.  ┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻

So how to fix this behaviour?  In Pentaho, it’s as simple as changing an entry in a file.

In the Spoon home directory there is a folder called “ui” (User Interface) and in there is a file called “menubar.xul”.

Open the file up in your favourite text editor (Notepad++ for me, but others swear by Atom) and you’ll see a whole bunch of XML (eXtensible Markup Language) which has the configuration settings for…the menu-bar.   Search for ‘ctrl-d’ (or the Mac equivalent) and you’ll be brought to the following text:

<menuitem id="repository-disconnect" acceltext="CTRL-D" accesskey="ctrl-d" disabled="true"
 label="${Spoon.Menu.Repository.DisconnectRepository}" command="spoon.closeRepository()" />

It’s pretty easy to guess what’s going on here.  The command equals “spoon.closeRepository”  string tells us that we’ve come to the right spot.  So all we need to do is to change something.  But first (because we always like to be able to undo mistakes), let’s copy the line we want to change and comment  the copy out.  In Notepad++ the shortcut to duplicate the current line is “ctrl-d” somewhat ironically.

Now to comment out things in XML (or its subset HTML), we type in <!-- to start the comment and --> to end it.  Applying that we have:

 <!-- <menuitem id="repository-disconnect" acceltext="CTRL-D" accesskey="ctrl-d" disabled="true" -->
 <menuitem id="repository-disconnect" acceltext="CTRL-D" accesskey="ctrl-d" disabled="true"
 label="${Spoon.Menu.Repository.DisconnectRepository}" command="spoon.closeRepository()" />

If we want to revert, we remove the middle line, uncomment the first line, save the file, and we’re back where we were.

Next, we’ll change the the entries CTRL-D and ctrl-d and by replacing the ‘D’ with ‘Q’ (Q is for Quit).  So now we have this:

 <!-- <menuitem id="repository-disconnect" acceltext="CTRL-D" accesskey="ctrl-d" disabled="true" -->
 <menuitem id="repository-disconnect" acceltext="CTRL-Q" accesskey="ctrl-q" disabled="true"
 label="${Spoon.Menu.Repository.DisconnectRepository}" command="spoon.closeRepository()" />

So save the file, restart Spoon and now the short-cut has been changed

(。◕‿◕。)


Of course, if you are using Pentaho 7, the repository connect/disconnect has been moved to the top-right corner.  But if you aren’t there yet, take the opportunity to protect your work – and feel free to try other changes.  You can always go back.

More blog posts