Merge branch 'master' of https://xp-dev.com/git/RRRRHHHH_Code
authorpinene <epinzolas001@ikasle.ehu.es>
Sun, 19 Apr 2015 14:18:02 +0000 (16:18 +0200)
committerpinene <epinzolas001@ikasle.ehu.es>
Sun, 19 Apr 2015 14:18:02 +0000 (16:18 +0200)
Conflicts:
ruralHouses/src/businessLogic/OfferManager.java
ruralHouses/src/gui/HouseFeaturesGUI.java
ruralHouses/src/gui/ModifyHouseGUI.java
ruralHouses/src/gui/StartWindow.java

ruralHouses/src/businessLogic/OfferManager.java
ruralHouses/src/gui/DeleteOfferGUI.java
ruralHouses/src/gui/HouseFeaturesGUI.java
ruralHouses/src/gui/LoginGUI.java
ruralHouses/src/gui/ModifyHouseGUI.java
ruralHouses/src/gui/RequestDeleteHouseGUI.java
ruralHouses/src/gui/StartWindow.java

index a0cd67e..8c6fb3e 100644 (file)
@@ -3,9 +3,6 @@ package businessLogic;
 import java.rmi.RemoteException;
 import java.sql.Date;
 
-import com.db4o.ObjectContainer;
-import com.db4o.ObjectSet;
-
 import dataAccess.DB4oManager;
 import domain.Offer;
 import domain.RuralHouse;
