Patch for SQuirreL SQL Client v3.2.1 - adds keyboard shortcut for SQL Query rerun/re-execution

SQuirreL SQL Client is a really awesome piece of software. It's a universal SQL client written in pure Java, thus it's portable to virtually any platform (at least all major desktop environments -Mac OSX, Windows, Linux- that people use nowadays). It's very compact and it allows you to work with all sorts of databases that have a pure Java JDBC driver available (most DBs do). A small annoyance has been bugging me for quite some time now and today I took the time to make a patch for it (big hurray for open source! Smile ).

SQuirreL does not (yet) have keyboard shortcut customization, thus you're stuck with whatever is built in. Unfortunately not every action has a shortcut assigned to it, thus it's not just that you've to get used to a shortcut that you don't like ... there's no shortcut at all.

One of these actions is the "Rerun" button on the right edge of the result tabs of SQL Worksheets. Of course you can just hit Ctrl+Enter to run the query again, but the results will open in a new tab every time. It doesn't take long this way to pile up a few dozen tabs of the same SQL. Smile Thus rerunning an SQL in the same tab is a pretty basic operation that some people (eg. me Smile) would like to have a shortcut for.

Now a few words on shortcuts (or accelerators as SQuirreL calls them). In SQuirreL (AFAIK, but I could be easily wrong in this) only a menuitem can have a keyboard shortcut. Thus if you want to assign a shortcut to an action, you've to put it in the menu. (Note: I know that this is not true, eg. the undo/redo actions have keyboard shortcuts and they're not available in the menu ... but without having my own action in the menu, it's shortcut wouldn't work. Please, let me know if you've the answer to this.)

With the already existing "Rerun" action there's another problem: it's implementation is an embedded Java class and it's parent is the net.sourceforge.squirrel_sql.client.session.mainpanel.ResultTab class. Now to add an action to the list of global actions, you've to create an instance of it. With the original RerunAction class this would require the creation of a "stale" instance of the ResultTab class too, which would be quite a hack.

To summarize:
  • I created a new action class (net.sourceforge.squirrel_sql.client.session.action.RerunCurrentSQLResultTabAction) with the same functionality (as ResultTab.Rerun)
  • Added this new action to the global action list in net.sourceforge.squirrel_sql.client.action.ActionCollection
  • Added this new action to the menu in net.sourceforge.squirrel_sql.client.gui.mainframe.MainFrameMenuBar
  • Added the proper entries for the new action+menuitem in net/sourceforge/squirrel_sql/client/resources/squirrel.properties
  • As a bonus I've replaced the action in ResultTab with the new action so it'd display the same tooltip string and shortcut combination.
I did not remove the old action from the ResultTab class since I wanted this patch to be as non-invasive as possible.

I've attached both the patch (diff) and the patched squirrel-sql.jar for SQuirreL v3.2.1 (rename the attached squirrel-sql-3.2.1.rerun_shortcut.jar to squirrel-sql.jar after you've downloaded it and place it -overwriting the original- in your SQuirreL program folder).

AttachmentSize
squirrel-sql-source-3.2.1.rerun_shortcut.diff8.85 KB
squirrel-sql-3.2.1.rerun_shortcut.jar1.91 MB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

This is cool!

I was looking for this feature for some time now. Thanks for publishing your effort! You should also see if SQuirrel can take this and make it a regular feature.

Since it is not mentioned in the post, for the benefit of others, the new shortcut to re-run the query in the same result tab is Ctrl + Shift + R

Re: This is cool!

I do not make any promises, but I'll try to find somebody in the SQuirreL dev team to integrate my patch into the main dev. tree.

This is still a problem in v3.4

I have entered a squirrel bug ticket for this issue, hopefully someone will look at it.
https://sourceforge.net/tracker/?func=detail&aid=3582379&group_id=28383&atid=393414

Syndicate content