Merged the two branches, DB separated
[RRRRHHHH_Code] / ruralHouses / src / gui / ModifyHouseGUI.java
index 06b679e..d5db84c 100644 (file)
@@ -4,6 +4,9 @@ import java.awt.event.ActionEvent;
 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.DefaultComboBoxModel;
 import javax.swing.JButton;
@@ -15,7 +18,9 @@ import javax.swing.JTextField;
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
-import businessLogic.HouseManager;
+import common.HouseInterface;
+
+import configuration.___IntNames;
 import domain.Districs;
 import domain.HouseFeatures;
 import domain.Owner;
@@ -132,19 +137,45 @@ public class ModifyHouseGUI extends JFrame {
                                                                                baths_f.getText()), new Integer(
                                                                                lRooms_f.getText()), new Integer(
                                                                                parkings_f.getText())));
-                               HouseManager hm = new HouseManager();
-
-                               if (hm.registerNewHouse(newRh)) {
-                                       owner.getRuralHouses().add(newRh);
-                                       houseBox.removeItem(rh);
-                                       feedback.setText("House properly modified");
-                               } else
-                                       feedback.setText("Imposible to modify the house");
+                               HouseInterface hm= null;
+                               try {
+                                       hm = (HouseInterface) Naming
+                                                       .lookup(___IntNames.HouseManager);
+                               } catch (Exception e1) {
+                                       System.out.println("Error accessing remote authentication: "
+                                                       + e1.toString());
+                               }
+               
+                               try {
+                                       if (hm.registerNewHouse(newRh)) {
+                                               owner.getRuralHouses().add(newRh);
+                                               houseBox.removeItem(rh);
+                                               feedback.setText("House properly modified");
+                                       } else
+                                               feedback.setText("Imposible to modify the house");
+                               } catch (RemoteException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                               }
 
                        }
                });
-
-               houseBox = new JComboBox<RuralHouse>(o.getRuralHouses());
+               HouseInterface hm= null;
+               try {
+                       hm = (HouseInterface) Naming
+                                       .lookup(___IntNames.HouseManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
+               Vector<RuralHouse> list = null;
+               try {
+                       list = hm.getHouses(o, null, null, 0, 0, 0, 0, 0);
+               } catch (RemoteException e1) {
+                       e1.printStackTrace();
+               }
+               
+               houseBox = new JComboBox<RuralHouse>(list);
                if (!o.getRuralHouses().isEmpty()) {
                        rh = (RuralHouse) houseBox.getSelectedItem();                   
                        comboBox.setSelectedItem(rh.getDistrict());