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
|
@ -57,7 +57,21 @@ public class Slot extends Table {
|
|||
ArrayList<Slot> list = new ArrayList<>();
|
||||
try {
|
||||
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT id FROM Slot");
|
||||
for (ResultSet rs = ps.executeQuery(); rs.next();)
|
||||
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) {
|
||||
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) {
|
||||
|
@ -72,7 +86,7 @@ public class Slot extends Table {
|
|||
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT S.id FROM Slot S INNER JOIN Projection P on S.id = P.SlotId WHERE S.CompetitionName = ? AND P.startDate = ? GROUP BY S.id");
|
||||
ps.setString(1, competition.getName());
|
||||
ps.setDate(2, date);
|
||||
for (ResultSet rs = ps.executeQuery(); rs.next();)
|
||||
for (ResultSet rs = ps.executeQuery(); rs.next(); )
|
||||
list.add(new Slot(rs.getInt("id")));
|
||||
ps.close();
|
||||
} catch (SQLException | NullPointerException | NotFoundInTable e) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package GUI.Agenda;
|
|||
|
||||
import DB.Competition;
|
||||
import DB.Projection;
|
||||
import DB.Slot;
|
||||
import Exceptions.ProjectionNotSpecified;
|
||||
import GUI.ProjectionHandler;
|
||||
import GUI.Types.CompetType;
|
||||
|
@ -19,16 +20,17 @@ import java.util.Arrays;
|
|||
|
||||
public class Agenda extends JPanel {
|
||||
private JPanel agendaPanel;
|
||||
private String headers[];
|
||||
private Object headers[];
|
||||
private int totalDay;
|
||||
private int currentPage;
|
||||
private JTable table;
|
||||
private CompetType competionType;
|
||||
private Agenda agenda;
|
||||
|
||||
private ArrayList<Slot> slots;
|
||||
public Agenda(JPanel agendaPanel, int currentPage, CompetType competionType) {
|
||||
this.agendaPanel = agendaPanel;
|
||||
this.headers = competionType.getHeaders();
|
||||
this.slots = competionType.getSlots();
|
||||
this.headers = slots.toArray();
|
||||
this.totalDay = 11;
|
||||
this.currentPage = currentPage;
|
||||
this.competionType = competionType;
|
||||
|
@ -178,12 +180,10 @@ public class Agenda extends JPanel {
|
|||
private void addMovie(Projection projection) {
|
||||
Date startDate = projection.getStartDate();
|
||||
Time time = projection.getSlot().getStartTime();
|
||||
String movieName = projection.getMovie().getName();
|
||||
int column = this.table.getColumn(startDate.toString()).getModelIndex();
|
||||
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 < times.length; i++) {
|
||||
if (times[i].equals(time.toString())) {
|
||||
for (int i = 0; i < slots.size(); i++) {
|
||||
if (slots.get(i).getStartTime().toString().equals(time.toString())) {
|
||||
row = i;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package GUI;
|
||||
|
||||
import DB.Slot;
|
||||
import GUI.Agenda.Agenda;
|
||||
import GUI.Types.CompetType;
|
||||
import GUI.Types.ProjectionType;
|
||||
|
@ -7,6 +8,7 @@ import GUI.Types.ProjectionType;
|
|||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GUI extends JFrame implements ActionListener {
|
||||
private JPanel mainPanel;
|
||||
|
@ -23,7 +25,7 @@ public class GUI extends JFrame implements ActionListener {
|
|||
private JMenuItem menuItemRemoveProj = new JMenuItem("Remove projection");
|
||||
private int currentPage;
|
||||
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;
|
||||
|
||||
public GUI() {
|
||||
|
@ -61,6 +63,9 @@ public class GUI extends JFrame implements ActionListener {
|
|||
setVisible(true);
|
||||
}
|
||||
|
||||
private void switchCompetition(CompetType competType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Object source = e.getSource();
|
||||
|
@ -79,19 +84,16 @@ public class GUI extends JFrame implements ActionListener {
|
|||
this.revalidate();
|
||||
} else if (source == LMButton) {
|
||||
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.repaint();
|
||||
this.revalidate();
|
||||
} 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.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
||||
this.repaint();
|
||||
this.revalidate();
|
||||
} else if (source == UCRButton) {
|
||||
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.repaint();
|
||||
this.revalidate();
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package GUI.Types;
|
||||
|
||||
import DB.Competition;
|
||||
import DB.Slot;
|
||||
import Exceptions.NotFoundInTable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public enum CompetType {
|
||||
LM("Long Métrage"),
|
||||
UCR("Un Certain Regard"),
|
||||
|
@ -10,13 +16,13 @@ public enum CompetType {
|
|||
this.competition = competition;
|
||||
}
|
||||
|
||||
public String[] getHeaders() {
|
||||
if (this.competition.equals("Long Métrage") || this.competition.equals("Un Certain Regard")) {
|
||||
return new String[]{"Matin", "Midi", "<html>Milieu<br/>Après-midi</html>", "<html>Fin<br/>Après-midi</html>", "Soirée"};
|
||||
} else if (this.competition.equals("Hors Compétition")) {
|
||||
return new String[]{"<html>Fin<br/>Matinée</html>", "<html>Fin<br/>Après-midi</html>", "Soirée"};
|
||||
public ArrayList<Slot> getSlots() {
|
||||
try {
|
||||
return Slot.getAll(new Competition(competition));
|
||||
} catch (NotFoundInTable notFoundInTable) {
|
||||
notFoundInTable.printStackTrace();
|
||||
}
|
||||
return new String[0];
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getCompetition() {
|
||||
|
|
Reference in a new issue