cleaning
[RRRRHHHH_Code] / ruralHouses / src / gui / OwnerRegistrationGUI.java
index c088e39..5a4ffe9 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.JButton;
 import javax.swing.JFrame;
@@ -11,16 +13,21 @@ import javax.swing.JPanel;
 import javax.swing.JTextField;
 import javax.swing.border.EmptyBorder;
 
-import businessLogic.AdminManager;
-import domain.Account;
+import common.AdminInterface;
+
+import configuration.___IntNames;
 import domain.Owner;
 
 public class OwnerRegistrationGUI extends JFrame {
 
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
        private JPanel panel;
        private JTextField nameField;
        private JTextField userNameField;
-       private AdminManager am = new AdminManager();
+       private AdminInterface am = null;
        private JTextField passField;
        private JTextField bank1Field;
        private JTextField bank2Field;
@@ -34,6 +41,14 @@ public class OwnerRegistrationGUI extends JFrame {
         * Create the frame.
         */
        public OwnerRegistrationGUI() {
+               
+               try {
+                       am = (AdminInterface) Naming
+                                       .lookup(___IntNames.AdminManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                setTitle("Owner registration");
                setBounds(100, 100, 500, 400);
                panel = new JPanel();
@@ -128,13 +143,19 @@ public class OwnerRegistrationGUI extends JFrame {
                                this.bank1Field.getText() + " " + this.bank2Field.getText()
                                                + " " + this.bank3Field.getText() + " "
                                                + this.bank4Field.getText(), this.emailField.getText());
-               Account acc = new Account(this.userNameField.getText(),
-                               this.passField.getText(), own);
 
-               if (this.am.addAccount(acc)) {
-                       this.feedback.setText("Request sended");
-               } else {
-                       this.feedback.setText("Can't send the request");
+
+               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();
                }
 
        }