1
0
Fork 0
This commit is contained in:
Tergel TSAGAAN 2021-01-14 08:52:54 +01:00 committed by flifloo
parent c869010150
commit b3d18e78b2
3 changed files with 12 additions and 15 deletions

View file

@ -4,13 +4,12 @@ import Config.Config;
import DB.Competition;
import DB.Projection;
import DB.Slot;
import Exceptions.NotFoundInTable;
import Exceptions.ProjectionNotSpecified;
import GUI.Agenda.Model.AgendaTableModel;
import GUI.ProjectionHandler;
import GUI.ProjectionSelecter;
import GUI.Types.CompetType;
import GUI.Types.ProjectionType;
import lombok.Getter;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
@ -28,18 +27,19 @@ public class Agenda extends JPanel {
private Object headers[];
private int currentPage;
private JTable table;
private CompetType competionType;
@Getter
private Competition competition;
private Agenda agenda;
private ArrayList<Slot> slots;
private Slot currentSlot;
private LocalDate currentDay;
public Agenda(JPanel agendaPanel, int currentPage, CompetType competionType) {
public Agenda(JPanel agendaPanel, int currentPage, Competition competition) {
this.agendaPanel = agendaPanel;
this.slots = competionType.getSlots();
this.slots = Slot.getAll(competition);
this.headers = slots.toArray();
this.currentPage = currentPage;
this.competionType = competionType;
this.competition = competition;
this.agendaPanel.removeAll();
int totalPages[] = dayToPage();
if (this.currentPage >= totalPages.length) {
@ -101,7 +101,7 @@ public class Agenda extends JPanel {
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setRowHeight(100);
Agenda tmp = this;
agenda = this;
table.addMouseListener(new MouseInputAdapter() {
@Override
public void mouseReleased(MouseEvent mouseEvent) {
@ -113,7 +113,7 @@ public class Agenda extends JPanel {
Projection projection = null;
if (currentCellValue.getClass() == Projection.class)
projection = (Projection) currentCellValue;
PopUpProjection popUpProjection = new PopUpProjection(projection, tmp);
PopUpProjection popUpProjection = new PopUpProjection(projection, agenda);
popUpProjection.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
}
}
@ -167,7 +167,7 @@ public class Agenda extends JPanel {
private void updateMovies() {
try {
ArrayList<Projection> projections = Projection.getAvailable(new Competition(this.competionType.getCompetition()));
ArrayList<Projection> projections = Projection.getAvailable(competition);
for (Projection projection : projections) {
addMovie(projection);
}
@ -216,9 +216,6 @@ public class Agenda extends JPanel {
return this.currentPage;
}
public Competition getCompetition() throws NotFoundInTable {
return new Competition(competionType.getCompetition());
}
public Slot getSlot() {
return currentSlot;

View file

@ -32,7 +32,7 @@ public class ProjectionTableModel extends AbstractTableModel {
}
public Projection getRowAt(int row) {
return (Projection) data[row];
return data[row];
}
@Override

View file

@ -21,6 +21,7 @@ public class ProjectionSelecter extends JDialog {
public ProjectionSelecter(ArrayList<Projection> projections, Agenda agenda) {
this.agenda = agenda;
this.currentProjection = null;
setContentPane(contentPane);
setModal(true);
setLocationRelativeTo(null);
@ -46,8 +47,8 @@ public class ProjectionSelecter extends JDialog {
JTable table = (JTable) e.getSource();
Point point = e.getPoint();
int row = table.rowAtPoint(point);
if (e.getClickCount() == 2 && table.getSelectedRow() != -1) {
currentProjection = ((ProjectionTableModel) table.getModel()).getRowAt(row);
if (e.getClickCount() == 2 && table.getSelectedRow() != -1) {
agenda.openDialog(ProjectionType.EDIT, currentProjection);
dispose();
}
@ -69,7 +70,6 @@ public class ProjectionSelecter extends JDialog {
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
private void onOK() {
agenda.openDialog(ProjectionType.EDIT, currentProjection);
dispose();