Merged the two branches, DB separated
[RRRRHHHH_Code] / ruralHouses / src / gui / RequestNewHouseGUI.java
index 76b2465..e22a4f2 100644 (file)
@@ -3,6 +3,8 @@ package gui;
 import java.awt.Color;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.GroupLayout;
@@ -17,7 +19,9 @@ import javax.swing.LayoutStyle.ComponentPlacement;
 import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 
-import businessLogic.AdminManager;
+import common.AdminInterface;
+
+import configuration.___IntNames;
 import domain.Districs;
 import domain.HouseFeatures;
 import domain.Owner;
@@ -48,7 +52,7 @@ public class RequestNewHouseGUI extends JFrame {
        private JLabel lblBaths;
        private JTextField baths_f;
        private JButton btnRegister;
-       private AdminManager am;
+       private AdminInterface am = null;
        private JComboBox<String> comboBox;
 
 
@@ -58,7 +62,13 @@ public class RequestNewHouseGUI extends JFrame {
        public RequestNewHouseGUI(Owner o) {
                comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
                                Districs.longNames()));
-               am  = new AdminManager();
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                this.setTitle("New House");
                setBackground(Color.WHITE);
                this.getContentPane().setLayout(null);
@@ -134,10 +144,16 @@ public class RequestNewHouseGUI extends JFrame {
                                        e.printStackTrace();
                                }
                                
-                               if(am.addAdditionRequest(rh)){
-                                       feedback.setText("Request sended");
-                               }else{
-                                       feedback.setText("Request cannot be sended(Already added)");
+                               try {
+                                       if(am.addAdditionRequest(rh)){
+                                               am.saveInstance();
+                                               feedback.setText("Request sended");
+                                       }else{
+                                               feedback.setText("Request cannot be sended(Already added)");
+                                       }
+                               } catch (RemoteException e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
                                }
                        }
                });