Update row header text to slot times
Fix movie that appear in wrong slot
This commit is contained in:
parent
c6a7f697b9
commit
45c7e62bd8
4 changed files with 41 additions and 19 deletions
|
@ -66,6 +66,20 @@ public class Slot extends Table {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public ArrayList<Slot> getAll(Competition competition) {
|
||||||
|
ArrayList<Slot> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT id FROM Slot WHERE CompetitionName = ?");
|
||||||
|
ps.setString(1, competition.getName());
|
||||||
|
for (ResultSet rs = ps.executeQuery(); rs.next(); )
|
||||||
|
list.add(new Slot(rs.getInt("id")));
|
||||||
|
ps.close();
|
||||||
|
} catch (SQLException | NullPointerException | NotFoundInTable e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
static public ArrayList<Slot> getAll(Competition competition, Date date) {
|
static public ArrayList<Slot> getAll(Competition competition, Date date) {
|
||||||
ArrayList<Slot> list = new ArrayList<>();
|
ArrayList<Slot> list = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package GUI.Agenda;
|
||||||
|
|
||||||
import DB.Competition;
|
import DB.Competition;
|
||||||
import DB.Projection;
|
import DB.Projection;
|
||||||
|
import DB.Slot;
|
||||||
import Exceptions.ProjectionNotSpecified;
|
import Exceptions.ProjectionNotSpecified;
|
||||||
import GUI.ProjectionHandler;
|
import GUI.ProjectionHandler;
|
||||||
import GUI.Types.CompetType;
|
import GUI.Types.CompetType;
|
||||||
|
@ -19,16 +20,17 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public class Agenda extends JPanel {
|
public class Agenda extends JPanel {
|
||||||
private JPanel agendaPanel;
|
private JPanel agendaPanel;
|
||||||
private String headers[];
|
private Object headers[];
|
||||||
private int totalDay;
|
private int totalDay;
|
||||||
private int currentPage;
|
private int currentPage;
|
||||||
private JTable table;
|
private JTable table;
|
||||||
private CompetType competionType;
|
private CompetType competionType;
|
||||||
private Agenda agenda;
|
private Agenda agenda;
|
||||||
|
private ArrayList<Slot> slots;
|
||||||
public Agenda(JPanel agendaPanel, int currentPage, CompetType competionType) {
|
public Agenda(JPanel agendaPanel, int currentPage, CompetType competionType) {
|
||||||
this.agendaPanel = agendaPanel;
|
this.agendaPanel = agendaPanel;
|
||||||
this.headers = competionType.getHeaders();
|
this.slots = competionType.getSlots();
|
||||||
|
this.headers = slots.toArray();
|
||||||
this.totalDay = 11;
|
this.totalDay = 11;
|
||||||
this.currentPage = currentPage;
|
this.currentPage = currentPage;
|
||||||
this.competionType = competionType;
|
this.competionType = competionType;
|
||||||
|
@ -178,12 +180,10 @@ public class Agenda extends JPanel {
|
||||||
private void addMovie(Projection projection) {
|
private void addMovie(Projection projection) {
|
||||||
Date startDate = projection.getStartDate();
|
Date startDate = projection.getStartDate();
|
||||||
Time time = projection.getSlot().getStartTime();
|
Time time = projection.getSlot().getStartTime();
|
||||||
String movieName = projection.getMovie().getName();
|
|
||||||
int column = this.table.getColumn(startDate.toString()).getModelIndex();
|
int column = this.table.getColumn(startDate.toString()).getModelIndex();
|
||||||
int row = 0;
|
int row = 0;
|
||||||
String times[] = {"08:30:00", "11:30:00", "15:00:00", "18:00:00", "21:00:00"};
|
for (int i = 0; i < slots.size(); i++) {
|
||||||
for (int i = 0; i < times.length; i++) {
|
if (slots.get(i).getStartTime().toString().equals(time.toString())) {
|
||||||
if (times[i].equals(time.toString())) {
|
|
||||||
row = i;
|
row = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package GUI;
|
package GUI;
|
||||||
|
|
||||||
|
import DB.Slot;
|
||||||
import GUI.Agenda.Agenda;
|
import GUI.Agenda.Agenda;
|
||||||
import GUI.Types.CompetType;
|
import GUI.Types.CompetType;
|
||||||
import GUI.Types.ProjectionType;
|
import GUI.Types.ProjectionType;
|
||||||
|
@ -7,6 +8,7 @@ import GUI.Types.ProjectionType;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class GUI extends JFrame implements ActionListener {
|
public class GUI extends JFrame implements ActionListener {
|
||||||
private JPanel mainPanel;
|
private JPanel mainPanel;
|
||||||
|
@ -23,7 +25,7 @@ public class GUI extends JFrame implements ActionListener {
|
||||||
private JMenuItem menuItemRemoveProj = new JMenuItem("Remove projection");
|
private JMenuItem menuItemRemoveProj = new JMenuItem("Remove projection");
|
||||||
private int currentPage;
|
private int currentPage;
|
||||||
private Agenda agenda;
|
private Agenda agenda;
|
||||||
String headers[] = {"Matin", "Midi", "<html>Milieu<br/>Après-midi</html>", "<html>Fin<br/>Après-midi</html>", "Soirée"};
|
private ArrayList<Slot> slots = new ArrayList<Slot>();
|
||||||
private CompetType currentCompetition = CompetType.LM;
|
private CompetType currentCompetition = CompetType.LM;
|
||||||
|
|
||||||
public GUI() {
|
public GUI() {
|
||||||
|
@ -61,6 +63,9 @@ public class GUI extends JFrame implements ActionListener {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void switchCompetition(CompetType competType) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Object source = e.getSource();
|
Object source = e.getSource();
|
||||||
|
@ -79,19 +84,16 @@ public class GUI extends JFrame implements ActionListener {
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
} else if (source == LMButton) {
|
} else if (source == LMButton) {
|
||||||
this.currentCompetition = CompetType.LM;
|
this.currentCompetition = CompetType.LM;
|
||||||
this.headers = new String[]{"Matin", "Midi", "<html>Milieu<br/>Après-midi</html>", "<html>Fin<br/>Après-midi</html>", "Soirée"};
|
|
||||||
this.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
this.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
} else if (source == HCButton) {
|
} else if (source == HCButton) {
|
||||||
this.headers = new String[]{"<html>Fin<br/>Matinée</html>", "<html>Fin<br/>Après-midi</html>", "Soirée"};
|
|
||||||
this.currentCompetition = CompetType.HC;
|
this.currentCompetition = CompetType.HC;
|
||||||
this.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
this.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
} else if (source == UCRButton) {
|
} else if (source == UCRButton) {
|
||||||
this.currentCompetition = CompetType.UCR;
|
this.currentCompetition = CompetType.UCR;
|
||||||
this.headers = new String[]{"Matin", "Midi", "<html>Milieu<br/>Après-midi</html>", "<html>Fin<br/>Après-midi</html>", "Soirée"};
|
|
||||||
this.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
this.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
this.revalidate();
|
this.revalidate();
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
package GUI.Types;
|
package GUI.Types;
|
||||||
|
|
||||||
|
import DB.Competition;
|
||||||
|
import DB.Slot;
|
||||||
|
import Exceptions.NotFoundInTable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public enum CompetType {
|
public enum CompetType {
|
||||||
LM("Long Métrage"),
|
LM("Long Métrage"),
|
||||||
UCR("Un Certain Regard"),
|
UCR("Un Certain Regard"),
|
||||||
|
@ -10,13 +16,13 @@ public enum CompetType {
|
||||||
this.competition = competition;
|
this.competition = competition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getHeaders() {
|
public ArrayList<Slot> getSlots() {
|
||||||
if (this.competition.equals("Long Métrage") || this.competition.equals("Un Certain Regard")) {
|
try {
|
||||||
return new String[]{"Matin", "Midi", "<html>Milieu<br/>Après-midi</html>", "<html>Fin<br/>Après-midi</html>", "Soirée"};
|
return Slot.getAll(new Competition(competition));
|
||||||
} else if (this.competition.equals("Hors Compétition")) {
|
} catch (NotFoundInTable notFoundInTable) {
|
||||||
return new String[]{"<html>Fin<br/>Matinée</html>", "<html>Fin<br/>Après-midi</html>", "Soirée"};
|
notFoundInTable.printStackTrace();
|
||||||
}
|
}
|
||||||
return new String[0];
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCompetition() {
|
public String getCompetition() {
|
||||||
|
|
Reference in a new issue