@SuppressWarnings({"unchecked"})
protected static void addMultiActions(ModelItem[] modelItems, ActionList actions, SoapUIActionGroup actionGroup) {
boolean prevWasSeparator = false;
SoapUIActionMappingList actionMappings = actionGroup.getActionMappings(null);
for (int c = 0; c < actionMappings.size(); c++) {
SoapUIActionMapping mapping = (SoapUIActionMapping) actionMappings.get(c);
if (mapping == null) {
continue;
}
SoapUIAction action = mapping.getAction();
if (action instanceof SeperatorAction) {
if (!prevWasSeparator) {
actions.addAction(ActionSupport.SEPARATOR_ACTION);
}
prevWasSeparator = true;
} else if (action instanceof SoapUIActionGroupAction) {
DefaultActionList subActions = new DefaultActionList(mapping.getName());
SoapUIActionGroup subGroup = ((SoapUIActionGroupAction) action).getActionGroup();
addMultiActions(modelItems, subActions, subGroup);
ActionSupport.ActionListAction actionListAction = new ActionSupport.ActionListAction(subActions);
actions.addAction(actionListAction);
actionListAction.setEnabled(mapping.isEnabled());
prevWasSeparator = false;
} else if (action instanceof SoapUIMultiAction) {
List<ModelItem> targets = new ArrayList<ModelItem>();
for (ModelItem target : modelItems) {
if (action.applies(target)) {
targets.add(target);
}
}
if (targets.size() > 0) {
SwingMultiActionDelegate actionDelegate = new SwingMultiActionDelegate(mapping, modelItems);
actions.addAction(actionDelegate);
if (mapping.isDefault()) {
actions.setDefaultAction(actionDelegate);
}
actionDelegate.setEnabled(mapping.isEnabled());
prevWasSeparator = false;
}
}
}
}