Keymaps for project-specific actions

I'm hoping someone can help shed some light on a problem I'm having.
Basically, i have some project-specific actions (the actions that toggle a
Workspace open/closed, etc.) that I'd like to be able to assign keymappings
to--pretty much the same idea as keymappings for Ant Targets, but in my case
the actions are project-specific instead of build-file specific.

What I don't know how to do is to (properly) get the actions to appear in
the Keymaps dialog. I've attached a build with the plugin jar and source to
show how I'm doing it right now. Here's the deal...

My Workspaces menu has a DefaultActionGroup (it's actually a
com.chrisbartley.idea.actions.MutableActionGroup, if anyone cares) that
contains actions that open/close workspaces. The whose MutableActionGroup's
update() method does the following:

  • Removes all current actions in the group

  • Gets a new list of actions to put in the group

  • Adds the new actions to the group

  • Enables/disables the action's presentation appropriately


That works fine for displaying the actions in the Workspaces menu. When you
open the menu, the update() method of the MutableActionGroup containing all
the actions (which toggle a Workspace open/closed) gets fired, and the
appropriate actions get put in the group. Works fine for multiple projects,
too.

But! The problem is when I try to view them in the Keymaps dialog. I guess
I assumed that the update() method would get called in the Keymaps dialog
too, but it apparently doesn't. So, the actions in the group only show up
if you've previously opened the Workspaces menu. That is, if you fire up
IDEA with the Workspaces plugin installed (and you have some workspaces
defined) and open the Keymaps dialog (before having opened the Workspaces
menu), the actions that open/close workspaces don't appear under All
Actions --> Main Menu --> Workspaces. If you close the Keymaps dialog, open
the Workspaces menu and then reopen the Keymaps dialog, the actions are now
visible.

Similarly, if you have two projects open, the appropriate workspace actions
only appear if you open the Workspaces menu prior to opening the Keymaps
dialog. Bummer.

So, how is this problem solved for the Ant Target actions? I don't know of
a way to determine the currently active project, so what magic is being
performed to get the appropriate Ant Targets to appear in the Keymaps
dialog?

thanks tons,

chris





Attachment(s):
Workspaces-0.9.1.zip

Please sign in to leave a comment.