@Override
protected void fillMenu(Menu menu) {
logger.debug("fill menu: " + menu);
ActionContributionItem item;
item = new ActionContributionItem(createParticipantAction);
item.fill(menu, -1);
// show up to 5 participants who aren't in this campaign already
logger.debug("getting eligible participants");
Participant[] participants = participantManager.getParticipantList();
logger.trace("participants: " + participants);
List<Participant> eligibleParticipants = new Vector<Participant>();
boolean moreEligible = false;
for(Participant p : participants) {
logger.trace("p: " + p);
if(!campaign.getParticipants().contains(p)) {
logger.debug("possibly adding participant to eligible list: " + p);
if(eligibleParticipants.size() >= 5) {
logger.debug("breaking from loop, since list is 5 or more elements already");
moreEligible = true;
break;
}
eligibleParticipants.add(p);
}
}
if(!eligibleParticipants.isEmpty()) {
logger.debug("adding separator");
// add a separator
new Separator().fill(menu, -1);
}
for(Participant ep : eligibleParticipants) {
logger.trace("ep: " + ep);
CampaignSelectParticipantAction action = (CampaignSelectParticipantAction)appContext.getBean(
"campaignSelectParticipantAction", new Object[] {
PlatformUI.getWorkbench().getActiveWorkbenchWindow(), ep, campaign });
item = new ActionContributionItem(action);
item.fill(menu, -1);
}
if(moreEligible) {
logger.info("adding 'add participant' action, since there were more eligible than could be shown");
// add participant action
item = new ActionContributionItem(addParticipantAction);
item.fill(menu, -1);
}
}