merge
This commit is contained in:
parent
c869010150
commit
b3d18e78b2
3 changed files with 12 additions and 15 deletions
|
@ -4,13 +4,12 @@ import Config.Config;
|
||||||
import DB.Competition;
|
import DB.Competition;
|
||||||
import DB.Projection;
|
import DB.Projection;
|
||||||
import DB.Slot;
|
import DB.Slot;
|
||||||
import Exceptions.NotFoundInTable;
|
|
||||||
import Exceptions.ProjectionNotSpecified;
|
import Exceptions.ProjectionNotSpecified;
|
||||||
import GUI.Agenda.Model.AgendaTableModel;
|
import GUI.Agenda.Model.AgendaTableModel;
|
||||||
import GUI.ProjectionHandler;
|
import GUI.ProjectionHandler;
|
||||||
import GUI.ProjectionSelecter;
|
import GUI.ProjectionSelecter;
|
||||||
import GUI.Types.CompetType;
|
|
||||||
import GUI.Types.ProjectionType;
|
import GUI.Types.ProjectionType;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.MouseInputAdapter;
|
import javax.swing.event.MouseInputAdapter;
|
||||||
|
@ -28,18 +27,19 @@ public class Agenda extends JPanel {
|
||||||
private Object headers[];
|
private Object headers[];
|
||||||
private int currentPage;
|
private int currentPage;
|
||||||
private JTable table;
|
private JTable table;
|
||||||
private CompetType competionType;
|
@Getter
|
||||||
|
private Competition competition;
|
||||||
private Agenda agenda;
|
private Agenda agenda;
|
||||||
private ArrayList<Slot> slots;
|
private ArrayList<Slot> slots;
|
||||||
private Slot currentSlot;
|
private Slot currentSlot;
|
||||||
private LocalDate currentDay;
|
private LocalDate currentDay;
|
||||||
|
|
||||||
public Agenda(JPanel agendaPanel, int currentPage, CompetType competionType) {
|
public Agenda(JPanel agendaPanel, int currentPage, Competition competition) {
|
||||||
this.agendaPanel = agendaPanel;
|
this.agendaPanel = agendaPanel;
|
||||||
this.slots = competionType.getSlots();
|
this.slots = Slot.getAll(competition);
|
||||||
this.headers = slots.toArray();
|
this.headers = slots.toArray();
|
||||||
this.currentPage = currentPage;
|
this.currentPage = currentPage;
|
||||||
this.competionType = competionType;
|
this.competition = competition;
|
||||||
this.agendaPanel.removeAll();
|
this.agendaPanel.removeAll();
|
||||||
int totalPages[] = dayToPage();
|
int totalPages[] = dayToPage();
|
||||||
if (this.currentPage >= totalPages.length) {
|
if (this.currentPage >= totalPages.length) {
|
||||||
|
@ -101,7 +101,7 @@ public class Agenda extends JPanel {
|
||||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||||
table.setRowHeight(100);
|
table.setRowHeight(100);
|
||||||
Agenda tmp = this;
|
agenda = this;
|
||||||
table.addMouseListener(new MouseInputAdapter() {
|
table.addMouseListener(new MouseInputAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent mouseEvent) {
|
public void mouseReleased(MouseEvent mouseEvent) {
|
||||||
|
@ -113,7 +113,7 @@ public class Agenda extends JPanel {
|
||||||
Projection projection = null;
|
Projection projection = null;
|
||||||
if (currentCellValue.getClass() == Projection.class)
|
if (currentCellValue.getClass() == Projection.class)
|
||||||
projection = (Projection) currentCellValue;
|
projection = (Projection) currentCellValue;
|
||||||
PopUpProjection popUpProjection = new PopUpProjection(projection, tmp);
|
PopUpProjection popUpProjection = new PopUpProjection(projection, agenda);
|
||||||
popUpProjection.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
|
popUpProjection.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ public class Agenda extends JPanel {
|
||||||
|
|
||||||
private void updateMovies() {
|
private void updateMovies() {
|
||||||
try {
|
try {
|
||||||
ArrayList<Projection> projections = Projection.getAvailable(new Competition(this.competionType.getCompetition()));
|
ArrayList<Projection> projections = Projection.getAvailable(competition);
|
||||||
for (Projection projection : projections) {
|
for (Projection projection : projections) {
|
||||||
addMovie(projection);
|
addMovie(projection);
|
||||||
}
|
}
|
||||||
|
@ -216,9 +216,6 @@ public class Agenda extends JPanel {
|
||||||
return this.currentPage;
|
return this.currentPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Competition getCompetition() throws NotFoundInTable {
|
|
||||||
return new Competition(competionType.getCompetition());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Slot getSlot() {
|
public Slot getSlot() {
|
||||||
return currentSlot;
|
return currentSlot;
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ProjectionTableModel extends AbstractTableModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Projection getRowAt(int row) {
|
public Projection getRowAt(int row) {
|
||||||
return (Projection) data[row];
|
return data[row];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class ProjectionSelecter extends JDialog {
|
||||||
|
|
||||||
public ProjectionSelecter(ArrayList<Projection> projections, Agenda agenda) {
|
public ProjectionSelecter(ArrayList<Projection> projections, Agenda agenda) {
|
||||||
this.agenda = agenda;
|
this.agenda = agenda;
|
||||||
|
this.currentProjection = null;
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
|
@ -46,8 +47,8 @@ public class ProjectionSelecter extends JDialog {
|
||||||
JTable table = (JTable) e.getSource();
|
JTable table = (JTable) e.getSource();
|
||||||
Point point = e.getPoint();
|
Point point = e.getPoint();
|
||||||
int row = table.rowAtPoint(point);
|
int row = table.rowAtPoint(point);
|
||||||
|
currentProjection = ((ProjectionTableModel) table.getModel()).getRowAt(row);
|
||||||
if (e.getClickCount() == 2 && table.getSelectedRow() != -1) {
|
if (e.getClickCount() == 2 && table.getSelectedRow() != -1) {
|
||||||
currentProjection = ((ProjectionTableModel) table.getModel()).getRowAt(row);
|
|
||||||
agenda.openDialog(ProjectionType.EDIT, currentProjection);
|
agenda.openDialog(ProjectionType.EDIT, currentProjection);
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
@ -69,7 +70,6 @@ public class ProjectionSelecter extends JDialog {
|
||||||
}
|
}
|
||||||
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onOK() {
|
private void onOK() {
|
||||||
agenda.openDialog(ProjectionType.EDIT, currentProjection);
|
agenda.openDialog(ProjectionType.EDIT, currentProjection);
|
||||||
dispose();
|
dispose();
|
||||||
|
|
Reference in a new issue