diff --git a/src/main/java/GUI/ProjectionHandler.java b/src/main/java/GUI/ProjectionHandler.java index 680dd4a..728225c 100644 --- a/src/main/java/GUI/ProjectionHandler.java +++ b/src/main/java/GUI/ProjectionHandler.java @@ -111,7 +111,7 @@ public class ProjectionHandler extends JDialog { Competition competition = (Competition) competitionComboBox.getSelectedItem(); Set dates = competition.getProjections().stream().map(p -> p.getStartDate()).collect(Collectors.toSet()); LocalDate[] localDates = LocalDate.of(2021, 5, 11).datesUntil(LocalDate.of(2021, 5, 22)).toArray(LocalDate[]::new); - if (competition.getDays() != 0 && dates.size() >= competition.getDays()) + if (competition.getDays() != 0 && dates.size() >= competition.getDays() && !(projectionType == ProjectionType.EDIT && projection.getCompetition().getName().equals(competition.getName()))) localDates = dates.stream().map(Date::toLocalDate).toArray(LocalDate[]::new); for (LocalDate date : localDates) @@ -125,10 +125,10 @@ public class ProjectionHandler extends JDialog { ArrayList slots; Competition competition = (Competition) competitionComboBox.getSelectedItem(); Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem()); - if (projectionType == ProjectionType.ADD) - slots = Slot.getAvailable(competition, date); + if (projectionType == ProjectionType.REMOVE) + slots = Slot.getAll(competition, date); else - slots = Slot.getAll(competition, date); + slots = Slot.getAvailable(competition, date); if (slots != null) for (Slot s : slots) slotComboBox.addItem(s); @@ -138,18 +138,14 @@ public class ProjectionHandler extends JDialog { private void updateRooms() { roomComboBox.removeAllItems(); if (dayComboBox.getSelectedItem() != null) { - ArrayList rooms = null; + ArrayList rooms; Movie movie = (Movie) filmComboBox.getSelectedItem(); Slot slot = (Slot) slotComboBox.getSelectedItem(); Date date = Date.valueOf((LocalDate) dayComboBox.getSelectedItem()); - switch (projectionType) { - case ADD: - case EDIT: - rooms = Room.getAvailable(movie, slot, date); - break; - case REMOVE: - rooms = Room.getAll(movie, slot, date); - } + if (projectionType == ProjectionType.REMOVE) + rooms = Room.getAll(movie, slot, date); + else + rooms = Room.getAvailable(movie, slot, date); if (rooms != null) for (Room r : rooms) roomComboBox.addItem(r);