Debbugin continues...
authorcamjan <jcampos004@ikasle.ehu.es>
Wed, 15 Apr 2015 17:08:42 +0000 (19:08 +0200)
committercamjan <jcampos004@ikasle.ehu.es>
Wed, 15 Apr 2015 17:08:42 +0000 (19:08 +0200)
ruralHouses/src/businessLogic/AdminManager.java
ruralHouses/src/domain/RuralHouse.java
ruralHouses/src/gui/AdminMenuGUI.java
ruralHouses/src/gui/ModifyHouseGUI.java
ruralHouses/src/gui/RequestDeleteHouseGUI.java
ruralHouses/src/gui/RequestNewHouseGUI.java
ruralHouses/src/gui/listOfAdditionRequestsGUI.java
ruralHouses/src/gui/listOfRemovalRequestsGUI.java

index d32eafa..6ddda72 100644 (file)
@@ -22,10 +22,15 @@ public class AdminManager {
        public void removeHouseDeletionRequests(RuralHouse house){
                Administrator.getRemoveRequest().remove(house);
                }
-       public void addAdditionRequest(RuralHouse rh){
-               Administrator.getAddRequest().add(rh);
+       public boolean addAdditionRequest(RuralHouse rh){
+               if(this.getAdditionRequests().contains(rh)){
+                       return false;
+               }
+               return Administrator.getAddRequest().add(rh);
        }
-       public void addDeletionRequest(RuralHouse rh){
-               Administrator.getRemoveRequest().add(rh);
+       public boolean addDeletionRequest(RuralHouse rh){
+               if(this.getDeletionRequests().contains(rh))
+                       return false;
+               return Administrator.getRemoveRequest().add(rh);
        }
 }
index 081ef4c..02ab6f9 100644 (file)
@@ -12,25 +12,24 @@ public class RuralHouse implements Serializable {
        private String houseName;
        private String description;
        private Owner owner;
-       private String district; 
+       private String district;
        private HouseFeatures features;
        public Vector<Offer> offers;
        public boolean isAccepted;
-       
+
        public RuralHouse() {
                super();
        }
 
-       public RuralHouse(String houseName, Owner owner, String description, String ds , HouseFeatures features) {
+       public RuralHouse(String houseName, Owner owner, String description,
+                       String ds, HouseFeatures features) {
                this.houseName = houseName;
                this.description = description;
                this.owner = owner;
                this.district = ds;
                this.features = features;
-               offers=new Vector<Offer>();
+               offers = new Vector<Offer>();
        }
-       
-       
 
        public String getHouseName() {
                return houseName;
@@ -43,9 +42,9 @@ public class RuralHouse implements Serializable {
        public String getDescription() {
                return description;
        }
-       
+
        public void setDescription(String description) {
-               this.description=description;
+               this.description = description;
        }
 
        public Owner getOwner() {
@@ -53,36 +52,35 @@ public class RuralHouse implements Serializable {
        }
 
        public void setOwner(Owner owner) {
-               this.owner=owner;
+               this.owner = owner;
        }
-       
+
        public String getDistrict() {
                return district;
        }
-       
+
        public void setDistrict(String ds) {
-               this.district=ds;
+               this.district = ds;
        }
+
        public HouseFeatures getFeatures() {
                return features;
        }
 
        public void setFeatures(HouseFeatures features) {
                this.features = features;
-       }       
+       }
+
        public String toString() {
                return this.houseName + ": " + this.district;
        }
-       
-       public Offer createOffer(int offerNumber,Date firstDay, Date lastDay, float price)  {
-        Offer off=new Offer(offerNumber,this,firstDay,lastDay,price);
-        offers.add(off);
-        return off;
-       }
-
-
-
 
+       public Offer createOffer(int offerNumber, Date firstDay, Date lastDay,
+                       float price) {
+               Offer off = new Offer(offerNumber, this, firstDay, lastDay, price);
+               offers.add(off);
+               return off;
+       }
 
        @Override
        public boolean equals(Object obj) {
@@ -98,69 +96,83 @@ public class RuralHouse implements Serializable {
                return true;
        }
 
-       
        /**
-        * This method obtains available offers for a concrete house in a certain period 
+        * This method obtains available offers for a concrete house in a certain
+        * period
         * 
-        * @param houseName, the house number where the offers must be obtained 
-        * @param firstDay, first day in a period range 
-        * @param lastDay, last day in a period range
-        * @return a vector of offers(Offer class)  available  in this period
+        * @param houseName
+        *            , the house number where the offers must be obtained
+        * @param firstDay
+        *            , first day in a period range
+        * @param lastDay
+        *            , last day in a period range
+        * @return a vector of offers(Offer class) available in this period
         */
-       public Vector<Offer> getOffers( Date firstDay,  Date lastDay) {
-               Vector<Offer> availableOffers=new Vector<Offer>();
-               Iterator<Offer> e=offers.iterator();
+       public Vector<Offer> getOffers(Date firstDay, Date lastDay) {
+               Vector<Offer> availableOffers = new Vector<Offer>();
+               Iterator<Offer> e = offers.iterator();
                Offer offer;
-               while (e.hasNext()){
-                       offer=e.next();
-                       if ( (offer.getFirstDay().compareTo(firstDay)>=0) && (offer.getLastDay().compareTo(lastDay)<=0) && (offer.getBooking()==null) )
+               while (e.hasNext()) {
+                       offer = e.next();
+                       if ((offer.getFirstDay().compareTo(firstDay) >= 0)
+                                       && (offer.getLastDay().compareTo(lastDay) <= 0)
+                                       && (offer.getBooking() == null))
                                availableOffers.add(offer);
                }
                return availableOffers;
        }
-       
+
        public Vector<Offer> getAllOffers() {
-               Vector<Offer> availableOffers=new Vector<Offer>();
-               Iterator<Offer> e=offers.iterator();
+               Vector<Offer> availableOffers = new Vector<Offer>();
+               Iterator<Offer> e = offers.iterator();
                Offer offer;
-               while (e.hasNext()){
-                       offer=e.next();
-                       if ( (offer.getBooking()==null) )
+               while (e.hasNext()) {
+                       offer = e.next();
+                       if ((offer.getBooking() == null))
                                availableOffers.add(offer);
                }
                return availableOffers;
        }
+
        /**
-        * This method obtains the offer that match exactly with a given dates that has not been booked
+        * This method obtains the offer that match exactly with a given dates that
+        * has not been booked
         * 
-        * @param firstDay, first day in a period range 
-        * @param lastDay, last day in a period range
-        * @return the  offer(Offer class)  available  for a this period
+        * @param firstDay
+        *            , first day in a period range
+        * @param lastDay
+        *            , last day in a period range
+        * @return the offer(Offer class) available for a this period
         */
-       public Offer findOffer( Date firstDay,  Date lastDay) {         
-               Iterator<Offer> e=offers.iterator();
-               Offer offer=null;
-               while (e.hasNext()){
-                       offer=e.next();
-                       if ( (offer.getFirstDay().compareTo(firstDay)==0) && (offer.getLastDay().compareTo(lastDay)==0) && (offer.getBooking()==null) )
+       public Offer findOffer(Date firstDay, Date lastDay) {
+               Iterator<Offer> e = offers.iterator();
+               Offer offer = null;
+               while (e.hasNext()) {
+                       offer = e.next();
+                       if ((offer.getFirstDay().compareTo(firstDay) == 0)
+                                       && (offer.getLastDay().compareTo(lastDay) == 0)
+                                       && (offer.getBooking() == null))
                                return offer;
                }
-               return null;            
-       }
-       
-       
-public Offer overlapsWith( Date firstDay,  Date lastDay) {
-               
-               Iterator<Offer> e=offers.iterator();
-               Offer offer=null;
-               while (e.hasNext()){
-                       offer=e.next();
-                       if ( (offer.getFirstDay().compareTo(lastDay)<0) 
-                                       && (offer.getLastDay().compareTo(firstDay)>0))
+               return null;
+       }
+
+       public Offer overlapsWith(Date firstDay, Date lastDay) {
+
+               Iterator<Offer> e = offers.iterator();
+               Offer offer = null;
+               while (e.hasNext()) {
+                       offer = e.next();
+                       if ((offer.getFirstDay().compareTo(lastDay) < 0)
+                                       && (offer.getLastDay().compareTo(firstDay) > 0))
                                return offer;
                }
                return null;
-               
+
+       }
+
+       public boolean equals(RuralHouse oRh) {
+               return this.getHouseName().equals(oRh.getHouseName());
        }
 
 }
index 7062a21..0c82313 100644 (file)
@@ -33,14 +33,14 @@ public class AdminMenuGUI extends JFrame {
                
                
                Administrator.getInstance();
-               this.setTitle("Owner Menu");
+               this.setTitle("Administrator Menu");
                this.getContentPane().setLayout(null);
                setBounds(100, 100, 450, 473);
                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");
+               JButton btnAdd = new JButton("Add requests");
                btnAdd.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                Frame a = new listOfAdditionRequestsGUI();
index e7bd38d..106a78b 100644 (file)
@@ -5,19 +5,19 @@ import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
+
+import javax.swing.DefaultComboBoxModel;
 import javax.swing.JButton;
 import javax.swing.JComboBox;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
-import javax.swing.LayoutStyle.ComponentPlacement;
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
 import businessLogic.HouseManager;
+import domain.Districs;
 import domain.HouseFeatures;
 import domain.Owner;
 import domain.RuralHouse;
@@ -31,7 +31,6 @@ public class ModifyHouseGUI extends JFrame {
        private JPanel contentPane;
        private Owner owner;
        private JLabel lblDistrict;
-       private JTextField District_f;
        private JLabel feedback;
        private JLabel lblDescription;
        private JTextField description_f;
@@ -44,6 +43,7 @@ public class ModifyHouseGUI extends JFrame {
        private JLabel lblParkings;
        private JTextField parkings_f;
        private JLabel lblBaths;
+       private String[] distric;
        private JTextField baths_f;
        private JButton btnConfirm;
        private JComboBox<RuralHouse> houseBox;
@@ -53,6 +53,9 @@ public class ModifyHouseGUI extends JFrame {
         * Create the frame.
         */
        public ModifyHouseGUI(Owner o) {
+               this.distric=Districs.longNames();
+               JComboBox<String> comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+                               this.distric));
                this.getContentPane().setLayout(null);
                owner = o;
                setBounds(100, 100, 500, 583);
@@ -68,10 +71,6 @@ public class ModifyHouseGUI extends JFrame {
                lblDistrict.setBounds(39, 119, 70, 14);
                lblDistrict.setHorizontalAlignment(SwingConstants.RIGHT);
 
-               District_f = new JTextField();
-               District_f.setBounds(127, 116, 86, 20);
-               District_f.setColumns(10);
-
                lblDescription = new JLabel("Description:");
                lblDescription.setBounds(231, 88, 90, 14);
                lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
@@ -126,7 +125,7 @@ public class ModifyHouseGUI extends JFrame {
                        public void actionPerformed(ActionEvent arg0) {
 
                                RuralHouse newRh = new RuralHouse(rh.getHouseName(), owner,
-                                               description_f.getText(), District_f.getText(),
+                                               description_f.getText(), (String)comboBox.getSelectedItem(),
                                                new HouseFeatures(new Integer(rooms_f.getText()),
                                                                new Integer(kitchens_f.getText()), new Integer(
                                                                                baths_f.getText()), new Integer(
@@ -135,6 +134,9 @@ public class ModifyHouseGUI extends JFrame {
                                HouseManager hm = new HouseManager();
 
                                if (hm.registerNewHouse(newRh)) {
+                                       o.getRuralHouses().remove(rh);
+                                       o.getRuralHouses().add(newRh);
+                                       houseBox.removeItem(rh);
                                        feedback.setText("House properly modified");
                                } else
                                        feedback.setText("Imposible to modify the house");
@@ -144,8 +146,8 @@ public class ModifyHouseGUI extends JFrame {
 
                houseBox = new JComboBox<RuralHouse>(o.getRuralHouses());
                if (!o.getRuralHouses().isEmpty()) {
-                       rh = (RuralHouse) houseBox.getSelectedItem();
-                       District_f.setText(rh.getDistrict());
+                       rh = (RuralHouse) houseBox.getSelectedItem();                   
+                       comboBox.setSelectedItem(rh.getDistrict());             
                        description_f.setText(rh.getDescription());
                        kitchens_f.setText(Integer
                                        .toString(rh.getFeatures().getnKitchens()));
@@ -157,12 +159,13 @@ public class ModifyHouseGUI extends JFrame {
                        houseBox.setBounds(89, 85, 124, 20);
                }else{
                        feedback.setText("Not available houses");
+                       btnConfirm.setEnabled(false);
                }
                houseBox.addItemListener(new ItemListener() {
                        @Override
                        public void itemStateChanged(ItemEvent e) {
                                rh = (RuralHouse) houseBox.getSelectedItem();
-                               District_f.setText(rh.getDistrict());
+                               comboBox.setSelectedItem(rh.getDistrict());
                                description_f.setText(rh.getDescription());
                                kitchens_f.setText(Integer.toString(rh.getFeatures()
                                                .getnKitchens()));
@@ -185,7 +188,6 @@ public class ModifyHouseGUI extends JFrame {
                contentPane.add(lblBaths);
                contentPane.add(baths_f);
                contentPane.add(lblDistrict);
-               contentPane.add(District_f);
                contentPane.add(lblLivings);
                contentPane.add(lRooms_f);
                contentPane.add(lblKitchen);
@@ -197,5 +199,8 @@ public class ModifyHouseGUI extends JFrame {
                feedback = new JLabel("");
                feedback.setBounds(189, 510, 195, 23);
                contentPane.add(feedback);
+               
+               comboBox.setBounds(127, 116, 86, 20);
+               contentPane.add(comboBox);
        }
 }
index ce4fe96..7dd1ee6 100644 (file)
@@ -17,14 +17,17 @@ import javax.swing.border.EmptyBorder;
 import businessLogic.AdminManager;
 import domain.Owner;
 import domain.RuralHouse;
+import javax.swing.JLabel;
+import javax.swing.LayoutStyle.ComponentPlacement;
 
 public class RequestDeleteHouseGUI extends JFrame {
 
        private JPanel contentPane;
        private Owner owner;
-       private JComboBox comboBox;
+       private JComboBox<RuralHouse> comboBox;
        private JButton btnDelete;
        private AdminManager am;
+       JLabel feedback = new JLabel("");
 
        /**
         * Create the frame.
@@ -37,12 +40,15 @@ public class RequestDeleteHouseGUI extends JFrame {
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
        
-               comboBox = new JComboBox(this.owner.getRuralHouses());
+               comboBox = new JComboBox<RuralHouse>(this.owner.getRuralHouses());
+               comboBox.setBounds(75, 55, 332, 20);
                
 
                JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
+               rdbtnIAmSure.setBounds(90, 154, 71, 23);
                
                btnDelete = new JButton("REQUEST");
+               btnDelete.setBounds(90, 213, 90, 23);
                btnDelete.setEnabled(false);
                
                rdbtnIAmSure.addItemListener(new ItemListener() {
@@ -58,34 +64,12 @@ public class RequestDeleteHouseGUI extends JFrame {
                                }
                        }
                });
-               
-               GroupLayout gl_contentPane = new GroupLayout(contentPane);
-               gl_contentPane.setHorizontalGroup(
-                       gl_contentPane.createParallelGroup(Alignment.LEADING)
-                               .addGroup(gl_contentPane.createSequentialGroup()
-                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
-                                               .addGroup(gl_contentPane.createSequentialGroup()
-                                                       .addGap(70)
-                                                       .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
-                                               .addGroup(gl_contentPane.createSequentialGroup()
-                                                       .addGap(85)
-                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
-                                                               .addComponent(btnDelete)
-                                                               .addComponent(rdbtnIAmSure))))
-                                       .addContainerGap(954, Short.MAX_VALUE))
-               );
-               gl_contentPane.setVerticalGroup(
-                       gl_contentPane.createParallelGroup(Alignment.LEADING)
-                               .addGroup(gl_contentPane.createSequentialGroup()
-                                       .addGap(50)
-                                       .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-                                       .addGap(68)
-                                       .addComponent(rdbtnIAmSure)
-                                       .addGap(47)
-                                       .addComponent(btnDelete)
-                                       .addContainerGap(493, Short.MAX_VALUE))
-               );
-               contentPane.setLayout(gl_contentPane);
+               contentPane.setLayout(null);
+               contentPane.add(comboBox);
+               contentPane.add(rdbtnIAmSure);
+               contentPane.add(btnDelete);
+               feedback.setBounds(90, 184, 274, 18);
+               contentPane.add(feedback);
                
                btnDelete.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
@@ -100,6 +84,11 @@ public class RequestDeleteHouseGUI extends JFrame {
        private void actionListenerButton(ActionEvent e){
                RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
                
-               am.addDeletionRequest(toDel);
+               if(am.addDeletionRequest(toDel)){
+                       feedback.setText("Delete request sended");
+                       
+               }else{
+                       feedback.setText("Request cannot be sended(Already sended)");
+               }
        }
 }
index d0cf337..76f182e 100644 (file)
@@ -6,6 +6,7 @@ import java.awt.event.ActionListener;
 
 import javax.swing.GroupLayout;
 import javax.swing.GroupLayout.Alignment;
+import javax.swing.DefaultComboBoxModel;
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
@@ -16,10 +17,13 @@ import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
 import businessLogic.AdminManager;
+import domain.Districs;
 import domain.HouseFeatures;
 import domain.Owner;
 import domain.RuralHouse;
 
+import javax.swing.JComboBox;
+
 public class RequestNewHouseGUI extends JFrame {
 
        /**
@@ -29,9 +33,9 @@ public class RequestNewHouseGUI extends JFrame {
        private JPanel contentPane;
        private Owner owner;
        private JLabel lblCode ;
+       private JLabel feedback = new JLabel("");
        private JTextField Code_f;
        private JLabel lblTown;
-       private JTextField Town_f;
        private JLabel lblDescription;
        private JTextField description_f;
        private JLabel lblKitchen;
@@ -46,13 +50,15 @@ public class RequestNewHouseGUI extends JFrame {
        private JTextField baths_f;
        private JButton btnRegister;
        private AdminManager am;
+       private JComboBox comboBox;
 
 
        /**
         * Create the frame.
         */
        public RequestNewHouseGUI(Owner o) {
-               
+               JComboBox<String> comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+                               Districs.longNames()));
                am  = new AdminManager();
                this.setTitle("New House");
                setBackground(Color.WHITE);
@@ -63,18 +69,15 @@ public class RequestNewHouseGUI extends JFrame {
                contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
                setContentPane(contentPane);
                
-               lblCode = new JLabel("House Code:");
+               lblCode = new JLabel("House Name:");
                lblCode.setHorizontalAlignment(SwingConstants.RIGHT);
                
                Code_f = new JTextField();
                Code_f.setColumns(10);
                
-               lblTown = new JLabel("Town:");
+               lblTown = new JLabel("District:");
                lblTown.setHorizontalAlignment(SwingConstants.RIGHT);
                
-               Town_f = new JTextField();
-               Town_f.setColumns(10);
-               
                lblDescription = new JLabel("Description(optional):");
                lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
                
@@ -121,7 +124,7 @@ public class RequestNewHouseGUI extends JFrame {
                                        //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
                                        rh = new RuralHouse(Code_f.getText(),
                                                                owner, description_f.getText(),
-                                                               Town_f.getText() ,new HouseFeatures(Integer.parseInt(rooms_f.getText()),
+                                                               (String) comboBox.getSelectedItem() ,new HouseFeatures(Integer.parseInt(rooms_f.getText()),
                                                                                Integer.parseInt(kitchens_f.getText()),
                                                                                Integer.parseInt(baths_f.getText()),
                                                                                Integer.parseInt(lRooms_f.getText()),
@@ -132,17 +135,22 @@ public class RequestNewHouseGUI extends JFrame {
                                        e.printStackTrace();
                                }
                                
-                               am.addAdditionRequest(rh);
+                               if(am.addAdditionRequest(rh)){
+                                       feedback.setText("Request sended");
+                               }else{
+                                       feedback.setText("Request cannot be sended(Already added)");
+                               }
                        }
                });
+               
+               
+               
+               
                GroupLayout gl_contentPane = new GroupLayout(contentPane);
                gl_contentPane.setHorizontalGroup(
                        gl_contentPane.createParallelGroup(Alignment.LEADING)
                                .addGroup(gl_contentPane.createSequentialGroup()
                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
-                                               .addGroup(gl_contentPane.createSequentialGroup()
-                                                       .addGap(140)
-                                                       .addComponent(btnRegister))
                                                .addGroup(gl_contentPane.createSequentialGroup()
                                                        .addContainerGap()
                                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
@@ -152,7 +160,7 @@ public class RequestNewHouseGUI extends JFrame {
                                                                                        .addGroup(gl_contentPane.createSequentialGroup()
                                                                                                .addComponent(lblTown, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
                                                                                                .addGap(18)
-                                                                                               .addComponent(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                                                               .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 86, GroupLayout.PREFERRED_SIZE))
                                                                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
                                                                                                .addGroup(gl_contentPane.createSequentialGroup()
                                                                                                        .addComponent(lblLivings)
@@ -182,7 +190,12 @@ public class RequestNewHouseGUI extends JFrame {
                                                        .addGap(18)
                                                        .addComponent(lblParkings, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(ComponentPlacement.UNRELATED)
-                                                       .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
+                                                       .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(140)
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                                               .addComponent(feedback, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE)
+                                                               .addComponent(btnRegister))))
                                        .addContainerGap(97, Short.MAX_VALUE))
                );
                gl_contentPane.setVerticalGroup(
@@ -202,8 +215,8 @@ public class RequestNewHouseGUI extends JFrame {
                                                                .addComponent(Code_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                                        .addPreferredGap(ComponentPlacement.UNRELATED)
                                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
-                                                               .addComponent(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-                                                               .addComponent(lblTown))
+                                                               .addComponent(lblTown)
+                                                               .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                                                        .addGap(18)
                                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                                                                .addComponent(lblLivings)
@@ -220,7 +233,7 @@ public class RequestNewHouseGUI extends JFrame {
                                                .addGroup(gl_contentPane.createSequentialGroup()
                                                        .addGap(3)
                                                        .addComponent(lblKitchen)))
-                                       .addPreferredGap(ComponentPlacement.RELATED, 7, Short.MAX_VALUE)
+                                       .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                                .addGroup(gl_contentPane.createSequentialGroup()
                                                        .addGap(3)
@@ -230,7 +243,9 @@ public class RequestNewHouseGUI extends JFrame {
                                        .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                                .addComponent(lblParkings)
                                                .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-                                       .addGap(88)
+                                       .addGap(41)
+                                       .addComponent(feedback, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
+                                       .addPreferredGap(ComponentPlacement.UNRELATED)
                                        .addComponent(btnRegister)
                                        .addGap(54))
                );
index dd728fe..2829bc1 100644 (file)
@@ -33,6 +33,7 @@ public class listOfAdditionRequestsGUI extends JFrame {
         * Create the frame.
         */
        public listOfAdditionRequestsGUI() {
+               setTitle("Adding requests");
                try {
                        this.houses= am.getAdditionRequests();
                        init();
@@ -53,9 +54,9 @@ public class listOfAdditionRequestsGUI extends JFrame {
                lblNewLabel.setBounds(23, 41, 536, 33);
                contentPane.add(lblNewLabel);
                if (houses.isEmpty())
-                       lblNewLabel.setText("There are not houses matching your search");
+                       lblNewLabel.setText("There are not houses to be added");
                else
-                       lblNewLabel.setText("List of houses that match your search:");
+                       lblNewLabel.setText("List of houses to be added:");
                JScrollPane scrollPane = new JScrollPane();
                scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
                scrollPane.setBounds(23, 113, 536, 271);
@@ -88,6 +89,7 @@ public class listOfAdditionRequestsGUI extends JFrame {
                                        houses.remove(rh);
                                        am.removeHouseAdditionRequests(rh);
                                        Administrator.saveInstance();
+                                       ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
                                }
                        }
                });
index da70439..07ee348 100644 (file)
@@ -29,12 +29,14 @@ public class listOfRemovalRequestsGUI extends JFrame {
        private DefaultTableModel tableModel;
        private AdminManager am = new AdminManager();
        private Vector<RuralHouse> houses;
-       /**
+
+       /**
         * Create the frame.
         */
        public listOfRemovalRequestsGUI() {
+               setTitle("Deleting requests");
                try {
-                       this.houses= am.getDeletionRequests();
+                       this.houses = am.getDeletionRequests();
                        init();
                } catch (Exception e) {
                        e.printStackTrace();
@@ -53,42 +55,41 @@ public class listOfRemovalRequestsGUI extends JFrame {
                lblNewLabel.setBounds(23, 41, 536, 33);
                contentPane.add(lblNewLabel);
                if (houses.isEmpty())
-                       lblNewLabel.setText("There are not houses matching your search");
+                       lblNewLabel.setText("There are not houses to be deleted");
                else
-                       lblNewLabel.setText("List of houses that match your search:");
+                       lblNewLabel.setText("List of houses to be deleted:");
                JScrollPane scrollPane = new JScrollPane();
                scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
                scrollPane.setBounds(23, 113, 536, 271);
                contentPane.add(scrollPane);
 
                table = new JTable() {
-               private static final long serialVersionUID = 1L;
+                       private static final long serialVersionUID = 1L;
 
-               public boolean isCellEditable(int row, int column) {                
-                       return false;               
-               };
-           };
+                       public boolean isCellEditable(int row, int column) {
+                               return false;
+                       };
+               };
                scrollPane.setViewportView(table);
-               tableModel = new DefaultTableModel(null, new String[] {
-                               "House Name", "Bedrooms", "Kitchens", "Baths", "Parkings",
-                               "Livings" });
-               
-               //Maybe there is a better way to avoid interaction.
-               //table.setEnabled(false);
+               tableModel = new DefaultTableModel(null, new String[] { "House Name",
+                               "Bedrooms", "Kitchens", "Baths", "Parkings", "Livings" });
+
                table.setModel(tableModel);
                Enumeration<RuralHouse> en = houses.elements();
                RuralHouse rh;
                JButton btnNewButton = new JButton("Confirm Deletion");
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
-                               if (table.getRowCount()!=0) {
+                               if (table.getRowCount() != 0) {
                                        HouseManagerInterface hm = new HouseManager();
                                        RuralHouse rh = houses.get(table.getSelectedRow());
-                                       //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
-                                       hm.removeHouse(rh, rh.getOwner());
-                                       houses.remove(rh);
-                                       am.removeHouseDeletionRequests(rh);
-                                       Administrator.saveInstance();
+                                       ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh));
+                                               hm.removeHouse(rh, rh.getOwner());
+                                               houses.remove(rh);
+                                               am.removeHouseDeletionRequests(rh);
+                                               Administrator.saveInstance();
+
+                                       
                                }
                        }
                });