implemented lacking GUIs and corrected errors
authorpinene <epinzolas001@ikasle.ehu.eus>
Fri, 6 Mar 2015 09:41:12 +0000 (10:41 +0100)
committerpinene <epinzolas001@ikasle.ehu.eus>
Fri, 6 Mar 2015 09:41:12 +0000 (10:41 +0100)
15 files changed:
ruralHouses/db/DBjcampos004.yap [new file with mode: 0644]
ruralHouses/src/businessLogic/FacadeImplementation.java
ruralHouses/src/businessLogic/HouseManager.java
ruralHouses/src/businessLogic/HouseManagerInterface.java
ruralHouses/src/businessLogic/LoginManager.java
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/domain/Owner.java
ruralHouses/src/domain/RuralHouse.java
ruralHouses/src/gui/DeleteHouseGUI.java [new file with mode: 0644]
ruralHouses/src/gui/HousesRelatedOwnerGUI.java [new file with mode: 0644]
ruralHouses/src/gui/LoginGUI.java
ruralHouses/src/gui/ModifyHouseGUI.java [new file with mode: 0644]
ruralHouses/src/gui/NewHouseGUI.java [new file with mode: 0644]
ruralHouses/src/gui/OwnerMenuGUI.java [new file with mode: 0644]
ruralHouses/src/gui/StartWindow.java

diff --git a/ruralHouses/db/DBjcampos004.yap b/ruralHouses/db/DBjcampos004.yap
new file mode 100644 (file)
index 0000000..212f8cd
Binary files /dev/null and b/ruralHouses/db/DBjcampos004.yap differ
index 9c2e8b1..0caab61 100644 (file)
@@ -72,6 +72,7 @@ public class FacadeImplementation extends UnicastRemoteObject implements Applica
        Exception {             
                return dbMngr.getAllRuralHouses();              
        }
+
        
 
        public Booking createBooking(RuralHouse ruralHouse, Date firstDate, Date lastDate, String bookTelephoneNumber)
index 21b8925..82eedfc 100644 (file)
@@ -18,41 +18,31 @@ public class HouseManager implements HouseManagerInterface {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
-                       // TODO Auto-generated catch block
+
                        e.printStackTrace();
                }
        }
 
-       @Override
-       public boolean registerNewHouse(int houseNumber, Owner owner, String town,
-                       int nRooms, int nKitchens, int nBaths, int nLivings, int nParkings) {
-               // TODO Auto-generated method stub
-               boolean stored = false;
-               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
-                       return false;
-               HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths,
-                               nLivings, nParkings);
-               stored = this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber,
-                               owner, town, feature));
-               return stored;
 
-       }
 
        @Override
        public boolean registerNewHouse(int houseNumber, Owner owner,
                        String description, String town, int nRooms, int nKitchens,
                        int nBaths, int nLivings, int nParkings) {
-               // TODO Auto-generated method stub
                boolean stored = false;
                if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
                        return false;
                HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths,
                                nLivings, nParkings);
-               stored = this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber,
-                               owner, description, town, feature));
+               RuralHouse rh = new RuralHouse(houseNumber,
+                               owner, description, town, feature);
+               owner.getRuralHouses().add(rh);
+               stored = this.dbMngr.storeRuralHouses(rh);
                return stored;
        }
 
+       
+       
        public void removeHouse(int houseNumber) {
                this.dbMngr.removeHouse(houseNumber);
        }
