diff --git a/bin/BillGUI/BillGui.class b/bin/BillGUI/BillGui.class new file mode 100644 index 0000000..e031975 Binary files /dev/null and b/bin/BillGUI/BillGui.class differ diff --git a/bin/BillGUI/ButtonListenerBill.class b/bin/BillGUI/ButtonListenerBill.class new file mode 100644 index 0000000..c00f559 Binary files /dev/null and b/bin/BillGUI/ButtonListenerBill.class differ diff --git a/bin/BillGUI/ButtonListenerManager.class b/bin/BillGUI/ButtonListenerManager.class new file mode 100644 index 0000000..a064d34 Binary files /dev/null and b/bin/BillGUI/ButtonListenerManager.class differ diff --git a/bin/BillGUI/ButtonQuitListener.class b/bin/BillGUI/ButtonQuitListener.class deleted file mode 100644 index c78f901..0000000 Binary files a/bin/BillGUI/ButtonQuitListener.class and /dev/null differ diff --git a/bin/BillGUI/HesSoGarage.class b/bin/BillGUI/HesSoGarage.class index 1928a32..afe39d3 100644 Binary files a/bin/BillGUI/HesSoGarage.class and b/bin/BillGUI/HesSoGarage.class differ diff --git a/bin/BillGUI/Impression1.class b/bin/BillGUI/Impression1.class new file mode 100644 index 0000000..10a72e2 Binary files /dev/null and b/bin/BillGUI/Impression1.class differ diff --git a/bin/BillGUI/ManagerGui$1.class b/bin/BillGUI/ManagerGui$1.class new file mode 100644 index 0000000..4368c43 Binary files /dev/null and b/bin/BillGUI/ManagerGui$1.class differ diff --git a/bin/BillGUI/ManagerGui$2.class b/bin/BillGUI/ManagerGui$2.class new file mode 100644 index 0000000..a6f9468 Binary files /dev/null and b/bin/BillGUI/ManagerGui$2.class differ diff --git a/bin/BillGUI/ManagerGui.class b/bin/BillGUI/ManagerGui.class index b394bfe..bc89d98 100644 Binary files a/bin/BillGUI/ManagerGui.class and b/bin/BillGUI/ManagerGui.class differ diff --git a/bin/BillGUI/Row.class b/bin/BillGUI/Row.class index 69344f0..f5075da 100644 Binary files a/bin/BillGUI/Row.class and b/bin/BillGUI/Row.class differ diff --git a/bin/GUI/ButtonListener.class b/bin/GUI/ButtonListener.class index 5ea8d2d..3bad10c 100644 Binary files a/bin/GUI/ButtonListener.class and b/bin/GUI/ButtonListener.class differ diff --git a/bin/GUI/GUI1.class b/bin/GUI/GUI1.class index 24dff36..ed02c4a 100644 Binary files a/bin/GUI/GUI1.class and b/bin/GUI/GUI1.class differ diff --git a/bin/GUI/GUI2.class b/bin/GUI/GUI2.class index 02a0620..1924fb4 100644 Binary files a/bin/GUI/GUI2.class and b/bin/GUI/GUI2.class differ diff --git a/bin/GUI/Listener.class b/bin/GUI/Listener.class index feb560b..180cf01 100644 Binary files a/bin/GUI/Listener.class and b/bin/GUI/Listener.class differ diff --git a/src/BillGUI/BillGui.java b/src/BillGUI/BillGui.java new file mode 100644 index 0000000..d9bc9ae --- /dev/null +++ b/src/BillGUI/BillGui.java @@ -0,0 +1,58 @@ +package BillGUI; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class BillGui extends JFrame{ + String bill; + JPanel jP; + + BillGui(String bill){ + this.bill = bill; + + //Create the frame with the layout + this.setSize(400,600); + this.setLocation(600,200); + this.setVisible(true); + FlowLayout fl = new FlowLayout(); + this.setLayout(fl); + + jP = new JPanel(); + + JLabel jBill = new JLabel(bill); + jP.add(jBill); + + this.add(jP); + + JButton buttonPrint = new JButton("Print"); + buttonPrint.addActionListener(new Impression1(jP)); + /* + new ButtonListenerBill(this) { + @Override + public void actionPerformed(ActionEvent e){ + // TO-DO : print the pdf + }; + });*/ + this.add(buttonPrint); + + + } +} + +/** + * + */ +class ButtonListenerBill implements ActionListener { + JFrame Jf; + + ButtonListenerBill(JFrame Jf){ + this.Jf = Jf; + } + + @Override + public void actionPerformed(ActionEvent e){ + + }; + +} diff --git a/src/BillGUI/HesSoGarage.java b/src/BillGUI/HesSoGarage.java index 200d97d..4721167 100644 --- a/src/BillGUI/HesSoGarage.java +++ b/src/BillGUI/HesSoGarage.java @@ -4,9 +4,9 @@ public class HesSoGarage { public static void main(String[] args) { GarageManager garageManager = new GarageManager(); ManagerGui managerGui; - String name = "Garage manager\nPrestations"; - String logoFilePath = "src/logo_garage.png"; - managerGui = new ManagerGui(name, logoFilePath, garageManager.getServices()); + String name = "\033[3mGarage manager\033[0m\nPrestations"; //TODO résoudre en italique + String logoFilePath = "src/logo_garage.png"; //TODO redimensionnement automatique + managerGui = new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager); //TODO affichage sans redimmensionnement } } diff --git a/src/BillGUI/ManagerGui.java b/src/BillGUI/ManagerGui.java index 7a3b2e2..b02f5aa 100644 --- a/src/BillGUI/ManagerGui.java +++ b/src/BillGUI/ManagerGui.java @@ -8,19 +8,23 @@ import javax.swing.*; /** * */ -public class ManagerGui extends JFrame{ +public class ManagerGui extends JFrame { GridLayout grid; JLabel Jname; JLabel Jlogo; ImageIcon logo; + String buttonNameQuit = "Quit"; + String buttonNameBill = "Show bill"; + Vector prestations = new Vector<>(); + Vector valuePrestations = new Vector(); /** - * + * */ - public ManagerGui(String name, String logoFilePath, String[] prestationsName){ + public ManagerGui(String name, String logoFilePath, String[] prestationsName, GarageManager garageManager){ this.setSize(400,600); this.setLocation(600,200); this.setVisible(true); @@ -39,7 +43,6 @@ public class ManagerGui extends JFrame{ //Create rows for prestations for(String s : prestationsName){ prestations.add(new Row(s)); - } //add rows on the Jframe for(Row r : prestations){ @@ -48,16 +51,44 @@ public class ManagerGui extends JFrame{ } //Create and add button - JButton ButtonBill = new JButton("Show bill"); - JButton ButtonQuit = new JButton("Quit"); - this.add(ButtonBill); - this.add(ButtonQuit); - + JButton buttonBill = new JButton(buttonNameBill); + buttonBill.addActionListener(new ButtonListenerManager(valuePrestations, prestations, garageManager){ + /** + * + */ + @Override + public void actionPerformed(ActionEvent e){ + //Get the value of each spinner + for (int i = 0; i < prestations.size(); i++) { + int value = (int)prestations.elementAt(i).spinner.getValue(); + for (int j = 0; j < value; j++) { + valuePrestations.add(i); + } + System.out.println(value); + } + + new BillGui(garageManager.generateHTMLBill(valuePrestations)); + }; + }); + JButton buttonQuit = new JButton(buttonNameQuit); + buttonQuit.addActionListener(new ButtonListenerManager(this){ + /** + * + */ + @Override + public void actionPerformed(ActionEvent e){ + Jf.dispose(); + }; + }); - } + this.add(buttonBill); + this.add(buttonQuit); + } } + + /** * */ @@ -69,30 +100,32 @@ class Row { label = new JLabel(title); spinner = new JSpinner(); } - } + /** * */ -class ButtonQuitListener implements ActionListener { - JFrame Jf; - /** - * - * @param Jf - */ - ButtonQuitListener(JFrame Jf){ +class ButtonListenerManager implements ActionListener { + JFrame Jf; + Vector valuePrestations; + Vector prestations; + GarageManager garageManager; + + ButtonListenerManager(Vector valuePrestations, Vector prestations, GarageManager garageManager){ + this.valuePrestations = valuePrestations; + this.prestations = prestations; + this.garageManager = garageManager; + }; + + ButtonListenerManager(JFrame Jf){ this.Jf = Jf; - } - /** - * - * @param e - */ - @Override - public void actionPerformed(ActionEvent e){ - Jf.dispose(); } - + + @Override + public void actionPerformed(ActionEvent e){}; + } +