I'm looking for any suggestions on the best way to manage dynamically
enabling and disabling SWT menu items. The only way I see to do it is to
pass other menu items to the selected menu item's listener and set their
enable state depending on success of the requested action. However, this
means that the menu logic will be sprinkled all over and could easily be a
huge headache to maintain.
I keep one menu, and one context menu. I don't think I want to create new
menus on the fly, just disable the particular items that don't apply for
the user's current situation. For example, File 'Save' and 'Save As'.
'Save' is disabled by default, but once 'Save As' is selected its listener
enables 'Save' (pending successful completion, of course). Then when
'New' is selected its listener disables 'Save'.
My SWT/Batik app has some fairly complex behavior dependencies, and
implementing the simple approach above can result in a highly
decentralized set of enable/disable instructions that will be difficult to
track should the menu system change down the road. There are also places
in code where I need to disable/enable menu items based on what type of
SVG element is selected on an interactive canvas.
Is there a better way to manage the menu logic? Any help would be
appreciated!