index 7a0656f..65e2baa 100644 (file)
@@ -10,8 +10,7 @@ import domain.RuralHouse;
 
 public interface HouseManagerInterface {
 
-       public boolean registerNewHouse(int houseNumber, Owner owner, String town,
-                       int nRooms, int nKitchens, int nBaths, int nLivings, int nParkings);
+
 
        public boolean registerNewHouse(int houseNumber, Owner owner,
                        String description, String town, int nRooms, int nKitchens,
index 966168c..72ce86b 100644 (file)
@@ -1,5 +1,6 @@
 package businessLogic;
 
+
 import java.util.Vector;
 
 import dataAccess.DB4oManager;
index 26fa6f3..b0e4005 100644 (file)
@@ -39,6 +39,7 @@ public class DB4oManager {
                        db = Db4o.openFile(Db4o.newConfiguration(), db4oFileName);
                        db.ext().configure().updateDepth(5);
 
+
                } else if (mode.compareTo("initialize") == 0) {
                        try {
                                new File(db4oFileName).delete();
@@ -51,7 +52,7 @@ public class DB4oManager {
                                jon.setBankAccount("1349 5677 21 2133567777");
                                alfredo.addRuralHouse(3, "Casa del abuelo", "Pitillas", 5, 5,
                                                5, 5, 5);
-                               alfredo.addRuralHouse(4, "Murgia", 6, 6, 6, 6, 6);
+                               alfredo.addRuralHouse(4,"", "Murgia", 6, 6, 6, 6, 6);
                                alfredo.setBankAccount("4144 0087 23 9700002133");
                                Account jonAcc = new Account("userJon", "passJon", jon);
                                Account alfredoAcc = new Account("userAlfredo", "passAlfredo",
@@ -76,6 +77,7 @@ public class DB4oManager {
                return db;
        }
 
+
        /**
         * @param rh
         */
@@ -102,6 +104,7 @@ public class DB4oManager {
         * This method finds all existing owners
         * 
         */
+
        public Vector<Owner> getOwners() throws RemoteException, Exception {
                DB4oManager.openDatabase("open");
                ObjectContainer db = DB4oManager.getContainer();
@@ -116,6 +119,7 @@ public class DB4oManager {
                } finally {
                        db.close();
                }
+
        }
 
        /**
@@ -148,6 +152,7 @@ public class DB4oManager {
         * @throws Exception
         */
        public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
+
                        Exception {
                DB4oManager.openDatabase("open");
                ObjectContainer db = DB4oManager.getContainer();
@@ -171,6 +176,7 @@ public class DB4oManager {
         *            number, start day, last day and price
         * @return None
         */
+
        public Offer createOffer(RuralHouse ruralHouse, Date firstDay,
                        Date lastDay, float price) throws RemoteException, Exception {
                DB4oManager.openDatabase("open");
@@ -191,6 +197,7 @@ public class DB4oManager {
                return o;
        }
 
+
        /**
         * @param rh
         * @return
@@ -201,6 +208,7 @@ public class DB4oManager {
                try {
                        ObjectContainer db = DB4oManager.getContainer();
                        RuralHouse proto = new RuralHouse(rh.getHouseNumber(), null,
+
                                        rh.getDescription(), rh.getTown(), rh.getFeatures());
                        ObjectSet<RuralHouse> result = db.queryByExample(proto);
                        return rh = (RuralHouse) result.next();
@@ -210,7 +218,8 @@ public class DB4oManager {
                } finally {
                        db.close();
                }
-       }
+
+       } 
 
        /**
         * @param offer
@@ -236,6 +245,7 @@ public class DB4oManager {
                } finally {
                        db.close();
                }
+
        }
 
        public void removeHouse(int houseNumber) {
index 35b0296..cd68e3c 100644 (file)
@@ -37,17 +37,11 @@ public class Owner implements Serializable {
                this.bankAccount = bankAccount;
        }
 
-       public Vector<RuralHouse> getRuralHouses() {
-               return ruralHouses;
+       public Vector<RuralHouse> getRuralHouses(){
+               return this.ruralHouses;
        }
 
-       public RuralHouse addRuralHouse(int houseNumber, String town, int nRooms,
-                       int nKitchens, int nBaths, int nLivings, int nParkings) {
-               HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths, nLivings, nParkings);
-               RuralHouse rh = new RuralHouse(houseNumber, this, town,feature);
-               ruralHouses.add(rh);
-               return rh;
-       }
+
 
        public RuralHouse addRuralHouse(int houseNumber, String description,
                        String town, int nRooms, int nKitchens, int nBaths, int nLivings,
index 50e46fa..7087a66 100644 (file)
@@ -29,14 +29,7 @@ public class RuralHouse implements Serializable {
                offers=new Vector<Offer>();
        }
        
-       public RuralHouse(int houseNumber, Owner owner, String town , HouseFeatures features) {
-               this.houseNumber = houseNumber;
-               this.description = null;
-               this.owner = owner;
-               this.town = town;
-               this.features = features;
-               offers=new Vector<Offer>();
-       }
+       
 
        public int getHouseNumber() {
                return houseNumber;
diff --git a/ruralHouses/src/gui/DeleteHouseGUI.java b/ruralHouses/src/gui/DeleteHouseGUI.java
new file mode 100644 (file)
index 0000000..0395a15
--- /dev/null
@@ -0,0 +1,91 @@
+package gui;
+
+import java.awt.BorderLayout;
+import java.awt.EventQueue;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+import javax.swing.JComboBox;
+import javax.swing.JRadioButton;
+import javax.swing.JButton;
+
+import businessLogic.FacadeImplementation;
+import businessLogic.HouseManager;
+
+import domain.Owner;
+import domain.RuralHouse;
+
+public class DeleteHouseGUI extends JFrame {
+
+       private JPanel contentPane;
+       private Owner owner;
+       private JComboBox comboBox;
+
+
+
+       /**
+        * Create the frame.
+        */
+       public DeleteHouseGUI(Owner o) {
+               o = owner;
+               setBounds(100, 100, 450, 300);
+               contentPane = new JPanel();
+               contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
+               setContentPane(contentPane);
+               
+               
+               
+               comboBox = new JComboBox();
+               
+               JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
+               
+               JButton btnDelete = new JButton("DELETE");
+               GroupLayout gl_contentPane = new GroupLayout(contentPane);
+               gl_contentPane.setHorizontalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(70)
+                                                       .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(85)
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                                               .addComponent(btnDelete)
+                                                               .addComponent(rdbtnIAmSure))))
+                                       .addContainerGap(954, Short.MAX_VALUE))
+               );
+               gl_contentPane.setVerticalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGap(50)
+                                       .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+                                       .addGap(68)
+                                       .addComponent(rdbtnIAmSure)
+                                       .addGap(47)
+                                       .addComponent(btnDelete)
+                                       .addContainerGap(493, Short.MAX_VALUE))
+               );
+               contentPane.setLayout(gl_contentPane);
+               
+               btnDelete.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent arg0) {
+                               actionListenerButton(arg0);
+                               
+                       }
+
+                       
+               });
+       }
+       
+       private void actionListenerButton(ActionEvent e){
+               RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
+               HouseManager hm = new HouseManager();
+               hm.removeHouse(toDel.getHouseNumber());
+       }
+}
diff --git a/ruralHouses/src/gui/HousesRelatedOwnerGUI.java b/ruralHouses/src/gui/HousesRelatedOwnerGUI.java
new file mode 100644 (file)
index 0000000..656d76f
--- /dev/null
@@ -0,0 +1,95 @@
+package gui;
+
+import java.awt.BorderLayout;
+import java.awt.EventQueue;
+import java.awt.Frame;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+import javax.swing.JButton;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+
+import domain.Owner;
+import domain.RuralHouse;
+
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+import javax.swing.JLabel;
+import java.awt.Color;
+import java.awt.Font;
+
+public class HousesRelatedOwnerGUI extends JFrame {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private JPanel contentPane;
+       private Owner owner;
+       /**
+        * Create the frame.
+        */
+       public HousesRelatedOwnerGUI(Owner o) {
+               this.getContentPane().setLayout(null);
+               owner = o;
+               setBounds(100, 100, 450, 562);
+               contentPane = new JPanel();
+               contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
+               setContentPane(contentPane);
+               
+               JButton btnCreateHouses = new JButton("Create Houses");
+               btnCreateHouses.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent arg0) {
+                               Frame a = new NewHouseGUI(owner);
+                               a.setVisible(true);
+                       }
+               });
+               
+               JButton btnModifyHouses = new JButton("Modify Houses");
+               btnModifyHouses.setEnabled(false);
+               btnModifyHouses.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               
+                               /* TODO to be implemented in a future.
+                               Frame a = new ModifyHouseGUI(owner);
+                               a.setVisible(true);
+                               */
+                       }
+               });
+               
+               JButton btnDeleteHouses = new JButton("Delete Houses");
+               btnDeleteHouses.setEnabled(false);
+               btnDeleteHouses.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               Frame a = new DeleteHouseGUI(owner);
+                               a.setVisible(true);
+                       }
+               });
+               GroupLayout gl_contentPane = new GroupLayout(contentPane);
+               gl_contentPane.setHorizontalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGap(110)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                               .addComponent(btnDeleteHouses, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE)
+                                               .addComponent(btnModifyHouses, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE)
+                                               .addComponent(btnCreateHouses, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE))
+                                       .addGap(121))
+               );
+               gl_contentPane.setVerticalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGap(88)
+                                       .addComponent(btnCreateHouses, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
+                                       .addGap(40)
+                                       .addComponent(btnModifyHouses, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE)
+                                       .addGap(39)
+                                       .addComponent(btnDeleteHouses, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE)
+                                       .addContainerGap(394, Short.MAX_VALUE))
+               );
+               contentPane.setLayout(gl_contentPane);
+       }
+}
index ef333d6..caeb1cd 100644 (file)
@@ -60,6 +60,7 @@ public class LoginGUI extends JFrame {
                        JButton loginButton = new JButton("Login");
                        loginButton.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent arg0) {
+
                                jButton_ActionPerformed(arg0);  
                                }                                       
                        });
