The new Composite Application Editor in version 6.2.x of Lotus Expeditor facilitates the creation of composite applications which are stored locally as .CA files.
A composite application can be configured so that it is added to the Launcher ('Open') menu of the Expeditor client, by setting the value of com.ibm.rcp.launcher to true in the Application properties:

This results in the composite application being added in a static way to the Launcher menu:

However if we wish to customise the items on the Launcher menu so that menu items are dynamically added according to which user is logged in, we can do this programmatically.
We have seen how these .CA files can be programmatically launched using method showApplication() from the CompositeApplicationUIService. This method is detailed in article: Programmatically show a composite application.
In Lotus Expeditor version 6.2.x, the preferred method for launching a .CA file is to use a CompositeApplicationUIServiceFactory instead to obtain a reference to the service.
As an example, assuming the .CA file is stored locally in directory C:\IBM\XPD\compApps, the following code would launch the .CA file:
CompositeApplicationUIServiceFactory.getService().showApplication
( new URL("FILE:///C:/IBM/XPD/compApps/dynamic_ca.ca")
, null
, null
);
We can get access to the Launcher menu by gettng the LauncherManager instance:
import com.ibm.rcp.ui.launcher.LauncherManager;
private LauncherManager lm = null;
// Get the LauncherManager instance
lm = LauncherManager.getInstance();
Individual items can be removed from the Launcher Manager:
IContributionItem[] itemArray = lm.getItems();
for (int i=0; i<itemArray.length; i++)
{
if (itemArray[i].getId().equals(itemId))
lm.remove(itemArray[i]);
}
Alternatively all items can be removed.
Items can be added to the Launcher menu as required for a particular user.
A new submenu can be added using FolderLauncherContributionItem, or a menu item can be added using a UrlLauncherContributionItem.
UrlLauncherContributionItem uci = null;
FolderLauncherContributionItem fci = null;
fci = new FolderLauncherContributionItem();
fci.setLabel(groupName);
fci.setId(groupId);
lm.add(fci);
uci = new UrlLauncherContributionItem();
uci.setUrl(url);
uci.setLabel(appName);
uci.setId(appId);
uci.setPath(groupName);
uci.setAlwaysLaunchInNewWindow(false);
lm.add(uci);
The update() method must be called to refresh the items on the Launcher menu.
In order to be able to invoke the showApplication() method when a menu item is selected, we need to subclass the ILauncherListener class to provide our own Launcher behaviour. The custom behaviour is added to the preLaunchItem() method:
import com.ibm.rcp.ui.launcher.ILauncherListener;
public class CustomLauncherListener implements IlauncherListener
{
public void postLaunchItem(LauncherEvent event) {
// TODO Auto-generated method stub
}
public void postLaunchItemInNewWindow(LauncherEvent event) {
// TODO Auto-generated method stub
}
public void preLaunchItem(LauncherEvent event) {
// TODO Auto-generated method stub
UrlLauncherContributionItem lci = (UrlLauncherContributionItem) event.getLauncherContributionItem();
final String id = lci.getId();
final String selectedUrl = lci.getUrl();
Activator.getDefault().getWorkbench().getDisplay().asyncExec
(new Runnable()
{
public void run()
{
try
{
CompositeApplicationUIServiceFactory.getService()
.showApplication
( new URL(url)
, null
, null
);
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CompositeApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
public void preLaunchItemInNewWindow(LauncherEvent event) {
// TODO Auto-generated method stub
}
}
We finally need to associate the CustomLauncherListener with the LauncherManager:
CustomLauncherListener myLauncherListener = new CustomLauncherListener();
lm.addLauncherListener(myLauncherListener);
Now when we log in to the Expeditor client, we see the additional items that we added on the Launcher menu:

When we select the dynamic_ca menu item, the composite application is launched using the showApplication() method as described above:
