}
private static Component[] createMenu(final String menuName, final ObjectAdapter target, final List<ObjectAction> actions, final Context context, final String targetObjectId) {
final List<Component> menuItems = new ArrayList<Component>();
for (int j = 0; j < actions.size(); j++) {
final ObjectAction action = actions.get(j);
final String name = action.getName();
Component menuItem = null;
if (action.getActions().size() > 0) {
final Component[] components = createMenu(name, target, action.getActions(), context, targetObjectId);
menuItem = context.getComponentFactory().createSubmenu(name, components);
} else {
if (!action.isVisible(IsisContext.getAuthenticationSession(), target, where).isAllowed()) {
continue;
}
if (action.getType() == ActionType.USER) {
// carry on, process this action
} else if (action.getType() == ActionType.EXPLORATION) {
final boolean isExploring = IsisContext.getDeploymentType().isExploring();
if (isExploring) {
// carry on, process this action
} else {
// ignore this action, skip onto next
continue;
}
} else if (action.getType() == ActionType.PROTOTYPE) {
final boolean isPrototyping = IsisContext.getDeploymentType().isPrototyping();
if (isPrototyping) {
// carry on, process this action
} else {
// ignore this action, skip onto next
continue;
}
} else if (action.getType() == ActionType.DEBUG) {
// TODO: show if debug "gesture" present
} else {
// ignore this action, skip onto next
continue;
}
final String actionId = context.mapAction(action);
boolean collectParameters;
if (action.getParameterCount() == 0) {
collectParameters = false;
// TODO use new promptForParameters method instead of all
// this
} else if (action.getParameterCount() == 1 && action.isContributed() && target.getSpecification().isOfType(action.getParameters().get(0).getSpecification())) {
collectParameters = false;
} else {
collectParameters = true;
}
final Consent consent = action.isUsable(IsisContext.getAuthenticationSession(), target, where);
final String consentReason = consent.getReason();
menuItem = context.getComponentFactory().createMenuItem(actionId, action.getName(), action.getDescription(), consentReason, action.getType(), collectParameters, targetObjectId);
}
if (menuItem != null) {
menuItems.add(menuItem);
}
}