Merge branch 'master' of https://xp-dev.com/git/RRRRHHHH_Code
authorepinzolas001 <epinzolas001@g004972.gi.ehu.es>
Fri, 27 Feb 2015 12:08:52 +0000 (13:08 +0100)
committerepinzolas001 <epinzolas001@g004972.gi.ehu.es>
Fri, 27 Feb 2015 12:08:52 +0000 (13:08 +0100)
Conflicts:
ruralHouses/db/DBjcampos004.yap
ruralHouses/src/gui/IntroduceOfferGUI.java

1  2 
ruralHouses/.gitignore
ruralHouses/db/DBjcampos004.yap
ruralHouses/src/gui/IntroduceOfferGUI.java
ruralHouses/src/gui/StartWindow.java

@@@ -1,2 -1,2 +1,3 @@@
  /bin
--/lib
++/lib/*
++/db/DBjcampos004.yap
index 7af26dd,a4f2ba5..64beb5c
Binary files differ
@@@ -1,11 -1,12 +1,12 @@@
  package gui;
  
  import javax.swing.*;
- import java.awt.Rectangle;
  
+ import java.awt.Frame;
+ import java.awt.Rectangle;
  import java.util.Vector;
  
--import businessLogic.ApplicationFacadeInterface;
++import businessLogic.*;
  import domain.Owner;
  import domain.RuralHouse;
  
@@@ -14,8 -17,10 +17,10 @@@ public class IntroduceOfferGUI extends 
  
        private static final long serialVersionUID = 1L;
        private JPanel jContentPane = null;
-       private JComboBox jComboBox = null;
-       private JButton jButton = null;
+       private JTextField usernameField;
+       private JPasswordField passwordField;
+       private JTextField textField;
 -      private LoginManager loginManager = new LoginManagerInterface();
++      private LoginManagerInterface loginManager = new LoginManager();
  
        public IntroduceOfferGUI() {
                super();
                if (jContentPane == null) {
                        jContentPane = new JPanel();
                        jContentPane.setLayout(null);
-                       jContentPane.add(getJComboBox(), null);
-                       jContentPane.add(getJButton(), null);
-               }
-               return jContentPane;
-       }
-       private JComboBox getJComboBox() {
-               if (jComboBox == null) {
-                       try {
-                               ApplicationFacadeInterface facade=StartWindow.getBusinessLogic();
-                               Vector<Owner> owners=facade.getOwners();
-                               jComboBox = new JComboBox(owners);
-                               jComboBox.setBounds(new Rectangle(63, 38, 175, 44));
-                       }
-                       catch (Exception e) {
-                               // TODO Auto-generated catch block
-                               e.printStackTrace();
-                       }
-               }
-               return jComboBox;
-       }
-       private JButton getJButton() {
-               if (jButton == null) {
-                       jButton = new JButton();
-                       jButton.setBounds(new Rectangle(113, 146, 95, 59));
-                       jButton.setText("Show houses");
-                       jButton.addActionListener(new java.awt.event.ActionListener() {
-                               public void actionPerformed(java.awt.event.ActionEvent e) {
-                                       Owner owner=(Owner)jComboBox.getSelectedItem();
-                                       System.out.println(owner.getUsername());
-                                       Vector<RuralHouse> houseList=null;
-                                       try {
-                                               //Obtain the business logic from a StartWindow class (local or remote)
-                                               ApplicationFacadeInterface facade=StartWindow.getBusinessLogic();
-                                               houseList=facade.getRuralHouses(owner);
-                                       }
-                                       catch (Exception e1) {
-                                               e1.printStackTrace();
-                                       }
-                                       if (houseList.isEmpty()!=true) {
-                                               JFrame a = new IntroduceOffer2GUI(houseList);
-                                               a.setVisible(true);
+                       
+                       JLabel usernameTag = new JLabel("Username:");
+                       usernameTag.setBounds(56, 67, 104, 20);
+                       jContentPane.add(usernameTag);
+                       
+                       JLabel passwordTag = new JLabel("Password:");
+                       passwordTag.setBounds(56, 132, 104, 15);
+                       jContentPane.add(passwordTag);
+                       
+                       usernameField = new JTextField();
+                       usernameField.setBounds(208, 68, 114, 19);
+                       jContentPane.add(usernameField);
+                       usernameField.setColumns(10);
+                       
+                       passwordField = new JPasswordField();
+                       passwordField.setBounds(208, 129, 114, 18);
+                       jContentPane.add(passwordField);
+                       
+                       JButton loginButton = new JButton("Login");
+                       loginButton.addActionListener(new ActionListener() {
+                               public void actionPerformed(ActionEvent arg0) {
 -                                      Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword());
++                                      Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
+                                       if(owner==null){
+                                               textField.setText("Incorrect username or password");
+                                       }else{
+                                               Vector<RuralHouse> ownerHouseList=null;
+                                               try{
+                                                       ownerHouseList = StartWindow.getBusinessLogic().getRuralHouses(owner);
+                                               }catch (Exception e){
+                                                       e.printStackTrace();
+                                               }
+                                               if(!ownerHouseList.isEmpty()){
+                                                       Frame a = new IntroduceOffer2GUI(ownerHouseList);
+                                                       a.setVisible(true);
+                                               }
+                                               else if(ownerHouseList.isEmpty())
+                                                       textField.setText("Login OK , but no houses in your name");
                                        }
-                                       else if (houseList.isEmpty()==true) {
-                                               System.out.print("Owner does not exist or has no registered houses ");
-                                       }               
                                }
                        });
+                       loginButton.setBounds(151, 178, 117, 25);
+                       jContentPane.add(loginButton);
+                       
+                       textField = new JTextField();
+                       textField.setBounds(127, 227, 185, 26);
+                       jContentPane.add(textField);
+                       textField.setColumns(10);
                }
-               return jButton;
+               return jContentPane;
        }
-       
-       
 -} // @jve:decl-index=0:visual-constraint="222,33"
 +
- }  //  @jve:decl-index=0:visual-constraint="222,33"
++
++}  // @jve:decl-index=0:visual-constraint="222,33"
++
Simple merge