Merge branch 'master' of ssh://xp-dev.com/RRRRHHHH_Code
authorpinene <epinzolas001@ikasle.ehu.eus>
Wed, 20 May 2015 16:42:17 +0000 (18:42 +0200)
committerpinene <epinzolas001@ikasle.ehu.eus>
Wed, 20 May 2015 16:42:17 +0000 (18:42 +0200)
Conflicts:
ruralHouses client/src/domain/Owner.java
ruralHouses client/src/domain/RuralHouse.java
ruralHouses client/src/gui/BookRuralHouseConfirmationWindow.java
ruralHouses client/src/gui/ModifyOfferGUI.java
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/domain/Booking.java

49 files changed:
ruralHouses client/src/common/AccountInterface.java
ruralHouses client/src/common/AdminInterface.java
ruralHouses client/src/common/BookingInterface.java
ruralHouses client/src/domain/Administrator.java
ruralHouses client/src/domain/Client.java
ruralHouses client/src/domain/Owner.java
ruralHouses client/src/domain/RuralHouse.java
ruralHouses client/src/gui/AdminMenuGUI.java
ruralHouses client/src/gui/BookRuralHouseConfirmationWindow.java
ruralHouses client/src/gui/DeleteOfferGUI.java
ruralHouses client/src/gui/DeleteOwnerGUI.java [new file with mode: 0644]
ruralHouses client/src/gui/HouseFeaturesGUI.java
ruralHouses client/src/gui/ModifyHouseGUI.java
ruralHouses client/src/gui/ModifyOfferGUI.java
ruralHouses client/src/gui/OwnerRegistrationGUI.java
ruralHouses client/src/gui/listOfAdditionRequestsGUI.java
ruralHouses client/src/gui/listOfBookingRequestsGUI.java
ruralHouses client/src/gui/listOfOffers.java
ruralHouses client/src/gui/listOfOwnerAddittionRequests.java
ruralHouses client/src/gui/listOfRemovalRequestsGUI.java
ruralHouses/config.xml
ruralHouses/src/businessLogic/AccountManager.java
ruralHouses/src/businessLogic/AdminManager.java
ruralHouses/src/businessLogic/BookingManager.java
ruralHouses/src/businessLogic/LoginManager.java
ruralHouses/src/businessLogic/OfferManager.java
ruralHouses/src/common/AccountInterface.java
ruralHouses/src/common/AdminInterface.java
ruralHouses/src/common/BookingInterface.java
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/domain/Account.java
ruralHouses/src/domain/Administrator.java
ruralHouses/src/domain/Booking.java
ruralHouses/src/domain/Client.java
ruralHouses/src/domain/Owner.java
ruralHouses/src/domain/RuralHouse.java
ruralHouses/src/gui/AdminMenuGUI.java
ruralHouses/src/gui/BookRuralHouseConfirmationWindow.java
ruralHouses/src/gui/DeleteOfferGUI.java
ruralHouses/src/gui/DeleteOwnerGUI.java [new file with mode: 0644]
ruralHouses/src/gui/HouseFeaturesGUI.java
ruralHouses/src/gui/ModifyHouseGUI.java
ruralHouses/src/gui/ModifyOfferGUI.java
ruralHouses/src/gui/OwnerRegistrationGUI.java
ruralHouses/src/gui/listOfAdditionRequestsGUI.java
ruralHouses/src/gui/listOfBookingRequestsGUI.java
ruralHouses/src/gui/listOfOffers.java
ruralHouses/src/gui/listOfOwnerAddittionRequests.java
ruralHouses/src/gui/listOfRemovalRequestsGUI.java

index 67e02d4..aee131c 100644 (file)
@@ -3,12 +3,10 @@ package common;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 
-import domain.Account;
-
 public interface AccountInterface extends Remote{
        
 
        public boolean addAccount(int index) throws RemoteException;
        
-       public boolean removeAccount(Account ac) throws RemoteException;
+       public boolean removeAccount(int index) throws RemoteException;
 }
index 5a76296..0f2887e 100644 (file)
@@ -10,27 +10,29 @@ import domain.RuralHouse;
 
 public interface AdminInterface extends Remote {
 
-       
        public Vector<RuralHouse> getAdditionRequests() throws RemoteException;
 
-       public Vector<RuralHouse> getDeletionRequests() throws RemoteException ;
+       public Vector<RuralHouse> getDeletionRequests() throws RemoteException;
 
-       public Vector<Account> getOwnerAdditionRequests() throws RemoteException ;
-       
-       public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException ;
+       public Vector<Account> getOwnerAdditionRequests() throws RemoteException;
 
-       public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException ;
-       
-       public void removeOwnerAdditionRequests(int index) throws RemoteException ;
-       
-       public boolean addAdditionRequest(RuralHouse rh) throws RemoteException ;
+       public Vector<Owner> getAllOwners() throws RemoteException;
+
+       public void removeHouseAdditionRequests(RuralHouse house)
+                       throws RemoteException;
+
+       public void removeHouseDeletionRequests(RuralHouse house)
+                       throws RemoteException;
+
+       public void removeOwnerAdditionRequests(int index) throws RemoteException;
+
+       public boolean addAdditionRequest(RuralHouse rh) throws RemoteException;
+
+       public boolean addDeletionRequest(RuralHouse rh) throws RemoteException;
+
+       public boolean addAccountRequest(String usr, String pss, Owner ow)
+                       throws RemoteException;
 
-       public boolean addDeletionRequest(RuralHouse rh) throws RemoteException ;
-       
-       public boolean addAccountRequest(String usr,
-                       String pss, Owner ow) throws RemoteException;
-       
        public void saveInstance() throws RemoteException;
-       
-       
+
 }
index 0d2db53..598a537 100644 (file)
@@ -15,7 +15,7 @@ public interface BookingInterface extends Remote {
 
 
 
-       public void removeDenyBooking(Booking b) throws RemoteException;
+       public void denyBooking(Booking b) throws RemoteException;
 
 
        public void acceptBooking(Booking b) throws RemoteException;
index 0d516c5..d1ea781 100644 (file)
@@ -24,7 +24,7 @@ public class Administrator implements Serializable {
                newOwnerRequest = new LinkedList<Account>();
        }
 
-
+       
        public LinkedList<RuralHouse> getAddRequest() {
                return addRequest;
        }
index 4dd9eb2..a4c0baf 100644 (file)
@@ -1,7 +1,13 @@
 package domain;
 
-public class Client {
+import java.io.Serializable;
 
+public class Client  implements Serializable{
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private String name;
        private String mailAccount;
        private String telephone;
index eb436f9..6bf0f97 100644 (file)
@@ -14,10 +14,6 @@ public class Owner implements Serializable {
        private String mailAccount = "";
        private Vector<RuralHouse> ruralHouses;
 
-//     public Owner(String name) {
-//             this.name = name;
-//             ruralHouses = new hVector<RuralHouse>();
-//     }
 
        public Owner(String name, String bankAccount,String mail) {
                this.bankAccount = bankAccount;
index 27f8d7f..0c7fbb7 100644 (file)
@@ -16,6 +16,7 @@ public class RuralHouse implements Serializable {
        private HouseFeatures features;
        public Vector<Offer> offers;
 
+
        public RuralHouse() {
                super();
        }
@@ -120,4 +121,5 @@ public class RuralHouse implements Serializable {
                return this.offers;
        }
 
+
 }
index eef2ba4..24dcb27 100644 (file)
@@ -4,8 +4,6 @@ import java.awt.Frame;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JPanel;
@@ -29,12 +27,13 @@ public class AdminMenuGUI extends JFrame {
                
                this.setTitle("Administrator Menu");
                this.getContentPane().setLayout(null);
-               setBounds(100, 100, 450, 473);
+               setBounds(100, 100, 450, 500);
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                //TODO BOTH BUTTONS ARE TO MODIFY
                JButton btnAdd = new JButton("Add requests");
+               btnAdd.setBounds(120, 67, 164, 81);
                btnAdd.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfAdditionRequestsGUI();
@@ -43,6 +42,7 @@ public class AdminMenuGUI extends JFrame {
                });
                
                JButton btnDel = new JButton("Delete Requests");
+               btnDel.setBounds(120, 159, 164, 73);
                btnDel.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfRemovalRequestsGUI();
@@ -51,34 +51,26 @@ public class AdminMenuGUI extends JFrame {
                });
                
                JButton btnOwneraddition = new JButton("OwnerAddition");
+               btnOwneraddition.setBounds(120, 243, 164, 73);
                btnOwneraddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfOwnerAddittionRequests();
                                a.setVisible(true);
                        }
                });
-               GroupLayout gl_contentPane = new GroupLayout(contentPane);
-               gl_contentPane.setHorizontalGroup(
-                       gl_contentPane.createParallelGroup(Alignment.LEADING)
-                               .addGroup(gl_contentPane.createSequentialGroup()
-                                       .addGap(115)
-                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
-                                               .addComponent(btnOwneraddition, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                                               .addComponent(btnDel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
-                                               .addComponent(btnAdd, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))
-                                       .addContainerGap(145, Short.MAX_VALUE))
-               );
-               gl_contentPane.setVerticalGroup(
-                       gl_contentPane.createParallelGroup(Alignment.LEADING)
-                               .addGroup(gl_contentPane.createSequentialGroup()
-                                       .addGap(62)
-                                       .addComponent(btnAdd, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
-                                       .addGap(58)
-                                       .addComponent(btnDel, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
-                                       .addGap(52)
-                                       .addComponent(btnOwneraddition, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
-                                       .addContainerGap())
-               );
-               contentPane.setLayout(gl_contentPane);
+               contentPane.setLayout(null);
+               contentPane.add(btnOwneraddition);
+               contentPane.add(btnDel);
+               contentPane.add(btnAdd);
+       
+               JButton btnOwnerDeletion = new JButton("Owner Deletion");
+               btnOwnerDeletion.setBounds(120, 331, 164, 73);
+               btnOwnerDeletion.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               Frame a = new DeleteOwnerGUI();
+                               a.setVisible(true);
+                       }
+               });
+               contentPane.add(btnOwnerDeletion);
        }
 }
