Dockable actions

Hello,

Sorry for a stupid question, but I was unable to find an answer…

Is there any simple way to duplicate minimize and normalize actions in an application menu? I am using the core library and SplitDockStation.

Thank you,

Alex

Not certain how your “minimize” action looks like, since the core library does not offer such an action. But for maximize/normalize you would just have to call “SplitDockStation.setFullscreenDockable”.

A more elaborate approach would be to let the framework automatically generate the menus. This is not that easy, but it is possible. You would need to:

  • track the currently focused Dockable, you can add a DockableFocusListener to the DockController to do that.
  • access the action-source of the focused Dockable (Dockable.getGlobalActionOffers()), and pack that source into a SimpleMenuAction.
  • (if you only want to show a subset of actions, wrap the action-source into a “FilteredDockActionSource”)
  • access the ActionViewConverter, see DockController.getActionViewConverter…
  • … and call “createView” with your new menu action, the focused dockable, and ViewTarget.MENU
  • you receive a “ViewItem” that wrapps around a JComponent, add this Component to your menu-bar. To install the menu you finally need to call “ViewItem.bind”, and if you no longer use it you can call “ViewItem.unbind” to release resources. Don’t forget to unbind the menu, otherwise you create a big memory leak.

Beni, thank you! This is exactly what I need!