{
final Vector actions = def.getActions();
final int count = actions.size();
for( int i = 0; i < count; i++ )
{
final ActionDef actionDef = (ActionDef) actions.elementAt( i );
boolean active;
if( actionDef.getOnlyIf() != null )
{
active = flags.contains( actionDef.getOnlyIf() );
}
else if( actionDef.getUnless() != null )
{
active = !flags.contains( actionDef.getUnless() );
}
else
{
active = actionDef.isActive();
}
final String actionName = actionDef.getName();
final boolean forItem = actionDef.getFor() != null;
final int code = actionDef.getCode();
Command command = Application.getCommandFactory().getCommand( code );
if( command == null )
{
command = new Command(
ResourceManager.getResource( actionDef.getLabel() ),
forItem ?
Command.ITEM :
actionDef.getType() != null ?
actionDef.getType().intValue() :
Command.SCREEN,
actionDef.getOrder() != -1 ?
actionDef.getOrder() :
i + 1
);
}
if( view instanceof DataFormView && forItem )
{
final Item item = ((DataFormView) view).getItem(
actionDef.getFor()
);
final Action action = new Action(
actionName,
command,
code,
item,
actionDef.getDefault() != null &&
actionDef.getDefault().booleanValue()
);
view.addAction( action, active );
}
else
{
view.addAction( new Action(
actionName,
command,
code,
null,
actionDef.getDefault() != null &&
actionDef.getDefault().booleanValue()
), active );
}
}
}