diff --git a/src/main/java/GUI/Agenda/Agenda.java b/src/main/java/GUI/Agenda/Agenda.java index f5e169a..067b4ee 100644 --- a/src/main/java/GUI/Agenda/Agenda.java +++ b/src/main/java/GUI/Agenda/Agenda.java @@ -166,13 +166,10 @@ public class Agenda extends JPanel { } private void updateMovies() { - try { ArrayList projections = Projection.getAvailable(competition); for (Projection projection : projections) { addMovie(projection); } - } catch (Exception e) { - } } public void openDialog(ProjectionType projectionType) { diff --git a/src/main/java/GUI/GUI.form b/src/main/java/GUI/GUI.form index 92ce595..82b91d8 100644 --- a/src/main/java/GUI/GUI.form +++ b/src/main/java/GUI/GUI.form @@ -77,8 +77,7 @@ - - + diff --git a/src/main/java/GUI/GUI.java b/src/main/java/GUI/GUI.java index 0d4718b..052139b 100644 --- a/src/main/java/GUI/GUI.java +++ b/src/main/java/GUI/GUI.java @@ -8,9 +8,8 @@ import GUI.Theme.PrimaryContainedButtonUI; import GUI.Types.ProjectionType; import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.ArrayList; +import java.util.HashMap; public class GUI extends JFrame { private JPanel mainPanel; @@ -29,11 +28,17 @@ public class GUI extends JFrame { private int currentPage; private Agenda agenda; private ArrayList slots = new ArrayList(); - private Competition currentCompetition = new Competition("Long Métrage"); + private Competition currentCompetition; + private HashMap competitionButtons = new HashMap(); - public GUI() throws NotFoundInTable { + public GUI() { super(); - construct(); + try { + this.currentCompetition = new Competition("Court Métrage"); + construct(); + } catch (Exception e) { + JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } } private void renderMenu() { @@ -43,7 +48,7 @@ public class GUI extends JFrame { setJMenuBar(menuBar); } - private void construct() { + private void construct() throws NotFoundInTable { this.currentPage = 1; setTitle("Projection Planning"); setContentPane(mainPanel); @@ -54,8 +59,8 @@ public class GUI extends JFrame { ImageIcon img = new ImageIcon("src/main/java/GUI/Assets/Logo/logo_cannes.jpg"); setIconImage(img.getImage()); this.renderMenu(); - - agenda = new Agenda(agendaPanel, this.currentPage, this.currentCompetition); + competitionButton(); + switchAgenda(currentCompetition); previousButton.addActionListener(e -> nextPreviousPage(false)); nextButton.addActionListener(e -> nextPreviousPage(true)); menuItemAddProj.addActionListener(e -> agenda.openDialog(ProjectionType.ADD)); @@ -64,12 +69,12 @@ public class GUI extends JFrame { } private void competitionButton() { - competitionButtonPanel = new JPanel(); for (Competition competition : Competition.getAll()) { JButton button = new JButton(competition.getName()); button.setUI(new PrimaryContainedButtonUI()); button.addActionListener(actionEvent -> switchAgenda(competition)); competitionButtonPanel.add(button); + competitionButtons.put(competition.getName(), button); } } @@ -85,6 +90,8 @@ public class GUI extends JFrame { } private void switchAgenda(Competition competition) { + competitionButtons.get(currentCompetition.getName()).setEnabled(true); + competitionButtons.get(competition.getName()).setEnabled(false); currentCompetition = competition; agenda = new Agenda(agendaPanel, 0, currentCompetition); repaint(); @@ -92,7 +99,6 @@ public class GUI extends JFrame { } private void createUIComponents() { - competitionButton(); nextButton = new JButton(); nextButton.setUI(new PrimaryContainedButtonUI()); previousButton = new JButton(); diff --git a/src/main/java/GUI/Types/CompetType.java b/src/main/java/GUI/Types/CompetType.java index 12567e0..1c40825 100644 --- a/src/main/java/GUI/Types/CompetType.java +++ b/src/main/java/GUI/Types/CompetType.java @@ -16,13 +16,8 @@ public enum CompetType { this.competition = competition; } - public ArrayList getSlots() { - try { - return Slot.getAll(new Competition(competition)); - } catch (NotFoundInTable notFoundInTable) { - notFoundInTable.printStackTrace(); - } - return null; + public ArrayList getSlots() throws NotFoundInTable { + return Slot.getAll(new Competition(competition)); } public String getCompetition() {