@@ -16,7 +13,6 @@ public final class OfferManager {
 
        private int offerNumber = 0;
        dataAccess.DB4oManager dbMngr;
-       private static OfferManager theOfferManager;
 
        public OfferManager() {
                try {
@@ -26,31 +22,7 @@ public final class OfferManager {
                }
        }
 
-       public static int getNumber() {
-               ObjectContainer db=DB4oManager.getContainer();
-               OfferManager o=getInstance();
-               o.offerNumber++;
-               db.store(o);
-               db.commit();
-               return o.offerNumber;
-       }
 
-       /**
-        * This method returns the instance of the OfferManager class 
-        * 
-        * @return the offer manager
-        */
-       public static OfferManager getInstance()  {
-               ObjectContainer db=DB4oManager.getContainer();
-               OfferManager b = new OfferManager();
-               ObjectSet<OfferManager> result = db.queryByExample(b);
-               if (!result.hasNext()){
-                       theOfferManager = new OfferManager();
-                       db.store(theOfferManager);
-                       db.commit();
-               } else theOfferManager=(OfferManager)result.next();
-               return theOfferManager;
-       }
        
        /**
         * This method creates an offer with a house number, first day, last day and price
@@ -66,8 +38,8 @@ public final class OfferManager {
 
                boolean b = dbMngr.existsOverlappingOffer(ruralHouse,firstDay,lastDay); // The ruralHouse object in the client may not be updated
                if (!b) {
-                       ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);
-                       return dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);                   
+                       dbMngr.createOffer(ruralHouse,firstDay,lastDay,price);
+                       return ruralHouse.createOffer(offerNumber, firstDay, lastDay, price);                   
                }
                return null;
        }
index 90f538e..cd2665a 100644 (file)
@@ -55,10 +55,10 @@ public class DeleteOfferGUI extends JFrame {
                }
 
                JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
-               rdbtnIAmSure.setBounds(101, 134, 71, 23);
+               rdbtnIAmSure.setBounds(101, 134, 108, 23);
 
                btnDelete = new JButton("DELETE");
-               btnDelete.setBounds(92, 226, 69, 23);
+               btnDelete.setBounds(92, 226, 117, 23);
                btnDelete.setEnabled(false);
 
                comboBox.addItemListener(new ItemListener() {
@@ -104,7 +104,7 @@ public class DeleteOfferGUI extends JFrame {
                contentPane.add(comboBox_1);
                
                feedback = new JLabel("");
-               feedback.setBounds(140, 178, 155, 23);
+               feedback.setBounds(140, 178, 202, 23);
                contentPane.add(feedback);
 
                btnDelete.addActionListener(new ActionListener() {
index 95ddb3a..a8643e4 100644 (file)
@@ -9,7 +9,6 @@ import java.awt.event.MouseEvent;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Vector;
-
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
@@ -53,7 +52,8 @@ public class HouseFeaturesGUI extends JFrame {
        private RuralHouse rh;
        private JTextField telIn;
        private int row;
-       private JLabel phoneNum;
+       private JLabel labelPhone;
+
 
        /**
         * Create the frame.
@@ -196,10 +196,11 @@ public class HouseFeaturesGUI extends JFrame {
                telIn.setBounds(99, 505, 129, 20);
                contentPane.add(telIn);
                telIn.setColumns(10);
-               
-               phoneNum = new JLabel("");
-               phoneNum.setBounds(215, 255, 201, 15);
-               contentPane.add(phoneNum);
+
+               labelPhone = new JLabel("");
+               labelPhone.setBounds(238, 252, 178, 14);
+               contentPane.add(labelPhone);
+
                table.addMouseListener( new MouseAdapter(){                     
                        @Override
                        public void mouseClicked(MouseEvent arg0) {
@@ -250,24 +251,23 @@ public class HouseFeaturesGUI extends JFrame {
        private void jButton_ActionPerformed(ActionEvent arg0) {
                BookingManager bookingM = new BookingManager();
                //RegExp to see if telephone number is correct??TODO
-               if (!telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")){
-                       phoneNum.setText("Wrong phone format");
-               }else {
-                       phoneNum.setText("");
-
-               Booking book = null;
-               try {
-                       if (table.getRowCount()!=0)
-                               book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText());
-               } catch (Exception e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } 
-               if (book != null) {
-                       BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
-                                       book);
-                       confirmWindow.setVisible(true);
-               }
+               if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")) {
+                       Booking book = null;
+                       try {
+                               if (table.getRowCount()!=0)
+                                       book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText());
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       } 
+                       if (book != null) {
+                               BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
+                                               book);
+                               confirmWindow.setVisible(true);
+                       }
+               } else {
+                       labelPhone.setText("Phone format is wrong");
+
+               
                }
        }
 }
index 2689506..1e59e89 100644 (file)
@@ -81,7 +81,8 @@ public class LoginGUI extends JFrame {
        private void jButton_ActionPerformed(ActionEvent e){
                        
                Account acc = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword()));
-               if (acc.getAdmin()) {
+               if (acc == null) loginFeedback.setText("Incorrect username or password");
+               else if( acc.getAdmin()) {
                        this.setVisible(false);
                        Frame a = new AdminMenuGUI();
                        a.setVisible(true);
index d902074..6b64b19 100644 (file)
@@ -52,9 +52,10 @@ public class ModifyHouseGUI extends JFrame {
        /**
         * Create the frame.
         */
-       public ModifyHouseGUI(Owner o) {
+       public ModifyHouseGUI(final Owner o) {
                this.distric=Districs.longNames();
-               comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+                comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+
                                this.distric));
                this.getContentPane().setLayout(null);
                owner = o;
index e9ad2e8..3285a89 100644 (file)
@@ -46,7 +46,7 @@ public class RequestDeleteHouseGUI extends JFrame {
                
 
                JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
-               rdbtnIAmSure.setBounds(90, 154, 71, 23);
+               rdbtnIAmSure.setBounds(90, 154, 90, 23);
                
                btnDelete = new JButton("REQUEST");
                btnDelete.setBounds(90, 213, 90, 23);
index 663369b..385d09b 100644 (file)
@@ -19,6 +19,7 @@ import javax.swing.UIManager;
 import configuration.ConfigXML;
 
 
+@SuppressWarnings("deprecation")
 public class StartWindow extends JFrame {
        
        private static final long serialVersionUID = 1L;
@@ -48,7 +49,6 @@ public class StartWindow extends JFrame {
 
                        c=configuration.ConfigXML.getInstance();
 
-
                }catch (com.db4o.ext.DatabaseFileLockedException e) {
                        a.lblNewLabel.setText("Database locked: Do not run BusinessLogicServer or BusinessLogicServer!!");
                        a.lblNewLabel.setForeground(Color.RED);         
@@ -58,7 +58,6 @@ public class StartWindow extends JFrame {
                        a.lblNewLabel.setForeground(Color.RED);         
                        System.out.println("Error in StartWindow: "+e.toString());
                }
-               //a.pack();