index c26d9df..21f9ab6 100644 (file)
@@ -79,10 +79,11 @@ public class BookRuralHouseConfirmationWindow extends JFrame {
     jTextField3.setBounds(new Rectangle(180, 140, 115, 25));
     jTextField3.setEditable(false);
 
-    jTextField3.setText(Float.toString(book.getOffer().getPrice()) + " ï¿½");
+    jTextField3.setText(Float.toString(book.getOffer().getPrice()) + " \80");
     jTextField4.setBounds(new Rectangle(180, 175, 115, 25));
     jTextField4.setEditable(false);
-    jTextField4.setText(Float.toString(book.getOffer().getPrice()*(float)0.2) + " ï¿½");
+    jTextField4.setText(Float.toString(book.getOffer().getPrice()*(float)0.2) + " \80");
+
     this.getContentPane().add(jTextField4, null);
     this.getContentPane().add(jTextField3, null);
     this.getContentPane().add(jLabel5, null);
index d3a79e4..d9f5ab8 100644 (file)
@@ -5,6 +5,7 @@ import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.rmi.Naming;
+import java.rmi.RemoteException;
 import java.util.Vector;
 
 import javax.swing.JButton;
@@ -15,6 +16,7 @@ import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.border.EmptyBorder;
 
+import common.HouseInterface;
 import common.OfferInterface;
 
 import configuration.___IntNames;
@@ -29,28 +31,40 @@ public class DeleteOfferGUI extends JFrame {
         */
        private static final long serialVersionUID = 1L;
        private JPanel contentPane;
-       private Owner owner;
        private JLabel feedback;
        private JComboBox<RuralHouse> comboBox;
        private JComboBox<Offer> comboBox_1;
        private JButton btnDelete;
+       private Vector<RuralHouse> Hlist = null;
+       private HouseInterface hm = null;
 
        /**
         * Create the frame.
         */
        public DeleteOfferGUI(Owner o) {
-               this.owner = o;
+               try {
+                       hm = (HouseInterface) Naming
+                                       .lookup(___IntNames.HouseManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               try {
+                       Hlist = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
+               } catch (RemoteException e1) {
+                       e1.printStackTrace();
+               }       
                setBounds(100, 100, 450, 300);
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
 
-               comboBox = new JComboBox<RuralHouse>(this.owner.getRuralHouses());
+               comboBox = new JComboBox<RuralHouse>(this.Hlist);
                comboBox.setBounds(101, 38, 314, 20);
 
                comboBox_1 = new JComboBox<Offer>();
                comboBox_1.setBounds(101, 76, 314, 20);
-               Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).offers;
+               Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).getAllOffers();
                comboBox_1.removeAllItems();
                for (Offer of : vo) {
                        comboBox_1.addItem(of);
@@ -68,7 +82,7 @@ public class DeleteOfferGUI extends JFrame {
 
                        @Override
                        public void itemStateChanged(ItemEvent arg0) {
-                               Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).offers;
+                               Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).getAllOffers();
                                comboBox_1.removeAllItems();
                                for (Offer of : vo) {
                                        comboBox_1.addItem(of);
diff --git a/ruralHouses client/src/gui/DeleteOwnerGUI.java b/ruralHouses client/src/gui/DeleteOwnerGUI.java
new file mode 100644 (file)
index 0000000..982e022
--- /dev/null
@@ -0,0 +1,139 @@
+package gui;
+
+import java.awt.Font;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableModel;
+
+import common.AccountInterface;
+import common.AdminInterface;
+
+import configuration.___IntNames;
+import domain.Owner;
+
+public class DeleteOwnerGUI extends JFrame {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private JPanel contentPane;
+       private JTable table;
+
+       private DefaultTableModel tableModel;
+       private AdminInterface AdM = null;
+       private Vector<Owner> owners = new Vector<Owner>();
+
+       /**
+        * Create the frame.
+        */
+       public DeleteOwnerGUI() {
+               setTitle("Current owners:");
+               try {
+                       init();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       private void init() throws Exception {
+               setBounds(100, 100, 600, 500);
+               contentPane = new JPanel();
+               contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
+               setContentPane(contentPane);
+               contentPane.setLayout(null);
+               try {
+                       AdM = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out
+                                       .println("Error accessing remote authentication: "
+                                                       + e1.toString());
+               }
+               this.owners = AdM.getAllOwners();
+               JLabel lblNewLabel = new JLabel();
+               lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
+               lblNewLabel.setBounds(23, 41, 536, 33);
+               contentPane.add(lblNewLabel);
+               if (this.owners.isEmpty())
+                       lblNewLabel
+                                       .setText("There are not owners in the system");
+               else
+                       lblNewLabel.setText("List of owners:");
+               JScrollPane scrollPane = new JScrollPane();
+               scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
+               scrollPane.setBounds(23, 113, 536, 271);
+               contentPane.add(scrollPane);
+               final JLabel feedback = new JLabel("");
+               feedback.setBounds(134, 447, 307, 14);
+               contentPane.add(feedback);
+               JButton btnNewButton = new JButton("Delete from the system");
+               btnNewButton.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
+                                       AccountInterface acm = null;
+                                       
+                                       try {
+                                               acm = (AccountInterface) Naming
+                                                               .lookup(___IntNames.AccountManager);
+                                       } catch (Exception e1) {
+                                               System.out.println("Error accessing remote authentication: "
+                                                               + e1.toString());
+                                       }
+
+                                       try {
+                                               if(acm.removeAccount(table.getSelectedRow()))
+                                                       {
+                                                       feedback.setText("Deleted from the system");
+                                                       }
+                                       } catch (RemoteException e1) {
+                                               e1.printStackTrace();
+                                       }
+                                       
+                                       ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
+                               }
+                       }
+               });
+               btnNewButton.setBounds(88, 396, 428, 40);
+               contentPane.add(btnNewButton);
+               table = new JTable() {
+                       private static final long serialVersionUID = 1L;
+
+                       public boolean isCellEditable(int row, int column) {
+                               return false;
+                       };
+               };
+               
+               scrollPane.setViewportView(table);      
+               tableModel = new DefaultTableModel(null, new String[] {
+                               "Name", "E-mail", "Bank Account" });
+
+               table.setModel(tableModel);
+               
+               
+               Enumeration<Owner> rhs = this.owners.elements();
+               while (rhs.hasMoreElements()) {
+                       Owner own = rhs.nextElement();
+                       Vector<Object> row = new Vector<Object>();
+                       row.add(own.getName());
+                       row.add(own.getMailAccount());
+                       row.add(own.getBankAccount());
+                       tableModel.addRow(row);
+               }
+               
+               
+       }
+}
index 62e81e9..39d0bc9 100644 (file)
@@ -55,6 +55,7 @@ public class HouseFeaturesGUI extends JFrame {
        private JTable table;
        private DefaultTableModel tableModel;
        private RuralHouse rh;
+       private Vector<Offer> offers= new Vector<Offer>();
        private JTextField telIn;
        private int row;
        private JLabel labelPhone;
@@ -238,7 +239,9 @@ public class HouseFeaturesGUI extends JFrame {
                Enumeration<Offer> rhs = rh.getAllOffers().elements();
                while (rhs.hasMoreElements()) {
                        Offer of = rhs.nextElement();
-                       if (of.getBookings() != null) {
+                       if (of.getBookings() == null
+                                       || !of.isBooked()) {
+                               offers.add(of);
                                Vector<Object> row = new Vector<Object>();
                                row.add(of.getOfferNumber());
                                row.add(of.getFirstDay());
@@ -300,8 +303,8 @@ public class HouseFeaturesGUI extends JFrame {
                                if (table.getRowCount() != 0) {
                                        Client cl = new Client(nameField.getText(),
                                                        mailField.getText(), telIn.getText());
-                                       book = bookingM.createBooking(rh, rh.offers.get(row)
-                                                       .getFirstDay(), rh.offers.get(row).getLastDay(),cl);
+                                       book = bookingM.createBooking(rh, offers.get(row)
+                                                       .getFirstDay(), offers.get(row).getLastDay(),cl);
                                }
                        } catch (Exception e) {
                                e.printStackTrace();
index 691b0ca..d5db84c 100644 (file)
@@ -19,6 +19,7 @@ import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
 import common.HouseInterface;
+
 import configuration.___IntNames;
 import domain.Districs;
 import domain.HouseFeatures;
index d5422bf..3e7a6c6 100644 (file)
@@ -26,9 +26,9 @@ import javax.swing.JLabel;
 import javax.swing.JTextField;
 
 import com.toedter.calendar.JCalendar;
-
 import common.HouseInterface;
 import common.OfferInterface;
+
 import configuration.___IntNames;
 import domain.Offer;
 import domain.Owner;
@@ -91,7 +91,7 @@ public class ModifyOfferGUI extends JFrame {
                        e1.printStackTrace();
                }
 
-               
+
                jComboBox1 = new JComboBox<RuralHouse>(Hlist);
 
                comboBox_o = new JComboBox<Offer>(
@@ -146,6 +146,7 @@ public class ModifyOfferGUI extends JFrame {
 
                        @Override
                        public void itemStateChanged(ItemEvent arg0) {
+
                                Vector<Offer> vo= null;
                                try {
                                        vo = om.getRuralHouseOffers((RuralHouse) jComboBox1.getSelectedItem());
index 5a4ffe9..62395d5 100644 (file)
@@ -41,10 +41,9 @@ public class OwnerRegistrationGUI extends JFrame {
         * Create the frame.
         */
        public OwnerRegistrationGUI() {
-               
+
                try {
-                       am = (AdminInterface) Naming
-                                       .lookup(___IntNames.AdminManager);
+                       am = (AdminInterface) Naming.lookup(___IntNames.AdminManager);
                } catch (Exception e1) {
                        System.out.println("Error accessing remote authentication: "
                                        + e1.toString());
@@ -139,23 +138,32 @@ public class OwnerRegistrationGUI extends JFrame {
 
        private void jButton_ActionPerformed(ActionEvent e) {
 
-               Owner own = new Owner(this.nameField.getText(),
-                               this.bank1Field.getText() + " " + this.bank2Field.getText()
-                                               + " " + this.bank3Field.getText() + " "
-                                               + this.bank4Field.getText(), this.emailField.getText());
-
-
-               try {
-                       if (this.am.addAccountRequest(this.userNameField.getText(),
-                                       this.passField.getText(), own)) {
-                               this.am.saveInstance();
-                               this.feedback.setText("Request sended");
-                       } else {
-                               this.feedback.setText("Can't send the request");
+               if (!emailField
+                               .getText()
+                               .matches(
+                                               "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")
+                               || !this.nameField.getText().isEmpty()||this.bank1Field.getText().length()!=4 || this.bank2Field.getText().length()!=4
+                               ||this.bank3Field.getText().length()!=2 || this.bank4Field.getText().length()!=10) {
+                       Owner own = new Owner(this.nameField.getText(),
+                                       this.bank1Field.getText() + " " + this.bank2Field.getText()
+                                                       + " " + this.bank3Field.getText() + " "
+                                                       + this.bank4Field.getText(),
+                                       this.emailField.getText());
+
+                       try {
+                               if (this.am.addAccountRequest(this.userNameField.getText(),
+                                               this.passField.getText(), own)) {
+                                       this.am.saveInstance();
+                                       this.feedback.setText("Request sended");
+                               } else {
+                                       this.feedback.setText("Can't send the request");
+                               }
+                       } catch (RemoteException e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
                        }
-               } catch (RemoteException e1) {
-                       // TODO Auto-generated catch block
-                       e1.printStackTrace();
+               } else {
+                       this.feedback.setText("Bad formatted data");
                }
 
        }
index d112532..30e5e66 100644 (file)
@@ -118,7 +118,6 @@ public class listOfAdditionRequestsGUI extends JFrame {
                                        }
                                        
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                       houses.remove(rh);
                                }
                        }
                });
index 982d7f2..423ea4d 100644 (file)
@@ -1,9 +1,12 @@
 package gui;
 
+import java.awt.Color;
+import java.awt.Component;
 import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.Naming;
 import java.rmi.RemoteException;
 import java.util.Enumeration;
 import java.util.Vector;
@@ -15,10 +18,12 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 
 import common.BookingInterface;
 
+import configuration.___IntNames;
 import domain.Booking;
 import domain.Offer;
 
@@ -31,7 +36,7 @@ public class listOfBookingRequestsGUI extends JFrame {
        private JPanel contentPane;
        private JTable table;
        private Offer off;
-       private BookingInterface bookM =null;
+       private BookingInterface bookM = null;
        private DefaultTableModel tableModel;
        private Vector<Booking> bookings = new Vector<Booking>();
 
@@ -56,17 +61,12 @@ public class listOfBookingRequestsGUI extends JFrame {
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                contentPane.setLayout(null);
-               
-               this.bookings= this.off.getBookings();
+
+               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 (bookings.isEmpty())
-                       lblNewLabel
-                                       .setText("There are not bookings to be confirmed or denied");
-               else
-                       lblNewLabel.setText("List of bookings:");
                JScrollPane scrollPane = new JScrollPane();
                scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
                scrollPane.setBounds(23, 113, 536, 271);
@@ -80,24 +80,34 @@ public class listOfBookingRequestsGUI extends JFrame {
                        };
                };
                scrollPane.setViewportView(table);
-               tableModel = new DefaultTableModel(null, new String[] {
-                               "Booking Number", "Booking Date","Name","E-mail", "Telephone" });
+               tableModel = new DefaultTableModel(null,
+                               new String[] { "Booking Number", "Booking Date", "Name",
+                                               "E-mail", "Telephone" });
 
-               // Maybe there is a better way to avoid interaction.
-               // table.setEnabled(false);
                table.setModel(tableModel);
 
                JButton btnNewButton = new JButton("Confirm Booking");
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
+                               try {
+                                       bookM = (BookingInterface) Naming
+                                                       .lookup(___IntNames.BookingManager);
+                               } catch (Exception e1) {
+                                       System.out
+                                                       .println("Error accessing remote authentication: "
+                                                                       + e1.toString());
+                               }
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
-                                       if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
+                                       if (table.getRowCount() != 0
+                                                       && table.getSelectedRow() != -1) {
                                                Booking book = bookings.get(table.getSelectedRow());
                                                try {
                                                        bookM.acceptBooking(book);
                                                } catch (RemoteException e1) {
                                                        e1.printStackTrace();
                                                }
+                                               contentPane.setVisible(false);
+
                                        }
 
                                }
@@ -109,20 +119,42 @@ public class listOfBookingRequestsGUI extends JFrame {
                JButton btnDenyAddition = new JButton("Deny Booking");
                btnDenyAddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
+                               try {
+                                       bookM = (BookingInterface) Naming
+                                                       .lookup(___IntNames.BookingManager);
+                               } catch (Exception e1) {
+                                       System.out
+                                                       .println("Error accessing remote authentication: "
+                                                                       + e1.toString());
+                               }
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        Booking book = bookings.get(table.getSelectedRow());
                                        try {
-                                               bookM.removeDenyBooking(book);
+                                               bookM.denyBooking(book);
                                        } catch (RemoteException e) {
                                                e.printStackTrace();
                                        }
+                                       ((DefaultTableModel) table.getModel()).removeRow(table
+                                                       .getSelectedRow());
+                                       bookings.remove(book);
 
                                }
                        }
                });
+               if (bookings.isEmpty())
+                       lblNewLabel
+                                       .setText("There are not bookings to be confirmed or denied");
+               else {
+                       lblNewLabel.setText("List of bookings:");
+                       if (this.bookings.get(0).getOffer().isBooked()) {
+                               btnDenyAddition.setEnabled(false);
+                               btnNewButton.setEnabled(false);
+                       }
+               }
+               
                btnDenyAddition.setBounds(390, 395, 169, 25);
                contentPane.add(btnDenyAddition);
-               
+
                Enumeration<Booking> en = this.bookings.elements();
                Booking book;
                while (en.hasMoreElements()) {
@@ -135,6 +167,31 @@ public class listOfBookingRequestsGUI extends JFrame {
                        row.add(book.getClient().getTelephone());
                        tableModel.addRow(row);
                }
+               table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
+                       /**
+                        * 
+                        */
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       public Component getTableCellRendererComponent(JTable table,
+                                       Object value, boolean isSelected, boolean hasFocus,
+                                       int row, int col) {
 
+                               super.getTableCellRendererComponent(table, value, isSelected,
+                                               hasFocus, row, col);
+
+                               if (!bookings.get(row).getOffer().isBooked()) {
+                                       setBackground(Color.RED);
+                                       setForeground(Color.BLACK);
+                               } else {
+                                       setBackground(Color.GREEN);
+                                       setForeground(Color.BLACK);
+                               }
+
+                               return this;
+                       }
+               });
        }
+
 }
index 1a49f1c..7d61def 100644 (file)
@@ -1,5 +1,7 @@
 package gui;
 
+import java.awt.Color;
+import java.awt.Component;
 import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.MouseAdapter;
@@ -13,6 +15,7 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 
 import domain.Offer;
@@ -103,8 +106,33 @@ public class listOfOffers extends JFrame {
                        row.add(of.getPrice());
                        row.add(of.getRuralHouse().getHouseName());
                        tableModel.addRow(row);
-
                }
+               
+               table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
+                       /**
+                        * 
+                        */
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       public Component getTableCellRendererComponent(JTable table,
+                                       Object value, boolean isSelected, boolean hasFocus,
+                                       int row, int col) {
+
+                               super.getTableCellRendererComponent(table, value, isSelected,
+                                               hasFocus, row, col);
+
+                               if (!offers.get(row).isBooked()) {
+                                       setBackground(Color.ORANGE);
+                                       setForeground(Color.BLACK);
+                               } else {
+                                       setBackground(Color.GREEN);
+                                       setForeground(Color.BLACK);
+                               }
+
+                               return this;
+                       }
+               });
 
        }
 }
index 01aaf8f..b3297b4 100644 (file)
@@ -117,8 +117,9 @@ public class listOfOwnerAddittionRequests extends JFrame {
                                        } catch (RemoteException e1) {
                                                e1.printStackTrace();
                                        }
-                       
+                                       
                                        ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
+                                       
                                }
                        }
                });
index 62daded..a85c246 100644 (file)
@@ -41,8 +41,7 @@ public class listOfRemovalRequestsGUI extends JFrame {
         */
        public listOfRemovalRequestsGUI() {
                try {
-                       am = (AdminInterface) Naming
-                                       .lookup(___IntNames.AdminManager);
+                       am = (AdminInterface) Naming.lookup(___IntNames.AdminManager);
                } catch (Exception e1) {
                        System.out.println("Error accessing remote authentication: "
                                        + e1.toString());
@@ -94,51 +93,50 @@ public class listOfRemovalRequestsGUI extends JFrame {
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
-                                       HouseInterface hm= null;
+                                       HouseInterface hm = null;
                                        try {
                                                hm = (HouseInterface) Naming
                                                                .lookup(___IntNames.HouseManager);
                                        } catch (Exception e1) {
-                                               System.out.println("Error accessing remote authentication: "
-                                                               + e1.toString());
+                                               System.out
+                                                               .println("Error accessing remote authentication: "
+                                                                               + e1.toString());
                                        }
                                        RuralHouse rh = houses.get(table.getSelectedRow());
-                                       ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                               try {
-                                                       hm.removeHouse(rh, rh.getOwner());
-                                                       am.removeHouseDeletionRequests(rh);
-                                                       am.saveInstance();
-                                               } catch (RemoteException e1) {
-                                                       // TODO Auto-generated catch block
-                                                       e1.printStackTrace();
-                                               }
-                                               houses.remove(rh);
-                                               
-
-                                       
+
+                                       try {
+                                               hm.removeHouse(rh, rh.getOwner());
+                                               am.removeHouseDeletionRequests(rh);
+                                               am.saveInstance();
+                                       } catch (RemoteException e1) {
+                                               e1.printStackTrace();
+                                       }
+                                       ((DefaultTableModel) table.getModel()).removeRow(houses
+                                                       .indexOf(rh));
+                                       houses.remove(rh);
+
                                }
                        }
                });
                btnNewButton.setBounds(90, 396, 169, 25);
                contentPane.add(btnNewButton);
-               
+
                JButton btnNewButton_1 = new JButton("Deny Deletion");
                btnNewButton_1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        RuralHouse rh = houses.get(table.getSelectedRow());
-                                       ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                               houses.remove(rh);
-                                               try {
-                                                       am.removeHouseDeletionRequests(rh);
-                                                       am.saveInstance();
-                                               } catch (RemoteException e1) {
-                                                       // TODO Auto-generated catch block
-                                                       e1.printStackTrace();
-                                               }
-                                               
-
-                                       
+                                       ((DefaultTableModel) table.getModel()).removeRow(houses
+                                                       .indexOf(rh));
+                                       houses.remove(rh);
+                                       try {
+                                               am.removeHouseDeletionRequests(rh);
+                                               am.saveInstance();
+                                       } catch (RemoteException e1) {
+                                               // TODO Auto-generated catch block
+                                               e1.printStackTrace();
+                                       }
+
                                }
                        }
                });
