@Override
public void widgetSelected(SelectionEvent e) {
Action targetAction = (Action) e.widget.getData();
for (TableItem item : tableItemList) {
Task task = (Task) item.getData();
Action[] actions = task.getActions();
for (int iAction = 0; iAction < actions.length; iAction++) {
Action a = actions[iAction];
if ((a.getType() == targetAction.getType()) && (a.getLocation() == targetAction.getLocation())
&& a.getExplanation().equals(targetAction.getExplanation())) {
task.setCurrentAction(iAction);
break;
}
}
updateTask(item);
}
}
};
Task[] taskList = new Task[tableItemList.length];
for (int i = 0; i < tableItemList.length; i++) {
taskList[i] = (Task) tableItemList[i].getData();
}
Menu m = new Menu(this);
MenuItem mi;
// load initial actions of first task
Action[] possibleActions = taskList[0].getActions().clone();
for (int iTask = 1; iTask < taskList.length; iTask++) {
// invalidate all possible actions we dont find in this actionlist
Action[] actions = taskList[iTask].getActions();
for (int iPosAction = 0; iPosAction < possibleActions.length; iPosAction++) {
Action action = possibleActions[iPosAction];
boolean found = false;
if (action == null) {
continue;
}
// check whether action is also supported by this task
for (Action a : actions) {
if ((a.getType() == action.getType()) && (a.getLocation() == action.getLocation())
&& a.getExplanation().equals(action.getExplanation())) {
// the action exists
found = true;
break;
}
}
if (!found) {
// invalidate action that is not supported by all selected tasks
possibleActions[iPosAction] = null;
}
}
}
Task referenceTask = taskList.length == 1 ? taskList[0] : null;
for (Action action : possibleActions) {
if (action == null) {
continue;
}