The steps described in this article are only necessary if you want to allow all add-ons to add actions and active settables to your action bar, or if you want to configure a standard Lucy action so that it appears in your action bar.

If you just want to add a tool bar or menu bar to your application which is unrelated to the Lucy action bar mechanism, you can simply use the standard JDK classes, for example JToolBar. There is no need to integrate it with the Lucy action bar mechanism in that situation.

The contents of the action bars in the UI are kept in-sync with the contents of the TLcyActionBarManager. Each time an add-on inserts an action in the TLcyActionBarManager, the action bar in the UI is notified of this change and shows the action.

You can use the same mechanism for your own action bars. It allows you to:

  • Configure your own actions and active settables to appear in your action bar.

  • Configure the standard Lucy actions and active settables to appear in your action bar.

This is possible with the API of the TLcyActionBarManager and ILcyActionBar classes, but Lucy has utility methods for this.

To add an action bar to the UI, and keep it in-sync with the TLcyActionBarManager:

  1. Create an ILcyActionBar implementation. Lucy has default implementations for the most common types of action bars. The TLcyToolBar implementation represents a tool bar, for example, and TLcyMenuBar represents a menu bar.

  2. Use the utility method of the TLcyActionBarUtil class to insert all actions and active settables registered with the action bar manager for this action bar. The use of this utility method also ensures that the action bar remains in-sync with the action bar manager.

    TLcyActionBarManager actionBarManager = lucy.getUserInterfaceManager().getActionBarManager();
    
    //Obtain a parsed version of the configuration file, e.g. by using a TLcyStringPropertiesCodec
    //If using an ALcyPreferencesAddOn, you can use ALcyPreferencesAddOn#getPreferences()
    ALcyProperties configuration = parseConfigurationFile();
    String configurationPrefix = "MyAddOnPrefix.";
    
    TLcyActionBarUtil.setupAsConfiguredActionBar(
        toolBar,
        toolBarName,
        mapComponent,
        configuration,
        configurationPrefix,
        (JComponent) mapComponent.getComponent(),
        actionBarManager
    );

    This utility method requires the full identifier of the action bar, which includes the name as well as the context. In this example, the context is the map component. For a global action bar, the context can be replaced with null.