Merge branch 'master' of https://forge.univ-lyon1.fr/cannes-cpoa/projection-planning into master
Conflicts: src/main/java/GUI/Agenda/Agenda.java
This commit is contained in:
commit
c869010150
10 changed files with 148 additions and 68 deletions
|
@ -15,6 +15,7 @@ dependencies {
|
|||
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
||||
implementation 'io.github.vincenzopalazzo:material-ui-swing:1.1.1'
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
@ -101,7 +101,7 @@ public class Agenda extends JPanel {
|
|||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
table.setRowHeight(100);
|
||||
agenda = this;
|
||||
Agenda tmp = 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, agenda);
|
||||
PopUpProjection popUpProjection = new PopUpProjection(projection, tmp);
|
||||
popUpProjection.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,19 +31,21 @@
|
|||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="ea5a" class="javax.swing.JButton" binding="previousButton">
|
||||
<component id="ea5a" class="javax.swing.JButton" binding="previousButton" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="JetBrains Mono" style="0"/>
|
||||
<text value="←"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ddc41" class="javax.swing.JButton" binding="nextButton">
|
||||
<component id="ddc41" class="javax.swing.JButton" binding="nextButton" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<font name="JetBrains Mono" style="0"/>
|
||||
<text value="→"/>
|
||||
</properties>
|
||||
</component>
|
||||
|
@ -75,7 +77,7 @@
|
|||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="b1c37" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<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"/>
|
||||
<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">
|
||||
|
@ -84,38 +86,7 @@
|
|||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="2dfdc" class="javax.swing.JButton" binding="LMButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="75" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="LM"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9869d" class="javax.swing.JButton" binding="HCButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="75" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="HC"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="bc004" class="javax.swing.JButton" binding="UCRButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="75" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="UCR"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
<children/>
|
||||
</grid>
|
||||
<hspacer id="975cc">
|
||||
<constraints>
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package GUI;
|
||||
|
||||
import DB.Competition;
|
||||
import DB.Slot;
|
||||
import Exceptions.NotFoundInTable;
|
||||
import GUI.Agenda.Agenda;
|
||||
import GUI.Types.CompetType;
|
||||
import GUI.Theme.PrimaryContainedButtonUI;
|
||||
import GUI.Types.ProjectionType;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -19,6 +21,7 @@ public class GUI extends JFrame implements ActionListener {
|
|||
private JButton LMButton;
|
||||
private JButton HCButton;
|
||||
private JButton UCRButton;
|
||||
private JPanel competitionButtonPanel;
|
||||
private JMenuBar menuBar = new JMenuBar();
|
||||
private JMenu menuFichier = new JMenu("File");
|
||||
private JMenuItem menuItemAddProj = new JMenuItem("Add projection");
|
||||
|
@ -26,9 +29,9 @@ public class GUI extends JFrame implements ActionListener {
|
|||
private int currentPage;
|
||||
private Agenda agenda;
|
||||
private ArrayList<Slot> slots = new ArrayList<Slot>();
|
||||
private CompetType currentCompetition = CompetType.LM;
|
||||
private Competition currentCompetition = new Competition("Long Métrage");
|
||||
|
||||
public GUI() {
|
||||
public GUI() throws NotFoundInTable {
|
||||
super();
|
||||
construct();
|
||||
}
|
||||
|
@ -55,15 +58,19 @@ public class GUI extends JFrame implements ActionListener {
|
|||
agenda = new Agenda(agendaPanel, this.currentPage, this.currentCompetition);
|
||||
previousButton.addActionListener(this);
|
||||
nextButton.addActionListener(this);
|
||||
HCButton.addActionListener(this);
|
||||
LMButton.addActionListener(this);
|
||||
UCRButton.addActionListener(this);
|
||||
menuItemAddProj.addActionListener(this);
|
||||
menuItemRemoveProj.addActionListener(this);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void switchCompetition(CompetType competType) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,21 +87,6 @@ public class GUI extends JFrame implements ActionListener {
|
|||
Agenda agenda = new Agenda(agendaPanel, this.currentPage, this.currentCompetition);
|
||||
this.currentPage = agenda.getCurrentPage();
|
||||
|
||||
this.repaint();
|
||||
this.revalidate();
|
||||
} else if (source == LMButton) {
|
||||
this.currentCompetition = CompetType.LM;
|
||||
this.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
||||
this.repaint();
|
||||
this.revalidate();
|
||||
} else if (source == HCButton) {
|
||||
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.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
||||
this.repaint();
|
||||
this.revalidate();
|
||||
} else if (source == this.menuItemAddProj) {
|
||||
|
@ -103,4 +95,19 @@ public class GUI extends JFrame implements ActionListener {
|
|||
agenda.openDialog(ProjectionType.REMOVE);
|
||||
}
|
||||
}
|
||||
|
||||
private void switchAgenda(Competition competition) {
|
||||
this.currentCompetition = competition;
|
||||
this.agenda = new Agenda(agendaPanel, 0, this.currentCompetition);
|
||||
this.repaint();
|
||||
this.revalidate();
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
competitionButton();
|
||||
nextButton = new JButton();
|
||||
nextButton.setUI(new PrimaryContainedButtonUI());
|
||||
previousButton = new JButton();
|
||||
previousButton.setUI(new PrimaryContainedButtonUI());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="6eea5" class="javax.swing.JButton" binding="cancelButton">
|
||||
<component id="6eea5" class="javax.swing.JButton" binding="cancelButton" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
|
@ -88,7 +88,7 @@
|
|||
<text value="Cancel"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9b61e" class="javax.swing.JButton" binding="confirmButton">
|
||||
<component id="9b61e" class="javax.swing.JButton" binding="confirmButton" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
|
|
|
@ -2,9 +2,11 @@ package GUI;
|
|||
|
||||
import Config.Config;
|
||||
import DB.*;
|
||||
import Exceptions.NotFoundInTable;
|
||||
import Exceptions.ProjectionNotSpecified;
|
||||
import GUI.Agenda.Agenda;
|
||||
import GUI.Theme.DangerContainedButtonUI;
|
||||
import GUI.Theme.PrimaryContainedButtonUI;
|
||||
import GUI.Theme.SecondaryContainedButtonUI;
|
||||
import GUI.Types.ProjectionType;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -45,9 +47,7 @@ public class ProjectionHandler extends JDialog {
|
|||
throw new ProjectionNotSpecified();
|
||||
this.projectionType = projectionType;
|
||||
this.agenda = agenda;
|
||||
try {
|
||||
competitionComboBox.getModel().setSelectedItem(agenda.getCompetition());
|
||||
} catch (NotFoundInTable ignored) {}
|
||||
competitionComboBox.getModel().setSelectedItem(agenda.getCompetition());
|
||||
if (agenda.getDate() != null || agenda.getSlot() != null) {
|
||||
updateMovies();
|
||||
updateDates();
|
||||
|
@ -56,14 +56,14 @@ public class ProjectionHandler extends JDialog {
|
|||
slotComboBox.getModel().setSelectedItem(agenda.getSlot());
|
||||
updateRooms();
|
||||
}
|
||||
createUIComponents();
|
||||
createUI();
|
||||
}
|
||||
|
||||
public ProjectionHandler(ProjectionType projectionType, Agenda agenda, Projection projection) {
|
||||
this.projectionType = projectionType;
|
||||
this.agenda = agenda;
|
||||
this.projection = projection;
|
||||
createUIComponents();
|
||||
createUI();
|
||||
competitionComboBox.getModel().setSelectedItem(projection.getCompetition());
|
||||
filmComboBox.getModel().setSelectedItem(projection.getMovie());
|
||||
dayComboBox.getModel().setSelectedItem(projection.getStartDate().toLocalDate());
|
||||
|
@ -74,7 +74,7 @@ public class ProjectionHandler extends JDialog {
|
|||
comboBox.setEnabled(false);
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
private void createUI() {
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
setPreferredSize(new Dimension(500, 300));
|
||||
|
@ -107,6 +107,16 @@ public class ProjectionHandler extends JDialog {
|
|||
dispose();
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
confirmButton = new JButton();
|
||||
if (projectionType == ProjectionType.REMOVE)
|
||||
confirmButton.setUI(new DangerContainedButtonUI());
|
||||
else
|
||||
confirmButton.setUI(new PrimaryContainedButtonUI());
|
||||
cancelButton = new JButton();
|
||||
cancelButton.setUI(new SecondaryContainedButtonUI());
|
||||
}
|
||||
|
||||
private void updateCompetitions() {
|
||||
ArrayList<Competition> competitions = Competition.getAll();
|
||||
if (competitions != null)
|
||||
|
|
28
src/main/java/GUI/Theme/DangerContainedButtonUI.java
Normal file
28
src/main/java/GUI/Theme/DangerContainedButtonUI.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package GUI.Theme;
|
||||
|
||||
import mdlaf.animation.MaterialUIMovement;
|
||||
import mdlaf.components.button.MaterialButtonUI;
|
||||
import mdlaf.utils.MaterialColors;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class DangerContainedButtonUI extends MaterialButtonUI {
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
super.mouseHoverEnabled = false;
|
||||
super.installUI(c);
|
||||
super.mouseHoverEnabled = true;
|
||||
super.colorMouseHoverNormalButton = MaterialColors.RED_600;
|
||||
super.background = MaterialColors.RED_700;
|
||||
c.setBackground(super.background);
|
||||
super.foreground = MaterialColors.WHITE;
|
||||
c.setForeground(super.foreground);
|
||||
|
||||
if (super.mouseHoverEnabled) {
|
||||
c.addMouseListener(
|
||||
MaterialUIMovement.getMovement(c, this.colorMouseHoverNormalButton)
|
||||
);
|
||||
}
|
||||
super.borderEnabled = false;
|
||||
}
|
||||
}
|
28
src/main/java/GUI/Theme/PrimaryContainedButtonUI.java
Normal file
28
src/main/java/GUI/Theme/PrimaryContainedButtonUI.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package GUI.Theme;
|
||||
|
||||
import mdlaf.animation.MaterialUIMovement;
|
||||
import mdlaf.components.button.MaterialButtonUI;
|
||||
import mdlaf.utils.MaterialColors;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class PrimaryContainedButtonUI extends MaterialButtonUI {
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
super.mouseHoverEnabled = false;
|
||||
super.installUI(c);
|
||||
super.mouseHoverEnabled = true;
|
||||
super.colorMouseHoverNormalButton = MaterialColors.BLUE_600;
|
||||
super.background = MaterialColors.BLUE_700;
|
||||
c.setBackground(super.background);
|
||||
super.foreground = MaterialColors.WHITE;
|
||||
c.setForeground(super.foreground);
|
||||
|
||||
if (super.mouseHoverEnabled) {
|
||||
c.addMouseListener(
|
||||
MaterialUIMovement.getMovement(c, this.colorMouseHoverNormalButton)
|
||||
);
|
||||
}
|
||||
super.borderEnabled = false;
|
||||
}
|
||||
}
|
28
src/main/java/GUI/Theme/SecondaryContainedButtonUI.java
Normal file
28
src/main/java/GUI/Theme/SecondaryContainedButtonUI.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package GUI.Theme;
|
||||
|
||||
import mdlaf.animation.MaterialUIMovement;
|
||||
import mdlaf.components.button.MaterialButtonUI;
|
||||
import mdlaf.utils.MaterialColors;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class SecondaryContainedButtonUI extends MaterialButtonUI {
|
||||
@Override
|
||||
public void installUI(JComponent c) {
|
||||
super.mouseHoverEnabled = false;
|
||||
super.installUI(c);
|
||||
super.mouseHoverEnabled = true;
|
||||
super.colorMouseHoverNormalButton = MaterialColors.PURPLE_600;
|
||||
super.background = MaterialColors.PURPLE_700;
|
||||
c.setBackground(super.background);
|
||||
super.foreground = MaterialColors.WHITE;
|
||||
c.setForeground(super.foreground);
|
||||
|
||||
if (super.mouseHoverEnabled) {
|
||||
c.addMouseListener(
|
||||
MaterialUIMovement.getMovement(c, this.colorMouseHoverNormalButton)
|
||||
);
|
||||
}
|
||||
super.borderEnabled = false;
|
||||
}
|
||||
}
|
|
@ -3,10 +3,17 @@ package ProjectionPlanning;
|
|||
import DB.DB;
|
||||
import Exceptions.NotFoundInTable;
|
||||
import GUI.GUI;
|
||||
import mdlaf.MaterialLookAndFeel;
|
||||
import mdlaf.themes.MaterialLiteTheme;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) throws NotFoundInTable {
|
||||
DB.connect();
|
||||
try {
|
||||
UIManager.setLookAndFeel(new MaterialLookAndFeel(new MaterialLiteTheme()));
|
||||
} catch (UnsupportedLookAndFeelException ignored) {}
|
||||
new GUI();
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue