Color menuBkColor, Color menuTextColor,
Font menuFont ) throws ClassNotFoundException, InstantiationException, IllegalAccessException
{
int numMenuItems = childNode.getChildren().size();
for ( int j = 0; j < numMenuItems; j++ ) {
XmlElement itemNode = ( XmlElement )childNode.elementAt( j );
if ( itemNode.getName().equalsIgnoreCase( "Menu" )) {
addMenu( menu, itemNode,
basePackageName, menuStyle,
menuBkColor, menuTextColor,
menuFont );
}
else {
String menuText = itemNode.getAttribute( "content" );
if ( menuText != null ) {
Object menuItem = null;
if ( adapter.requiresParent()) {
Object[] args = new Object[ 1 ];
args[ 0 ] = menu;
menuItem = ReflectionHelper.constructViaReflection( basePackageName + XPage.MENUITEM, args );
}
else {
menuItem = Class.forName( basePackageName + XPage.MENUITEM ).newInstance();
}
if ( menuStyle != null ) {
adapter.setBackground( menuItem, menuBkColor );
adapter.setForeground( menuItem, menuTextColor );
adapter.setFont( menuItem, menuFont );
}
((XTextHolder)menuItem).setText( componentFactory.translate( menuText ));
if ( menuItem instanceof XAttributedComponent ) {
// Should these values be translated?
((XAttributedComponent)menuItem).setAttribute( "image", componentFactory.translate( itemNode.getAttribute( "image" )));
((XAttributedComponent)menuItem).setAttribute( "name", componentFactory.translate( itemNode.getAttribute( "name" )));
}
menu.append( menuItem, itemNode.getAttribute( "name" ) );
String attribStr = itemNode.getAttribute( "enabled" );
if (( attribStr != null ) && attribStr.equals( "false" ))
adapter.setEnabled( menuItem, false );
attribStr = itemNode.getAttribute( "visible" );
if (( attribStr != null ) && attribStr.equals( "false" ))
adapter.setVisible( menuItem, false );
}
else
menu.addSeparator();