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:
parent
19344bd9d5
commit
6f94624e89
4 changed files with 19 additions and 22 deletions
|
@ -166,13 +166,10 @@ public class Agenda extends JPanel {
|
|||
}
|
||||
|
||||
private void updateMovies() {
|
||||
try {
|
||||
ArrayList<Projection> projections = Projection.getAvailable(competition);
|
||||
for (Projection projection : projections) {
|
||||
addMovie(projection);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void openDialog(ProjectionType projectionType) {
|
||||
|
|
|
@ -77,8 +77,7 @@
|
|||
<properties/>
|
||||
<border type="none"/>
|
||||
<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">
|
||||
<margin top="25" left="50" bottom="0" right="0"/>
|
||||
<grid id="b1c37" binding="competitionButtonPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<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">
|
||||
<preferred-size width="284" height="61"/>
|
||||
|
|
|
@ -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<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();
|
||||
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();
|
||||
|
|
|
@ -16,13 +16,8 @@ public enum CompetType {
|
|||
this.competition = competition;
|
||||
}
|
||||
|
||||
public ArrayList<Slot> getSlots() {
|
||||
try {
|
||||
return Slot.getAll(new Competition(competition));
|
||||
} catch (NotFoundInTable notFoundInTable) {
|
||||
notFoundInTable.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
public ArrayList<Slot> getSlots() throws NotFoundInTable {
|
||||
return Slot.getAll(new Competition(competition));
|
||||
}
|
||||
|
||||
public String getCompetition() {
|
||||
|
|
Reference in a new issue