The available action bar configuration options documentation lists all possible configuration options you can use with the default Lucy actions.
The TLcyActionBarManager allows you to re-use this mechanism for your own actions and active settables:
-
Create your own
ILcdActionorILcyActiveSettableimplementation. -
Add an identifier key-value pair to the action or active settable using the
putValuemethod.ILcdAction action = createAction(); //add identifier String identifier = "MyOpenAction"; action.putValue(TLcyActionBarUtil.ID_KEY, identifier); -
Add the necessary configuration options for that action. In this example, we stick to the required
itemproperty which defines the location.# Configure the location of the action, using the same identifier MyOpenAction.toolBar.item=OpenIn this example, the action is inserted into an action bar with the name
"toolBar". -
Use the
TLcyActionBarUtil.insertInConfiguredActionBarsmethod to register the action.TLcyActionBarManager actionBarManager = aLucyEnv.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(); //When inserting an action, you need to specify the context. Typically this is: //null for global action like for example an action to exit the application //the map component for an action which works on a specific map, like an action to open data Object context = mapComponent; //Insert the action in all configured locations //In case the configuration file contains other settings (shortDescription, smallIcon, ...), //these will be also set on the action TLcyActionBarUtil.insertInConfiguredActionBars(action, context, actionBarManager, configuration);The
TLcyActionBarUtil.insertInConfiguredActionBarsmethod uses the identifier stored in the action (step 2) to find the relevant settings from the configuration. In this example, it will detect that the action must be registered for an action bar with the name"toolBar"(step 3).As explained in The action bar API, the action bar manager uses both a name and a context to identify an action bar. The name is retrieved from the configuration file. The context is passed to the
TLcyActionBarUtil.insertInConfiguredActionBarsmethod as a parameter. In this example, the context is themapComponentvariable.This means that only the name part of the action bar identifier is configurable, and not the context. This makes sense as the action is written for a specific context.
|
If you want to insert your action in a specific, hard-coded location, there is no need to use the configuration file and the
|