index 9099bad..0ce7502 100644 (file)
@@ -10,7 +10,7 @@
        <db4oFilename>db/casas.db4o</db4oFilename>
        <dataBaseOpenMode>initialize</dataBaseOpenMode>
        <activationDepth>10</activationDepth>
-       <updateDepth>8</updateDepth>
+       <updateDepth>10</updateDepth>
        <databasePort>8100</databasePort>
        <user>softEng</user>
        <password>i4softwEngin2matx</password>
index ae57126..705ef27 100644 (file)
@@ -43,9 +43,14 @@ public class AccountManager extends UnicastRemoteObject implements AccountInterf
                
        }
        
-       public boolean removeAccount(Account ac)throws RemoteException {
-               if(this.dbMngr.removeAccount(ac))
-                       return true;
+       public boolean removeAccount(int index)throws RemoteException {
+               AdminManager adm = new AdminManager();
+               try {
+                       if(this.dbMngr.removeAccount(adm.getAllOwners().get(index)))
+                               return true;
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
                return false;
                
        }
index 688cc9c..a7e3a2a 100644 (file)
@@ -6,6 +6,7 @@ import java.util.Vector;
 
 import common.AdminInterface;
 
+import dataAccess.DB4oManager;
 import domain.Account;
 import domain.Administrator;
 import domain.Owner;
@@ -39,6 +40,14 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
                                .getNewOwnerRequest());
        }
        