@@ -80,20 +81,13 @@ public class LoginGUI extends JFrame {
                if(owner==null){
                        loginFeedback.setText("Incorrect username or password");
                }else{
-                       Vector<RuralHouse> ownerHouseList=null;
-                       try{
-                               ownerHouseList = StartWindow.getBusinessLogic().getRuralHouses(owner);
-                       }catch (Exception e1){
-                               e1.printStackTrace();
-                       }
-                       if(!ownerHouseList.isEmpty()){
+                       
+                       
+                       
                                this.setVisible(false);
-                               Frame a = new IntroduceOffer2GUI(ownerHouseList);
+                               Frame a = new OwnerMenuGUI(owner);
                                a.setVisible(true);
-                       }
-                       else if(ownerHouseList.isEmpty())
-                               loginFeedback.setText("Login OK , but no houses in your name");
-               }
+               }       
 
        }
 
diff --git a/ruralHouses/src/gui/ModifyHouseGUI.java b/ruralHouses/src/gui/ModifyHouseGUI.java
new file mode 100644 (file)
index 0000000..a273b6e
--- /dev/null
@@ -0,0 +1,209 @@
+package gui;
+
+import java.awt.BorderLayout;
+import java.awt.EventQueue;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+
+import domain.Owner;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.SwingConstants;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+
+public class ModifyHouseGUI extends JFrame {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private JPanel contentPane;
+       private Owner owner;
+       private JLabel lblTown;
+       private JTextField Town_f;
+       private JLabel lblDescription;
+       private JTextField description_f;
+       private JLabel lblKitchen;
+       private JTextField kitchens_f;
+       private JLabel lblRooms;
+       private JTextField rooms_f;
+       private JLabel lblLivings;
+       private JTextField lRooms_f;
+       private JLabel lblParkings;
+       private JTextField parkings_f;
+       private JLabel lblBaths;
+       private JTextField baths_f;
+       private JButton btnRegister;
+       private JComboBox comboBox;
+       
+
+
+       /**
+        * Create the frame.
+        */
+       public ModifyHouseGUI(Owner o) {
+               this.getContentPane().setLayout(null);
+               owner = o;
+               setBounds(100, 100, 500, 583);
+               contentPane = new JPanel();
+               contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
+               setContentPane(contentPane);
+               
+               JLabel lblCode = new JLabel("House Code:");
+               lblCode.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               lblTown = new JLabel("Town:");
+               lblTown.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               Town_f = new JTextField();
+               Town_f.setColumns(10);
+               
+               lblDescription = new JLabel("Description:");
+               lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               description_f = new JTextField();
+               description_f.setColumns(10);
+               
+               lblKitchen = new JLabel("Kitchens:");
+               lblKitchen.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               kitchens_f = new JTextField();
+               kitchens_f.setColumns(10);
+               
+               lblRooms = new JLabel("Rooms:");
+               lblRooms.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               rooms_f = new JTextField();
+               rooms_f.setColumns(10);
+               
+               lblLivings = new JLabel("Living rooms:");
+               lblLivings.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               lRooms_f = new JTextField();
+               lRooms_f.setColumns(10);
+               
+               lblParkings = new JLabel("Parkings:");
+               lblParkings.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               parkings_f = new JTextField();
+               parkings_f.setColumns(10);
+               
+               lblBaths = new JLabel("Baths:");
+               lblBaths.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               baths_f = new JTextField();
+               baths_f.setColumns(10);
+               
+               btnRegister = new JButton("Register House");
+               
+               comboBox = new JComboBox();
+               GroupLayout gl_contentPane = new GroupLayout(contentPane);
+               gl_contentPane.setHorizontalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addContainerGap()
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addComponent(lblParkings, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                       .addGap(18)
+                                                                       .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addComponent(lblRooms, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                       .addGap(18)
+                                                                       .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addComponent(lblCode)
+                                                                       .addPreferredGap(ComponentPlacement.UNRELATED)
+                                                                       .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 124, GroupLayout.PREFERRED_SIZE))
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addComponent(lblBaths, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                       .addGap(18)
+                                                                       .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addComponent(lblTown, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                       .addGap(18)
+                                                                       .addComponent(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addGap(17)
+                                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                                       .addComponent(lblLivings)
+                                                                                       .addGap(18)
+                                                                                       .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                                       .addComponent(lblKitchen, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                                       .addGap(18)
+                                                                                       .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addGap(18)
+                                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                                       .addGap(10)
+                                                                                       .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE))
+                                                                               .addComponent(lblDescription, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)))))
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(140)
+                                                       .addComponent(btnRegister)))
+                                       .addContainerGap())
+               );
+               gl_contentPane.setVerticalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGap(20)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(60)
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
+                                                               .addComponent(lblCode)
+                                                               .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                       .addPreferredGap(ComponentPlacement.UNRELATED)
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
+                                                               .addComponent(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+                                                               .addComponent(lblTown)))
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(63)
+                                                       .addComponent(lblDescription)
+                                                       .addPreferredGap(ComponentPlacement.UNRELATED)
+                                                       .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)))
+                                       .addGap(71)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(3)
+                                                       .addComponent(lblRooms))
+                                               .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(3)
+                                                       .addComponent(lblKitchen))
+                                               .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                       .addGap(18)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                               .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                                       .addGroup(gl_contentPane.createSequentialGroup()
+                                                               .addGap(3)
+                                                               .addComponent(lblBaths))
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
+                                                               .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+                                                               .addComponent(lblLivings)))
+                                               .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                       .addGap(30)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(3)
+                                                       .addComponent(lblParkings))
+                                               .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                       .addGap(41)
+                                       .addComponent(btnRegister)
+                                       .addGap(54))
+               );
+               contentPane.setLayout(gl_contentPane);
+       }
+}
diff --git a/ruralHouses/src/gui/NewHouseGUI.java b/ruralHouses/src/gui/NewHouseGUI.java
new file mode 100644 (file)
index 0000000..bb72996
--- /dev/null
@@ -0,0 +1,238 @@
+package gui;
+
+import java.awt.BorderLayout;
+import java.awt.EventQueue;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+
+import domain.HouseFeatures;
+import domain.Owner;
+import domain.RuralHouse;
+
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.SwingConstants;
+import javax.swing.JButton;
+import java.awt.Color;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import javax.swing.JTextPane;
+
+import businessLogic.HouseManager;
+
+public class NewHouseGUI extends JFrame {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private JPanel contentPane;
+       private Owner owner;
+       private JLabel lblCode ;
+       private JTextField Code_f;
+       private JLabel lblTown;
+       private JTextField Town_f;
+       private JLabel lblDescription;
+       private JTextField description_f;
+       private JLabel lblKitchen;
+       private JTextField kitchens_f;
+       private JLabel lblRooms;
+       private JTextField rooms_f;
+       private JLabel lblLivings;
+       private JTextField lRooms_f;
+       private JLabel lblParkings;
+       private JTextField parkings_f;
+       private JLabel lblBaths;
+       private JTextField baths_f;
+       private JButton btnRegister;
+
+
+       /**
+        * Create the frame.
+        */
+       public NewHouseGUI(Owner o) {
+               this.setTitle("New House");
+               setBackground(Color.WHITE);
+               this.getContentPane().setLayout(null);
+               owner = o;
+               setBounds(100, 100, 500, 583);
+               contentPane = new JPanel();
+               contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
+               setContentPane(contentPane);
+               
+               lblCode = new JLabel("House Code:");
+               lblCode.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               Code_f = new JTextField();
+               Code_f.setColumns(10);
+               
+               lblTown = new JLabel("Town:");
+               lblTown.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               Town_f = new JTextField();
+               Town_f.setColumns(10);
+               
+               lblDescription = new JLabel("Description(optional):");
+               lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               description_f = new JTextField();
+               description_f.setToolTipText("");
+               description_f.setHorizontalAlignment(SwingConstants.LEFT);
+               description_f.setColumns(10);
+               
+               lblKitchen = new JLabel("Kitchens:");
+               lblKitchen.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               kitchens_f = new JTextField();
+               kitchens_f.setColumns(10);
+               
+               lblRooms = new JLabel("Rooms:");
+               lblRooms.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               rooms_f = new JTextField();
+               rooms_f.setColumns(10);
+               
+               lblLivings = new JLabel("Living rooms:");
+               lblLivings.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               lRooms_f = new JTextField();
+               lRooms_f.setColumns(10);
+               
+               lblParkings = new JLabel("Parkings:");
+               lblParkings.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               parkings_f = new JTextField();
+               parkings_f.setColumns(10);
+               
+               lblBaths = new JLabel("Baths:");
+               lblBaths.setHorizontalAlignment(SwingConstants.RIGHT);
+               
+               baths_f = new JTextField();
+               baths_f.setColumns(10);
+               
+               btnRegister = new JButton("Register House");
+               btnRegister.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent arg0) {
+                               try {
+                                       HouseManager hm = new HouseManager();
+                                       hm.registerNewHouse(Integer.parseInt(Code_f.getText()),
+                                                               owner, description_f.getText(),
+                                                               Town_f.getText() ,Integer.parseInt(rooms_f.getText()),
+                                                                               Integer.parseInt(kitchens_f.getText()),
+                                                                               Integer.parseInt(baths_f.getText()),
+                                                                               Integer.parseInt(lRooms_f.getText()),
+                                                                               Integer.parseInt(parkings_f.getText()) );
+                               
+                               }
+                               catch(NumberFormatException e ){
+                                       e.printStackTrace();
+                               }
+                       }
+               });
+               GroupLayout gl_contentPane = new GroupLayout(contentPane);
+               gl_contentPane.setHorizontalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(140)
+                                                       .addComponent(btnRegister))
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addContainerGap()
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                                                               .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                                                                       .addGroup(gl_contentPane.createSequentialGroup()
+                                                                                               .addComponent(lblTown, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                                               .addGap(18)
+                                                                                               .addComponent(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
+                                                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                                                       .addComponent(lblLivings)
+                                                                                                       .addGap(18)
+                                                                                                       .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                                                       .addComponent(lblCode)
+                                                                                                       .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                                                                                                       .addComponent(Code_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
+                                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                                       .addComponent(lblBaths, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                                       .addGap(18)
+                                                                                       .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
+                                                                       .addGap(29)
+                                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                                                               .addComponent(lblDescription)
+                                                                               .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE)))
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addComponent(lblKitchen, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                       .addGap(18)
+                                                                       .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                                       .addComponent(lblRooms, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                                       .addGap(18)
+                                                                       .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(26)
+                                                       .addComponent(lblParkings, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
+                                                       .addPreferredGap(ComponentPlacement.UNRELATED)
+                                                       .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
+                                       .addContainerGap(885, Short.MAX_VALUE))
+               );
+               gl_contentPane.setVerticalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGap(20)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(63)
+                                                       .addComponent(lblDescription)
+                                                       .addPreferredGap(ComponentPlacement.RELATED)
+                                                       .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE))
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(60)
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
+                                                               .addComponent(lblCode)
+                                                               .addComponent(Code_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                                       .addPreferredGap(ComponentPlacement.UNRELATED)
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
+                                                               .addComponent(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+                                                               .addComponent(lblTown))
+                                                       .addGap(18)
+                                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
+                                                               .addComponent(lblLivings)
+                                                               .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
+                                       .addGap(63)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(3)
+                                                       .addComponent(lblRooms))
+                                               .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                       .addPreferredGap(ComponentPlacement.RELATED)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(3)
+                                                       .addComponent(lblKitchen)))
+                                       .addPreferredGap(ComponentPlacement.RELATED, 206, Short.MAX_VALUE)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addGroup(gl_contentPane.createSequentialGroup()
+                                                       .addGap(3)
+                                                       .addComponent(lblBaths))
+                                               .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                       .addGap(45)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
+                                               .addComponent(lblParkings)
+                                               .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
+                                       .addGap(88)
+                                       .addComponent(btnRegister)
+                                       .addGap(54))
+               );
+               contentPane.setLayout(gl_contentPane);
+       }
+}
diff --git a/ruralHouses/src/gui/OwnerMenuGUI.java b/ruralHouses/src/gui/OwnerMenuGUI.java
new file mode 100644 (file)
index 0000000..532d373
--- /dev/null
@@ -0,0 +1,80 @@
+package gui;
+
+import java.awt.BorderLayout;
+import java.awt.EventQueue;
+import java.awt.Frame;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+import javax.swing.JButton;
+
+import domain.Owner;
+import domain.RuralHouse;
+
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.util.Vector;
+
+public class OwnerMenuGUI extends JFrame {
+
+       /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       private JPanel contentPane;
+       private Owner owner;
+
+
+       /**
+        * Create the frame.
+        */
+       public OwnerMenuGUI(Owner o) {
+               this.setTitle("Owner Menu");
+               this.getContentPane().setLayout(null);
+               owner = o;
+               setBounds(100, 100, 450, 473);
+               contentPane = new JPanel();
+               contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
+               setContentPane(contentPane);
+               
+               JButton btnHouses = new JButton("Houses");
+               btnHouses.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               Frame a = new HousesRelatedOwnerGUI(owner);
+                               a.setVisible(true);
+                       }
+               });
+               
+               JButton btnOffers = new JButton("Offers");
+               btnOffers.addActionListener(new ActionListener() {
+                       public void actionPerformed(ActionEvent e) {
+                               Frame a = new IntroduceOffer2GUI(owner.getRuralHouses());
+                               a.setVisible(true);
+                       }
+               });
+               GroupLayout gl_contentPane = new GroupLayout(contentPane);
+               gl_contentPane.setHorizontalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGap(115)
+                                       .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
+                                               .addComponent(btnOffers, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE)
+                                               .addComponent(btnHouses, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE))
+                                       .addContainerGap(145, Short.MAX_VALUE))
+               );
+               gl_contentPane.setVerticalGroup(
+                       gl_contentPane.createParallelGroup(Alignment.LEADING)
+                               .addGroup(gl_contentPane.createSequentialGroup()
+                                       .addGap(62)
+                                       .addComponent(btnHouses, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
+                                       .addGap(58)
+                                       .addComponent(btnOffers, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
+                                       .addContainerGap(142, Short.MAX_VALUE))
+               );
+               contentPane.setLayout(gl_contentPane);
+       }
+
+}
index 54fe389..f33bc0f 100644 (file)
@@ -41,7 +41,7 @@ public class StartWindow extends JFrame {
                // this.setSize(271, 295);
                this.setSize(350, 400);
                this.setContentPane(getJContentPane());
-               this.setTitle("Use Cases");
+               this.setTitle("Rural Houses");
        }
 
        private JPanel getJContentPane() {