@Override public void execute() { HashMap<Key<GroupDTO>, GroupDTO> invites = VeggieDinner.getGroups(me.getGroups()); myInvites = new MenuBar(true); myStuff.addItem("My Invites", myInvites); for (GroupDTO g : invites.values()) { final GroupDTO finalGroup = g; String hostsString = "Me"; for (UserDTO u : VeggieDinner.getUsers(g.getHosts()).values()) if (!u.getKey().equals(me.getKey())) hostsString += ", " + u.getUserName(); myInvites.addItem( hostsString, new Command() { @Override public void execute() { VeggieDinner.showGroup(finalGroup.getKey()); } }); } }
@Override public void execute() { final GroupDTO g = VeggieDinner.getGroup(me.getSelectedGroup()); myStuff.addItem( "My Group", new Command() { @Override public void execute() { VeggieDinner.showGroup(g.getKey()); } }); Collection<Key<EventDTO>> events = g.getEvents(); if (events.size() == 1) { final Key<EventDTO> e = g.getEvent(0); myStuff.addItem( "My Event", new Command() { @Override public void execute() { VeggieDinner.showEvent(e); } }); } else if (events.size() > 1) { MenuBar myEvents = new MenuBar(true); myStuff.addItem("My Events", myEvents); for (int i = 0; i < events.size(); i++) { final Key<EventDTO> e = g.getEvent(i); // TODO add the schedule to the group and populate the date // here as well myEvents.addItem( "Event #" + e.getId(), new Command() { @Override public void execute() { VeggieDinner.showEvent(e); } }); } } }
private HashSet<Key<EventDTO>> getEventsFromGroups(Collection<GroupDTO> groups) { HashSet<Key<EventDTO>> events = new HashSet<Key<EventDTO>>(); if (groups == null) return events; for (GroupDTO g : groups) events.addAll(g.getEvents()); return events; }
private HashSet<Key<UserDTO>> getHostsFromGroups(Collection<GroupDTO> groups) { HashSet<Key<UserDTO>> hosts = new HashSet<Key<UserDTO>>(); if (groups == null) return hosts; for (GroupDTO g : groups) hosts.addAll(g.getHosts()); return hosts; }