+       public Vector<Owner> getAllOwners()throws RemoteException {
+               try {
+                       return new Vector<Owner>(DB4oManager.getInstance().getOwners());
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               return null;
+       }
        public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException {
                Administrator.getInstance().getAddRequest().remove(house);
        }
index 985bf56..138484b 100644 (file)
@@ -5,6 +5,8 @@ import java.rmi.server.UnicastRemoteObject;
 import java.util.Date;
 import java.util.Vector;
 
+import javax.mail.MessagingException;
+
 import com.db4o.ObjectContainer;
 import com.db4o.ObjectSet;
 import common.BookingInterface;
@@ -37,25 +39,21 @@ public final class BookingManager extends UnicastRemoteObject implements Booking
 
        
 
-       public void removeDenyBooking(Booking b) throws RemoteException{
-                               b.getOffer().getBookings().remove(b);
+       public void denyBooking(Booking b) throws RemoteException{
                                this.dbMngr.removeBooking(b);
        }
 
 
        public void acceptBooking(Booking b) throws RemoteException{
                b.getOffer().setBooked(true);
-               for(Booking boo : b.getOffer().getBookings()){
-                       if(!boo.equals(b))
-                               b.getOffer().getBookings().remove(b);
-               }
+               b.getOffer().getBookings().clear();
+               b.getOffer().getBookings().add(b);
                this.dbMngr.acceptBooking(b.getOffer());
-               /*try {
+               try {
                        MailManager.getInstance().Send(b.getClient().getMailAccount(), "Your booking has been accepted","Here should be the bill");
                } catch (MessagingException e) {
-                       // TODO Auto-generated catch block
                        e.printStackTrace();
-               }*/
+               }
                
        }
        /**
index e0f0439..f3c4600 100644 (file)
@@ -24,7 +24,6 @@ public class LoginManager extends UnicastRemoteObject implements LoginInterface
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
-                       // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
index cfe7276..12279a3 100644 (file)
@@ -56,7 +56,7 @@ public final class OfferManager extends UnicastRemoteObject implements OfferInte
 
        
        public void deleteOffer(RuralHouse rh, Offer o) throws RemoteException, Exception{
-               rh.offers.removeElement(o);
+               rh.getAllOffers().removeElement(o);
                dbMngr.deleteOffer( o);
        }
 
index 67e02d4..aee131c 100644 (file)
@@ -3,12 +3,10 @@ package common;
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 
-import domain.Account;
-
 public interface AccountInterface extends Remote{
        
 
        public boolean addAccount(int index) throws RemoteException;
        
-       public boolean removeAccount(Account ac) throws RemoteException;
+       public boolean removeAccount(int index) throws RemoteException;
 }
index 5a76296..7e3289f 100644 (file)
@@ -17,6 +17,8 @@ public interface AdminInterface extends Remote {
 
        public Vector<Account> getOwnerAdditionRequests() throws RemoteException ;
        
+       public Vector<Owner> getAllOwners()throws RemoteException ;
+       
        public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException ;
 
        public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException ;
index 0d2db53..598a537 100644 (file)
@@ -15,7 +15,7 @@ public interface BookingInterface extends Remote {
 
 
 
-       public void removeDenyBooking(Booking b) throws RemoteException;
+       public void denyBooking(Booking b) throws RemoteException;
 
 
        public void acceptBooking(Booking b) throws RemoteException;
index baab98a..d17876f 100644 (file)
@@ -81,11 +81,19 @@ public class DB4oManager {
                configuration = Db4oEmbedded.newConfiguration();
                configuration.common().activationDepth(c.getActivationDepth());
                configuration.common().updateDepth(c.getUpdateDepth());
-               configuration.common().objectClass(Owner.class).cascadeOnUpdate(true);
                configuration.common().objectClass(Owner.class).cascadeOnDelete(true);
+               configuration.common().objectClass(Booking.class).cascadeOnDelete(true);
+               configuration.common().objectClass(RuralHouse.class)
+                               .cascadeOnDelete(true);
+               configuration.common().objectClass(Account.class).cascadeOnDelete(true);
+               configuration.common().objectClass(Offer.class).cascadeOnDelete(true);
+               configuration.common().objectClass(Owner.class).cascadeOnUpdate(true);
+               configuration.common().objectClass(Booking.class).cascadeOnUpdate(true);
                configuration.common().objectClass(RuralHouse.class)
                                .cascadeOnUpdate(true);
                configuration.common().objectClass(Account.class).cascadeOnUpdate(true);
+               configuration.common().objectClass(Offer.class).cascadeOnUpdate(true);
+               configuration.common().objectClass(Account.class).cascadeOnUpdate(true);
                db = Db4oEmbedded.openFile(configuration, c.getDb4oFilename());
        }
 
@@ -207,7 +215,7 @@ public class DB4oManager {
                try {
                        ObjectSet<Offer> of = db.queryByExample(offer);
                        RuralHouse rh = of.get(0).getRuralHouse();
-                       System.out.println(rh.offers.remove(of.get(0)));
+                       System.out.println(rh.getAllOffers().remove(of.get(0)));
                        db.store(rh);
                        db.commit();
 
@@ -219,14 +227,15 @@ public class DB4oManager {
                }
        }
 
-       public Vector<Offer> getRHsOffer(String name){
+       public Vector<Offer> getRHsOffer(String name) {
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                        openDB();
 
                try {
-                       RuralHouse rh = (RuralHouse)db.queryByExample(new RuralHouse(name, null, null, null, null)).get(0);
+                       RuralHouse rh = (RuralHouse) db.queryByExample(
+                                       new RuralHouse(name, null, null, null, null)).get(0);
                        Offer proto = new Offer(0, rh, null, null, 0);
                        ObjectSet<Offer> result = db.queryByExample(proto);
                        return new Vector<Offer>(result);
@@ -234,8 +243,8 @@ public class DB4oManager {
                        db.close();
                }
        }
-       
-       public Administrator getAdminData(){
+
+       public Administrator getAdminData() {
 
                if (c.isDatabaseLocal() == false)
                        openSDB();
@@ -371,6 +380,8 @@ public class DB4oManager {
                }
        }
 
+
+
        public boolean existsOverlappingOffer(RuralHouse rh, Date firstDay,
                        Date lastDay) throws RemoteException, OverlappingOfferExists {
 
@@ -486,8 +497,8 @@ public class DB4oManager {
 
        }
 
-       public Vector<RuralHouse> getRuralHouses(Owner ow, String name, String town,
-                       int nBed, int nKit, int nBath, int nPark, int nLiv) {
+       public Vector<RuralHouse> getRuralHouses(Owner ow, String name,
+                       String town, int nBed, int nKit, int nBath, int nPark, int nLiv) {
                HouseFeatures fea = new HouseFeatures(nBed, nKit, nBath, nLiv, nPark);
                RuralHouse rh = new RuralHouse(name, ow, null, town, fea);
                if (c.isDatabaseLocal() == false)
@@ -530,20 +541,16 @@ public class DB4oManager {
                return false;
        }
 
-       // TODO remove account
-
-       public boolean removeAccount(Account acc) {
+       public boolean removeAccount(Owner own) {
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
                        openDB();
 
                try {
-                       ObjectSet<Account> result = db.queryByExample(new Account(acc
-                                       .getUsername()));
+                       ObjectSet<Account> result = db.queryByExample(new Account(null,null,own));
                        if (!result.isEmpty()) {
                                db.delete(result.get(0));
-                               ;
                                db.commit();
                                return true;
                        }
@@ -555,10 +562,10 @@ public class DB4oManager {
                return false;
        }
 
-       // TODO this method should be improved.
        public void acceptBooking(Offer of) {
-               Offer off = new Offer(of.getOfferNumber(), of.getRuralHouse(),
-                               of.getFirstDay(), of.getLastDay(), of.getPrice());
+               Offer off = new Offer(of.getOfferNumber(), new RuralHouse(of
+                               .getRuralHouse().getHouseName(), null, null, null, null), null,
+                               null, 0);
                if (c.isDatabaseLocal() == false)
                        openSDB();
                else
@@ -566,8 +573,12 @@ public class DB4oManager {
 
                try {
                        ObjectSet<Offer> result = db.queryByExample(off);
-                       this.deleteOffer(result.get(0));
-                       db.store(of);
+                       db.delete(result.get(0));
+                       RuralHouse rh = result.get(0).getRuralHouse();
+                       of.setRuralHouse(rh);
+                       rh.getAllOffers().remove(result.get(0));
+                       rh.getAllOffers().add(of);
+                       db.store(rh);
                        db.close();
 
                } catch (Exception e) {
@@ -582,14 +593,15 @@ public class DB4oManager {
                else
                        openDB();
                try {
-                       ObjectSet<Booking> result = db.queryByExample(b);
-                       ObjectSet<Client> result2 = db.queryByExample(b.getClient());
-                       db.delete(result.get(0));
-                       db.delete(result2.get(0));
+                       Booking book = new Booking(b.getBookNumber(), new Offer(b
+                                       .getOffer().getOfferNumber(), new RuralHouse(b.getOffer()
+                                       .getRuralHouse().getHouseName(), null, null, null, null),
+                                       null, null, 0), b.getClient(), b.getBookDate());
+                       book.setOffer(null);
+                       db.delete(book);
                        db.commit();
                } catch (Exception e) {
                        e.printStackTrace();
-                       ;
                } finally {
                        db.close();
                }
index ff19267..7fb472c 100644 (file)
@@ -2,9 +2,9 @@ package domain;
 
 import java.io.Serializable;
 import java.util.Arrays;
-
 import businessLogic.SecurityManager;
 
+
 public class Account implements Serializable {
 
        /**
@@ -21,7 +21,6 @@ public class Account implements Serializable {
        private Owner owner;
        private boolean admin = false;
 
-       
        public Account(byte[] usr){
                this.username = usr;
                this.salt =null;
@@ -48,7 +47,9 @@ public class Account implements Serializable {
 
        }
 
+
        
+
        public byte[] getUsername() {
                return username;
        }
index 8244f09..eb42f26 100644 (file)
@@ -55,6 +55,7 @@ public class Administrator implements Serializable {
                }
        }
 
+       
        public LinkedList<RuralHouse> getAddRequest() {
                return addRequest;
        }
index 68575c6..4b68a70 100644 (file)
@@ -26,6 +26,13 @@ public class Booking implements Serializable  {
        }
        
 
+       public Booking(int bN , Offer offer,Client client, Date bookDate) {
+               this.bookingNumber = bN;
+               this.offer = offer;
+               this.client=client;
+               this.bookingDate= bookDate;     }
+
+
        public int getBookNumber() {
                return this.bookingNumber;
        }
index 4dd9eb2..a4c0baf 100644 (file)
@@ -1,7 +1,13 @@
 package domain;
 
-public class Client {
+import java.io.Serializable;
 
+public class Client  implements Serializable{
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private String name;
        private String mailAccount;
        private String telephone;
index eb436f9..6bf0f97 100644 (file)
@@ -14,10 +14,6 @@ public class Owner implements Serializable {
        private String mailAccount = "";
        private Vector<RuralHouse> ruralHouses;
 
-//     public Owner(String name) {
-//             this.name = name;
-//             ruralHouses = new hVector<RuralHouse>();
-//     }
 
        public Owner(String name, String bankAccount,String mail) {
                this.bankAccount = bankAccount;
index 27f8d7f..0c7fbb7 100644 (file)
@@ -16,6 +16,7 @@ public class RuralHouse implements Serializable {
        private HouseFeatures features;
        public Vector<Offer> offers;
 
+
        public RuralHouse() {
                super();
        }
@@ -120,4 +121,5 @@ public class RuralHouse implements Serializable {
                return this.offers;
        }
 
+
 }
index eef2ba4..24dcb27 100644 (file)
@@ -4,8 +4,6 @@ import java.awt.Frame;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JPanel;
@@ -29,12 +27,13 @@ public class AdminMenuGUI extends JFrame {
                
                this.setTitle("Administrator Menu");
                this.getContentPane().setLayout(null);
-               setBounds(100, 100, 450, 473);
+               setBounds(100, 100, 450, 500);
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                //TODO BOTH BUTTONS ARE TO MODIFY
                JButton btnAdd = new JButton("Add requests");
+               btnAdd.setBounds(120, 67, 164, 81);
                btnAdd.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfAdditionRequestsGUI();
@@ -43,6 +42,7 @@ public class AdminMenuGUI extends JFrame {
                });
                
                JButton btnDel = new JButton("Delete Requests");
+               btnDel.setBounds(120, 159, 164, 73);
                btnDel.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfRemovalRequestsGUI();
@@ -51,34 +51,26 @@ public class AdminMenuGUI extends JFrame {
                });
                
                JButton btnOwneraddition = new JButton("OwnerAddition");
+               btnOwneraddition.setBounds(120, 243, 164, 73);
                btnOwneraddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfOwnerAddittionRequests();
                                a.setVisible(true);
                        }
                });
-               GroupLayout gl_contentPane = new GroupLayout(contentPane);
-               gl_contentPane.setHorizontalGroup(
-                       gl_contentPane.createParallelGroup(Alignment.LEADING)
-                               .addGroup(gl_contentPane.createSequentialGroup()
-                                       .addGap(115)
-                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
-                                               .addComponent(btnOwneraddition, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                                               .addComponent(btnDel, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
-                                               .addComponent(btnAdd, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))
-                                       .addContainerGap(145, Short.MAX_VALUE))
-               );
-               gl_contentPane.setVerticalGroup(
-                       gl_contentPane.createParallelGroup(Alignment.LEADING)
-                               .addGroup(gl_contentPane.createSequentialGroup()
-                                       .addGap(62)
-                                       .addComponent(btnAdd, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
-                                       .addGap(58)
-                                       .addComponent(btnDel, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
-                                       .addGap(52)
-                                       .addComponent(btnOwneraddition, GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
-                                       .addContainerGap())
-               );
-               contentPane.setLayout(gl_contentPane);
+               contentPane.setLayout(null);
+               contentPane.add(btnOwneraddition);
+               contentPane.add(btnDel);
+               contentPane.add(btnAdd);
+       
+               JButton btnOwnerDeletion = new JButton("Owner Deletion");
+               btnOwnerDeletion.setBounds(120, 331, 164, 73);
+               btnOwnerDeletion.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               Frame a = new DeleteOwnerGUI();
+                               a.setVisible(true);
+                       }
+               });
+               contentPane.add(btnOwnerDeletion);
        }
 }
index c26d9df..21f9ab6 100644 (file)
@@ -79,10 +79,11 @@ public class BookRuralHouseConfirmationWindow extends JFrame {
     jTextField3.setBounds(new Rectangle(180, 140, 115, 25));
     jTextField3.setEditable(false);
 
-    jTextField3.setText(Float.toString(book.getOffer().getPrice()) + " ï¿½");
+    jTextField3.setText(Float.toString(book.getOffer().getPrice()) + " \80");
     jTextField4.setBounds(new Rectangle(180, 175, 115, 25));
     jTextField4.setEditable(false);
-    jTextField4.setText(Float.toString(book.getOffer().getPrice()*(float)0.2) + " ï¿½");
+    jTextField4.setText(Float.toString(book.getOffer().getPrice()*(float)0.2) + " \80");
+
     this.getContentPane().add(jTextField4, null);
     this.getContentPane().add(jTextField3, null);
     this.getContentPane().add(jLabel5, null);
index d3a79e4..d9f5ab8 100644 (file)
@@ -5,6 +5,7 @@ import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.rmi.Naming;
+import java.rmi.RemoteException;
 import java.util.Vector;
 
 import javax.swing.JButton;
@@ -15,6 +16,7 @@ import javax.swing.JPanel;
 import javax.swing.JRadioButton;
 import javax.swing.border.EmptyBorder;
 
+import common.HouseInterface;
 import common.OfferInterface;
 
 import configuration.___IntNames;
@@ -29,28 +31,40 @@ public class DeleteOfferGUI extends JFrame {
         */
        private static final long serialVersionUID = 1L;
        private JPanel contentPane;
-       private Owner owner;
        private JLabel feedback;
        private JComboBox<RuralHouse> comboBox;
        private JComboBox<Offer> comboBox_1;
        private JButton btnDelete;
+       private Vector<RuralHouse> Hlist = null;
+       private HouseInterface hm = null;
 
        /**
         * Create the frame.
         */
        public DeleteOfferGUI(Owner o) {
-               this.owner = o;
+               try {
+                       hm = (HouseInterface) Naming
+                                       .lookup(___IntNames.HouseManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               try {
+                       Hlist = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
+               } catch (RemoteException e1) {
+                       e1.printStackTrace();
+               }       
                setBounds(100, 100, 450, 300);
                contentPane = new JPanel();
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
 
-               comboBox = new JComboBox<RuralHouse>(this.owner.getRuralHouses());
+               comboBox = new JComboBox<RuralHouse>(this.Hlist);
                comboBox.setBounds(101, 38, 314, 20);
 
                comboBox_1 = new JComboBox<Offer>();
                comboBox_1.setBounds(101, 76, 314, 20);
-               Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).offers;
+               Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).getAllOffers();
                comboBox_1.removeAllItems();
                for (Offer of : vo) {
                        comboBox_1.addItem(of);
@@ -68,7 +82,7 @@ public class DeleteOfferGUI extends JFrame {
 
                        @Override
                        public void itemStateChanged(ItemEvent arg0) {
-                               Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).offers;
+                               Vector<Offer> vo = ((RuralHouse) comboBox.getSelectedItem()).getAllOffers();
                                comboBox_1.removeAllItems();
                                for (Offer of : vo) {
                                        comboBox_1.addItem(of);
diff --git a/ruralHouses/src/gui/DeleteOwnerGUI.java b/ruralHouses/src/gui/DeleteOwnerGUI.java
new file mode 100644 (file)
index 0000000..982e022
--- /dev/null
@@ -0,0 +1,139 @@
+package gui;
+
+import java.awt.Font;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableModel;
+
+import common.AccountInterface;
+import common.AdminInterface;
+
+import configuration.___IntNames;
+import domain.Owner;
+
+public class DeleteOwnerGUI extends JFrame {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private JPanel contentPane;
+       private JTable table;
+
+       private DefaultTableModel tableModel;
+       private AdminInterface AdM = null;
+       private Vector<Owner> owners = new Vector<Owner>();
+
+       /**
+        * Create the frame.
+        */
+       public DeleteOwnerGUI() {
+               setTitle("Current owners:");
+               try {
+                       init();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       private void init() throws Exception {
+               setBounds(100, 100, 600, 500);
+               contentPane = new JPanel();
+               contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
+               setContentPane(contentPane);
+               contentPane.setLayout(null);
+               try {
+                       AdM = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out
+                                       .println("Error accessing remote authentication: "
+                                                       + e1.toString());
+               }
+               this.owners = AdM.getAllOwners();
+               JLabel lblNewLabel = new JLabel();
+               lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
+               lblNewLabel.setBounds(23, 41, 536, 33);
+               contentPane.add(lblNewLabel);
+               if (this.owners.isEmpty())
+                       lblNewLabel
+                                       .setText("There are not owners in the system");
+               else
+                       lblNewLabel.setText("List of owners:");
+               JScrollPane scrollPane = new JScrollPane();
+               scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
+               scrollPane.setBounds(23, 113, 536, 271);
+               contentPane.add(scrollPane);
+               final JLabel feedback = new JLabel("");
+               feedback.setBounds(134, 447, 307, 14);
+               contentPane.add(feedback);
+               JButton btnNewButton = new JButton("Delete from the system");
+               btnNewButton.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               if (table.getRowCount()!=0 && table.getSelectedRow() != -1) {
+                                       AccountInterface acm = null;
+                                       
+                                       try {
+                                               acm = (AccountInterface) Naming
+                                                               .lookup(___IntNames.AccountManager);
+                                       } catch (Exception e1) {
+                                               System.out.println("Error accessing remote authentication: "
+                                                               + e1.toString());
+                                       }
+
+                                       try {
+                                               if(acm.removeAccount(table.getSelectedRow()))
+                                                       {
+                                                       feedback.setText("Deleted from the system");
+                                                       }
+                                       } catch (RemoteException e1) {
+                                               e1.printStackTrace();
+                                       }
+                                       
+                                       ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
+                               }
+                       }
+               });
+               btnNewButton.setBounds(88, 396, 428, 40);
+               contentPane.add(btnNewButton);
+               table = new JTable() {
+                       private static final long serialVersionUID = 1L;
+
+                       public boolean isCellEditable(int row, int column) {
+                               return false;
+                       };
+               };
+               
+               scrollPane.setViewportView(table);      
+               tableModel = new DefaultTableModel(null, new String[] {
+                               "Name", "E-mail", "Bank Account" });
+
+               table.setModel(tableModel);
+               
+               
+               Enumeration<Owner> rhs = this.owners.elements();
+               while (rhs.hasMoreElements()) {
+                       Owner own = rhs.nextElement();
+                       Vector<Object> row = new Vector<Object>();
+                       row.add(own.getName());
+                       row.add(own.getMailAccount());
+                       row.add(own.getBankAccount());
+                       tableModel.addRow(row);
+               }
+               
+               
+       }
+}
index 62e81e9..39d0bc9 100644 (file)
@@ -55,6 +55,7 @@ public class HouseFeaturesGUI extends JFrame {
        private JTable table;
        private DefaultTableModel tableModel;
        private RuralHouse rh;
+       private Vector<Offer> offers= new Vector<Offer>();
        private JTextField telIn;
        private int row;
        private JLabel labelPhone;
@@ -238,7 +239,9 @@ public class HouseFeaturesGUI extends JFrame {
                Enumeration<Offer> rhs = rh.getAllOffers().elements();
                while (rhs.hasMoreElements()) {
                        Offer of = rhs.nextElement();
-                       if (of.getBookings() != null) {
+                       if (of.getBookings() == null
+                                       || !of.isBooked()) {
+                               offers.add(of);
                                Vector<Object> row = new Vector<Object>();
                                row.add(of.getOfferNumber());
                                row.add(of.getFirstDay());
@@ -300,8 +303,8 @@ public class HouseFeaturesGUI extends JFrame {
                                if (table.getRowCount() != 0) {
                                        Client cl = new Client(nameField.getText(),
                                                        mailField.getText(), telIn.getText());
-                                       book = bookingM.createBooking(rh, rh.offers.get(row)
-                                                       .getFirstDay(), rh.offers.get(row).getLastDay(),cl);
+                                       book = bookingM.createBooking(rh, offers.get(row)
+                                                       .getFirstDay(), offers.get(row).getLastDay(),cl);
                                }
                        } catch (Exception e) {
                                e.printStackTrace();
index 691b0ca..d5db84c 100644 (file)
@@ -19,6 +19,7 @@ import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
 import common.HouseInterface;
+
 import configuration.___IntNames;
 import domain.Districs;
 import domain.HouseFeatures;
index d5422bf..3e7a6c6 100644 (file)
@@ -26,9 +26,9 @@ import javax.swing.JLabel;
 import javax.swing.JTextField;
 
 import com.toedter.calendar.JCalendar;
-
 import common.HouseInterface;
 import common.OfferInterface;
+
 import configuration.___IntNames;
 import domain.Offer;
 import domain.Owner;
@@ -91,7 +91,7 @@ public class ModifyOfferGUI extends JFrame {
                        e1.printStackTrace();
                }
 
-               
+
                jComboBox1 = new JComboBox<RuralHouse>(Hlist);
 
                comboBox_o = new JComboBox<Offer>(
@@ -146,6 +146,7 @@ public class ModifyOfferGUI extends JFrame {
 
                        @Override
                        public void itemStateChanged(ItemEvent arg0) {
+
                                Vector<Offer> vo= null;
                                try {
                                        vo = om.getRuralHouseOffers((RuralHouse) jComboBox1.getSelectedItem());
index 5a4ffe9..62395d5 100644 (file)
@@ -41,10 +41,9 @@ public class OwnerRegistrationGUI extends JFrame {
         * Create the frame.
         */
        public OwnerRegistrationGUI() {
-               
+
                try {
-                       am = (AdminInterface) Naming
-                                       .lookup(___IntNames.AdminManager);
+                       am = (AdminInterface) Naming.lookup(___IntNames.AdminManager);
                } catch (Exception e1) {
                        System.out.println("Error accessing remote authentication: "
                                        + e1.toString());
@@ -139,23 +138,32 @@ public class OwnerRegistrationGUI extends JFrame {
 
        private void jButton_ActionPerformed(ActionEvent e) {
 
-               Owner own = new Owner(this.nameField.getText(),
-                               this.bank1Field.getText() + " " + this.bank2Field.getText()
-                                               + " " + this.bank3Field.getText() + " "
-                                               + this.bank4Field.getText(), this.emailField.getText());
-
-
-               try {
-                       if (this.am.addAccountRequest(this.userNameField.getText(),
-                                       this.passField.getText(), own)) {
-                               this.am.saveInstance();
-                               this.feedback.setText("Request sended");
-                       } else {
-                               this.feedback.setText("Can't send the request");
+               if (!emailField
+                               .getText()
+                               .matches(
+                                               "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")
+                               || !this.nameField.getText().isEmpty()||this.bank1Field.getText().length()!=4 || this.bank2Field.getText().length()!=4
+                               ||this.bank3Field.getText().length()!=2 || this.bank4Field.getText().length()!=10) {
+                       Owner own = new Owner(this.nameField.getText(),
+                                       this.bank1Field.getText() + " " + this.bank2Field.getText()
+                                                       + " " + this.bank3Field.getText() + " "
+                                                       + this.bank4Field.getText(),
+                                       this.emailField.getText());
+
+                       try {
+                               if (this.am.addAccountRequest(this.userNameField.getText(),
+                                               this.passField.getText(), own)) {
+                                       this.am.saveInstance();
+                                       this.feedback.setText("Request sended");
+                               } else {
+                                       this.feedback.setText("Can't send the request");
+                               }
+                       } catch (RemoteException e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
                        }
-               } catch (RemoteException e1) {
-                       // TODO Auto-generated catch block
-                       e1.printStackTrace();
+               } else {
+                       this.feedback.setText("Bad formatted data");
                }
 
        }
index d112532..30e5e66 100644 (file)
@@ -118,7 +118,6 @@ public class listOfAdditionRequestsGUI extends JFrame {
                                        }
                                        
                                        ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                       houses.remove(rh);
                                }
                        }
                });
index 982d7f2..423ea4d 100644 (file)
@@ -1,9 +1,12 @@
 package gui;
 
+import java.awt.Color;
+import java.awt.Component;
 import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.Naming;
 import java.rmi.RemoteException;
 import java.util.Enumeration;
 import java.util.Vector;
@@ -15,10 +18,12 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 
 import common.BookingInterface;
 
+import configuration.___IntNames;
 import domain.Booking;
 import domain.Offer;
 
@@ -31,7 +36,7 @@ public class listOfBookingRequestsGUI extends JFrame {
        private JPanel contentPane;
        private JTable table;
        private Offer off;
-       private BookingInterface bookM =null;
+       private BookingInterface bookM = null;
        private DefaultTableModel tableModel;
        private Vector<Booking> bookings = new Vector<Booking>();
 
@@ -56,17 +61,12 @@ public class listOfBookingRequestsGUI extends JFrame {
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                contentPane.setLayout(null);
-               
-               this.bookings= this.off.getBookings();
+
+               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 (bookings.isEmpty())
-                       lblNewLabel
-                                       .setText("There are not bookings to be confirmed or denied");
-               else
-                       lblNewLabel.setText("List of bookings:");
                JScrollPane scrollPane = new JScrollPane();
                scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
                scrollPane.setBounds(23, 113, 536, 271);
@@ -80,24 +80,34 @@ public class listOfBookingRequestsGUI extends JFrame {
                        };
                };
                scrollPane.setViewportView(table);
-               tableModel = new DefaultTableModel(null, new String[] {
-                               "Booking Number", "Booking Date","Name","E-mail", "Telephone" });
+               tableModel = new DefaultTableModel(null,
+                               new String[] { "Booking Number", "Booking Date", "Name",
+                                               "E-mail", "Telephone" });
 
-               // Maybe there is a better way to avoid interaction.
-               // table.setEnabled(false);
                table.setModel(tableModel);
 
                JButton btnNewButton = new JButton("Confirm Booking");
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
+                               try {
+                                       bookM = (BookingInterface) Naming
+                                                       .lookup(___IntNames.BookingManager);
+                               } catch (Exception e1) {
+                                       System.out
+                                                       .println("Error accessing remote authentication: "
+                                                                       + e1.toString());
+                               }
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
-                                       if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
+                                       if (table.getRowCount() != 0
+                                                       && table.getSelectedRow() != -1) {
                                                Booking book = bookings.get(table.getSelectedRow());
                                                try {
                                                        bookM.acceptBooking(book);
                                                } catch (RemoteException e1) {
                                                        e1.printStackTrace();
                                                }
+                                               contentPane.setVisible(false);
+
                                        }
 
                                }
@@ -109,20 +119,42 @@ public class listOfBookingRequestsGUI extends JFrame {
                JButton btnDenyAddition = new JButton("Deny Booking");
                btnDenyAddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
+                               try {
+                                       bookM = (BookingInterface) Naming
+                                                       .lookup(___IntNames.BookingManager);
+                               } catch (Exception e1) {
+                                       System.out
+                                                       .println("Error accessing remote authentication: "
+                                                                       + e1.toString());
+                               }
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        Booking book = bookings.get(table.getSelectedRow());
                                        try {
-                                               bookM.removeDenyBooking(book);
+                                               bookM.denyBooking(book);
                                        } catch (RemoteException e) {
                                                e.printStackTrace();
                                        }
+                                       ((DefaultTableModel) table.getModel()).removeRow(table
+                                                       .getSelectedRow());
+                                       bookings.remove(book);
 
                                }
                        }
                });
+               if (bookings.isEmpty())
+                       lblNewLabel
+                                       .setText("There are not bookings to be confirmed or denied");
+               else {
+                       lblNewLabel.setText("List of bookings:");
+                       if (this.bookings.get(0).getOffer().isBooked()) {
+                               btnDenyAddition.setEnabled(false);
+                               btnNewButton.setEnabled(false);
+                       }
+               }
+               
                btnDenyAddition.setBounds(390, 395, 169, 25);
                contentPane.add(btnDenyAddition);
-               
+
                Enumeration<Booking> en = this.bookings.elements();
                Booking book;
                while (en.hasMoreElements()) {
@@ -135,6 +167,31 @@ public class listOfBookingRequestsGUI extends JFrame {
                        row.add(book.getClient().getTelephone());
                        tableModel.addRow(row);
                }
+               table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
+                       /**
+                        * 
+                        */
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       public Component getTableCellRendererComponent(JTable table,
+                                       Object value, boolean isSelected, boolean hasFocus,
+                                       int row, int col) {
 
+                               super.getTableCellRendererComponent(table, value, isSelected,
+                                               hasFocus, row, col);
+
+                               if (!bookings.get(row).getOffer().isBooked()) {
+                                       setBackground(Color.RED);
+                                       setForeground(Color.BLACK);
+                               } else {
+                                       setBackground(Color.GREEN);
+                                       setForeground(Color.BLACK);
+                               }
+
+                               return this;
+                       }
+               });
        }
+
 }
index 1a49f1c..7d61def 100644 (file)
@@ -1,5 +1,7 @@
 package gui;
 
+import java.awt.Color;
+import java.awt.Component;
 import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.event.MouseAdapter;
@@ -13,6 +15,7 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
 import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.DefaultTableModel;
 
 import domain.Offer;
@@ -103,8 +106,33 @@ public class listOfOffers extends JFrame {
                        row.add(of.getPrice());
                        row.add(of.getRuralHouse().getHouseName());
                        tableModel.addRow(row);
-
                }
+               
+               table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
+                       /**
+                        * 
+                        */
+                       private static final long serialVersionUID = 1L;
+
+                       @Override
+                       public Component getTableCellRendererComponent(JTable table,
+                                       Object value, boolean isSelected, boolean hasFocus,
+                                       int row, int col) {
+
+                               super.getTableCellRendererComponent(table, value, isSelected,
+                                               hasFocus, row, col);
+
+                               if (!offers.get(row).isBooked()) {
+                                       setBackground(Color.ORANGE);
+                                       setForeground(Color.BLACK);
+                               } else {
+                                       setBackground(Color.GREEN);
+                                       setForeground(Color.BLACK);
+                               }
+
+                               return this;
+                       }
+               });
 
        }
 }
index 01aaf8f..b3297b4 100644 (file)
@@ -117,8 +117,9 @@ public class listOfOwnerAddittionRequests extends JFrame {
                                        } catch (RemoteException e1) {
                                                e1.printStackTrace();
                                        }
-                       
+                                       
                                        ((DefaultTableModel)table.getModel()).removeRow(table.getSelectedRow());
+                                       
                                }
                        }
                });
index 62daded..a85c246 100644 (file)
@@ -41,8 +41,7 @@ public class listOfRemovalRequestsGUI extends JFrame {
         */
        public listOfRemovalRequestsGUI() {
                try {
-                       am = (AdminInterface) Naming
-                                       .lookup(___IntNames.AdminManager);
+                       am = (AdminInterface) Naming.lookup(___IntNames.AdminManager);
                } catch (Exception e1) {
                        System.out.println("Error accessing remote authentication: "
                                        + e1.toString());
@@ -94,51 +93,50 @@ public class listOfRemovalRequestsGUI extends JFrame {
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
-                                       HouseInterface hm= null;
+                                       HouseInterface hm = null;
                                        try {
                                                hm = (HouseInterface) Naming
                                                                .lookup(___IntNames.HouseManager);
                                        } catch (Exception e1) {
-                                               System.out.println("Error accessing remote authentication: "
-                                                               + e1.toString());
+                                               System.out
+                                                               .println("Error accessing remote authentication: "
+                                                                               + e1.toString());
                                        }
                                        RuralHouse rh = houses.get(table.getSelectedRow());
-                                       ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                               try {
-                                                       hm.removeHouse(rh, rh.getOwner());
-                                                       am.removeHouseDeletionRequests(rh);
-                                                       am.saveInstance();
-                                               } catch (RemoteException e1) {
-                                                       // TODO Auto-generated catch block
-                                                       e1.printStackTrace();
-                                               }
-                                               houses.remove(rh);
-                                               
-
-                                       
+
+                                       try {
+                                               hm.removeHouse(rh, rh.getOwner());
+                                               am.removeHouseDeletionRequests(rh);
+                                               am.saveInstance();
+                                       } catch (RemoteException e1) {
+                                               e1.printStackTrace();
+                                       }
+                                       ((DefaultTableModel) table.getModel()).removeRow(houses
+                                                       .indexOf(rh));
+                                       houses.remove(rh);
+
                                }
                        }
                });
                btnNewButton.setBounds(90, 396, 169, 25);
                contentPane.add(btnNewButton);
-               
+
                JButton btnNewButton_1 = new JButton("Deny Deletion");
                btnNewButton_1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        RuralHouse rh = houses.get(table.getSelectedRow());
-                                       ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
-                                               houses.remove(rh);
-                                               try {
-                                                       am.removeHouseDeletionRequests(rh);
-                                                       am.saveInstance();
-                                               } catch (RemoteException e1) {
-                                                       // TODO Auto-generated catch block
-                                                       e1.printStackTrace();
-                                               }
-                                               
-
-                                       
+                                       ((DefaultTableModel) table.getModel()).removeRow(houses
+                                                       .indexOf(rh));
+                                       houses.remove(rh);
+                                       try {
+                                               am.removeHouseDeletionRequests(rh);
+                                               am.saveInstance();
+                                       } catch (RemoteException e1) {
+                                               // TODO Auto-generated catch block
+                                               e1.printStackTrace();
+                                       }
+
                                }
                        }
                });