Possibility of registering new owners added
[RRRRHHHH_Code] / ruralHouses / src / gui / listOfBookingRequestsGUI.java
index 7495777..2a70df5 100644 (file)
@@ -5,6 +5,7 @@ import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.Enumeration;
+import java.util.LinkedList;
 import java.util.Vector;
 
 import javax.swing.JButton;
@@ -16,10 +17,10 @@ import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
 import javax.swing.table.DefaultTableModel;
 
-import businessLogic.AdminManager;
-import businessLogic.HouseManager;
-import businessLogic.HouseManagerInterface;
-import domain.Administrator;
+import businessLogic.BookingManager;
+import domain.Booking;
+import domain.Offer;
+import domain.Owner;
 import domain.RuralHouse;
 
 public class listOfBookingRequestsGUI extends JFrame {
@@ -30,16 +31,19 @@ public class listOfBookingRequestsGUI extends JFrame {
        private static final long serialVersionUID = 1L;
        private JPanel contentPane;
        private JTable table;
+       private Offer off;
+       private BookingManager bookM = new BookingManager();
        private DefaultTableModel tableModel;
-       private AdminManager am = new AdminManager();
-       private Vector<RuralHouse> houses;
-       /**
+       private Vector<Booking> bookings = new Vector<Booking>();
+
+       /**
         * Create the frame.
         */
-       public listOfBookingRequestsGUI() {
-               setTitle("Adding requests");
+       public listOfBookingRequestsGUI(Offer of) {
+               setTitle("Adding requests");
+               this.off = of;
                try {
-                       this.houses= am.getAdditionRequests();
+
                        init();
                } catch (Exception e) {
                        e.printStackTrace();
@@ -52,80 +56,69 @@ public class listOfBookingRequestsGUI extends JFrame {
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                contentPane.setLayout(null);
-
+               
+               this.bookings= this.off.getBookings();
                JLabel lblNewLabel = new JLabel();
                lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
                lblNewLabel.setBounds(23, 41, 536, 33);
                contentPane.add(lblNewLabel);
-               if (houses.isEmpty())
-                       lblNewLabel.setText("There are not houses to be added");
+               if (bookings.isEmpty())
+                       lblNewLabel
+                                       .setText("There are not bookings to be confirmed or denied");
                else
-                       lblNewLabel.setText("List of houses to be added:");
+                       lblNewLabel.setText("List of bookings:");
                JScrollPane scrollPane = new JScrollPane();
                scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
                scrollPane.setBounds(23, 113, 536, 271);
                contentPane.add(scrollPane);
 
                table = new JTable() {
-               private static final long serialVersionUID = 1L;
+                       private static final long serialVersionUID = 1L;
 
-               public boolean isCellEditable(int row, int column) {                
-                       return false;               
-               };
-           };
+                       public boolean isCellEditable(int row, int column) {
+                               return false;
+                       };
+               };
                scrollPane.setViewportView(table);
                tableModel = new DefaultTableModel(null, new String[] {
-                               "House Name", "Bedrooms", "Kitchens", "Baths", "Parkings",
-                               "Livings" });
-               
-               //Maybe there is a better way to avoid interaction.
-               //table.setEnabled(false);
+                               "Booking Number", "Is paid", "Booking Date", "Telephone",
+                               "Offer" });
+
+               // Maybe there is a better way to avoid interaction.
+               // table.setEnabled(false);
                table.setModel(tableModel);
-               
-               JButton btnNewButton = new JButton("Confirm Addition");
+
+               JButton btnNewButton = new JButton("Confirm Booking");
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
-                               if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
-                                       HouseManagerInterface hm = new HouseManager();
-                                       RuralHouse rh = houses.get(table.getSelectedRow());
-                                       //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
-                                       hm.registerNewHouse(rh);
-                                       am.removeHouseAdditionRequests(rh);
-                                       Administrator.saveInstance();
-                                       ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                       houses.remove(rh);
+                               if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
+
                                }
                        }
                });
                btnNewButton.setBounds(88, 396, 169, 25);
                contentPane.add(btnNewButton);
-               
-               JButton btnDenyAddition = new JButton("Deny Addition");
+
+               JButton btnDenyAddition = new JButton("Deny Booking");
                btnDenyAddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
-                               if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
-                                       RuralHouse rh = houses.get(table.getSelectedRow());
-                                       am.removeHouseAdditionRequests(rh);
-                                       Administrator.saveInstance();
-                                       ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                       houses.remove(rh);
+                               if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
+
                                }
                        }
                });
                btnDenyAddition.setBounds(300, 396, 169, 25);
                contentPane.add(btnDenyAddition);
-               Enumeration<RuralHouse> en = houses.elements();
-               RuralHouse rh;
-               
+               Enumeration<Booking> en = this.bookings.elements();
+               Booking book;
                while (en.hasMoreElements()) {
-                       rh = en.nextElement();
+                       book = en.nextElement();
                        Vector<Object> row = new Vector<Object>();
-                       row.add(rh.getHouseName());
-                       row.add(rh.getFeatures().getnRooms());
-                       row.add(rh.getFeatures().getnKitchens());
-                       row.add(rh.getFeatures().getnBaths());
-                       row.add(rh.getFeatures().getnParkings());
-                       row.add(rh.getFeatures().getnLivings());
+                       row.add(book.getBookNumber());
+                       row.add(book.isPaid());
+                       row.add(book.getBookDate());
+                       row.add(book.getClient());
+                       row.add(book.getOffer());
                        tableModel.addRow(row);
                }