String pageName = activePage != null ? activePage.getName() : null;
// Create and add the menu bar
JMenuBar mb = new JMenuBar();
JaspiraAction root = ActionMgr.getInstance().getAction(JaspiraAction.MENU_ROOT);
if (root.getMenuchildren() != null)
{
for (Iterator it = root.getMenuchildren().iterator(); it.hasNext();)
{
JaspiraAction action = (JaspiraAction) it.next();
if (action.matchesPageName(pageName))
{
JMenuItem menuItem = action.toMenuItem(pageName);
if (menuItem != null)
{
mb.add(menuItem);
}
}
}
}
setJMenuBar(mb);
// Clear and populate the toolbar
toolbar.removeAll();
root = ActionMgr.getInstance().getAction(JaspiraAction.TOOLBAR_ROOT);
if (root.getToolbarchildren() != null)
{
for (Iterator it = root.getToolbarchildren().iterator(); it.hasNext();)
{
JaspiraAction action = (JaspiraAction) it.next();
if (action.matchesPageName(pageName))
{
JComponent toolbarComponent = action.toToolBarComponent(pageName);
if (toolbarComponent != null)
{
toolbar.add(toolbarComponent);
toolbar.addSeparator();
}