1
0
Fork 0

Notice in which competition we are and eventually call an error dialog when there is an exception but it doesn't work for some case infortunaly so todo: handle more case of this

This commit is contained in:
Tergel TSAGAAN 2021-01-15 18:10:11 +01:00 committed by flifloo
parent 19344bd9d5
commit 6f94624e89
4 changed files with 19 additions and 22 deletions

View file

@ -166,13 +166,10 @@ public class Agenda extends JPanel {
} }
private void updateMovies() { private void updateMovies() {
try {
ArrayList<Projection> projections = Projection.getAvailable(competition); ArrayList<Projection> projections = Projection.getAvailable(competition);
for (Projection projection : projections) { for (Projection projection : projections) {
addMovie(projection); addMovie(projection);
} }
} catch (Exception e) {
}
} }
public void openDialog(ProjectionType projectionType) { public void openDialog(ProjectionType projectionType) {

View file

@ -77,8 +77,7 @@
<properties/> <properties/>
<border type="none"/> <border type="none"/>
<children> <children>
<grid id="b1c37" binding="competitionButtonPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="b1c37" binding="competitionButtonPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
<margin top="25" left="50" bottom="0" right="0"/>
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="284" height="61"/> <preferred-size width="284" height="61"/>

View file

@ -8,9 +8,8 @@ import GUI.Theme.PrimaryContainedButtonUI;
import GUI.Types.ProjectionType; import GUI.Types.ProjectionType;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
public class GUI extends JFrame { public class GUI extends JFrame {
private JPanel mainPanel; private JPanel mainPanel;
@ -29,11 +28,17 @@ public class GUI extends JFrame {
private int currentPage; private int currentPage;
private Agenda agenda; private Agenda agenda;
private ArrayList<Slot> slots = new ArrayList<Slot>(); private ArrayList<Slot> slots = new ArrayList<Slot>();
private Competition currentCompetition = new Competition("Long Métrage"); private Competition currentCompetition;
private HashMap<String, JButton> competitionButtons = new HashMap<String, JButton>();
public GUI() throws NotFoundInTable { public GUI() {
super(); 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() { private void renderMenu() {
@ -43,7 +48,7 @@ public class GUI extends JFrame {
setJMenuBar(menuBar); setJMenuBar(menuBar);
} }
private void construct() { private void construct() throws NotFoundInTable {
this.currentPage = 1; this.currentPage = 1;
setTitle("Projection Planning"); setTitle("Projection Planning");
setContentPane(mainPanel); setContentPane(mainPanel);
@ -54,8 +59,8 @@ public class GUI extends JFrame {
ImageIcon img = new ImageIcon("src/main/java/GUI/Assets/Logo/logo_cannes.jpg"); ImageIcon img = new ImageIcon("src/main/java/GUI/Assets/Logo/logo_cannes.jpg");
setIconImage(img.getImage()); setIconImage(img.getImage());
this.renderMenu(); this.renderMenu();
competitionButton();
agenda = new Agenda(agendaPanel, this.currentPage, this.currentCompetition); switchAgenda(currentCompetition);
previousButton.addActionListener(e -> nextPreviousPage(false)); previousButton.addActionListener(e -> nextPreviousPage(false));
nextButton.addActionListener(e -> nextPreviousPage(true)); nextButton.addActionListener(e -> nextPreviousPage(true));
menuItemAddProj.addActionListener(e -> agenda.openDialog(ProjectionType.ADD)); menuItemAddProj.addActionListener(e -> agenda.openDialog(ProjectionType.ADD));
@ -64,12 +69,12 @@ public class GUI extends JFrame {
} }
private void competitionButton() { private void competitionButton() {
competitionButtonPanel = new JPanel();
for (Competition competition : Competition.getAll()) { for (Competition competition : Competition.getAll()) {
JButton button = new JButton(competition.getName()); JButton button = new JButton(competition.getName());
button.setUI(new PrimaryContainedButtonUI()); button.setUI(new PrimaryContainedButtonUI());
button.addActionListener(actionEvent -> switchAgenda(competition)); button.addActionListener(actionEvent -> switchAgenda(competition));
competitionButtonPanel.add(button); competitionButtonPanel.add(button);
competitionButtons.put(competition.getName(), button);
} }
} }
@ -85,6 +90,8 @@ public class GUI extends JFrame {
} }
private void switchAgenda(Competition competition) { private void switchAgenda(Competition competition) {
competitionButtons.get(currentCompetition.getName()).setEnabled(true);
competitionButtons.get(competition.getName()).setEnabled(false);
currentCompetition = competition; currentCompetition = competition;
agenda = new Agenda(agendaPanel, 0, currentCompetition); agenda = new Agenda(agendaPanel, 0, currentCompetition);
repaint(); repaint();
@ -92,7 +99,6 @@ public class GUI extends JFrame {
} }
private void createUIComponents() { private void createUIComponents() {
competitionButton();
nextButton = new JButton(); nextButton = new JButton();
nextButton.setUI(new PrimaryContainedButtonUI()); nextButton.setUI(new PrimaryContainedButtonUI());
previousButton = new JButton(); previousButton = new JButton();

View file

@ -16,13 +16,8 @@ public enum CompetType {
this.competition = competition; this.competition = competition;
} }
public ArrayList<Slot> getSlots() { public ArrayList<Slot> getSlots() throws NotFoundInTable {
try { return Slot.getAll(new Competition(competition));
return Slot.getAll(new Competition(competition));
} catch (NotFoundInTable notFoundInTable) {
notFoundInTable.printStackTrace();
}
return null;
} }
public String getCompetition() { public String getCompetition() {