admin completed
[RRRRHHHH_Code] / ruralHouses / src / gui / LoginGUI.java
index caeb1cd..db04aff 100644 (file)
@@ -1,18 +1,25 @@
 package gui;
 
-import javax.swing.*;
-
+import java.awt.Color;
 import java.awt.Frame;
-import java.awt.Rectangle;
-import java.util.Vector;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 
-import businessLogic.*;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
+import javax.swing.JTextField;
+import javax.swing.SwingConstants;
+
+import businessLogic.LoginManager;
+import businessLogic.LoginManagerInterface;
+import domain.Account;
 import domain.Owner;
-import domain.RuralHouse;
 
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-import java.awt.Color;
+import javax.swing.JRadioButton;
+import javax.swing.ButtonGroup;
 
 public class LoginGUI extends JFrame {
 
@@ -22,7 +29,7 @@ public class LoginGUI extends JFrame {
        private JPasswordField passwordField;
        private LoginManagerInterface loginManager = new LoginManager();
        private JLabel loginFeedback;
-
+       private final ButtonGroup buttonGroup = new ButtonGroup();
        public LoginGUI() {
                super();
                initialize();
@@ -77,19 +84,22 @@ public class LoginGUI extends JFrame {
        }
        
        private void jButton_ActionPerformed(ActionEvent e){
-               Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
-               if(owner==null){
-                       loginFeedback.setText("Incorrect username or password");
-               }else{
-                       
-                       
                        
+               Account acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
+               if (acc.getAdmin()) {
+                       this.setVisible(false);
+                       Frame a = new AdminMenuGUI();
+                       a.setVisible(true);
+               } else {
+                       if(acc.getOwner()==null){
+                               loginFeedback.setText("Incorrect username or password");
+                       }else{
                                this.setVisible(false);
-                               Frame a = new OwnerMenuGUI(owner);
-                               a.setVisible(true);
-               }       
-
+                               Frame a = new OwnerMenuGUI(acc.getOwner());
+                               a.setVisible(true);             
+                       }
+               }
+               
        }
-
 }  // @jve:decl-index=0:visual-constraint="222,33"