From: pinene Date: Fri, 6 Mar 2015 09:41:12 +0000 (+0100) Subject: implemented lacking GUIs and corrected errors X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/commitdiff_plain/a927255f6eb55fb1f52738b9b88ce51f9b0ed9bc?hp=7b7027e13369849d213c9b4e118395e4bfd23dc2 implemented lacking GUIs and corrected errors --- diff --git a/ruralHouses/db/DBjcampos004.yap b/ruralHouses/db/DBjcampos004.yap index 41236b6..212f8cd 100644 Binary files a/ruralHouses/db/DBjcampos004.yap and b/ruralHouses/db/DBjcampos004.yap differ diff --git a/ruralHouses/src/businessLogic/ApplicationFacadeInterface.java b/ruralHouses/src/businessLogic/ApplicationFacadeInterface.java index 8863af3..ef3cad2 100644 --- a/ruralHouses/src/businessLogic/ApplicationFacadeInterface.java +++ b/ruralHouses/src/businessLogic/ApplicationFacadeInterface.java @@ -1,7 +1,6 @@ package businessLogic; import java.rmi.*; - import java.util.Vector; import java.util.Date; @@ -9,23 +8,13 @@ import domain.Booking; import domain.Offer; import domain.Owner; import domain.RuralHouse; - -import exceptions.OfferCanNotBeBooked; +import exceptions.OfferCanNotBeBooked; public interface ApplicationFacadeInterface extends Remote { /** - * This method obtains an owner's rural houses - * - * @param owner object - * - * @return a vector of Rural Houses - */ - Vector getRuralHouses(Owner owner) - throws RemoteException; - - /** - * This method creates an offer with a house number, first day, last day and price + * This method creates an offer with a house number, first day, last day and + * price * * @param House * number, start day, last day and price @@ -46,26 +35,38 @@ public interface ApplicationFacadeInterface extends Remote { String telephoneNumber) throws RemoteException, OfferCanNotBeBooked; /** - * This method obtains available offers for a concrete house in a certain period + * This method obtains available offers for a concrete house in a certain + * period * - * @param houseNumber, the house number where the offers must be obtained - * @param firstDay, first day in a period range - * @param lastDay, last day in a period range - * @return a vector of offers(Offer class) available in this period + * @param houseNumber + * , the house number where the offers must be obtained + * @param firstDay + * , first day in a period range + * @param lastDay + * , last day in a period range + * @return a vector of offers(Offer class) available in this period */ - Vector getOffers(RuralHouse houseNumber, Date firstDay, Date lastDay) + Vector getOffers(RuralHouse houseNumber, Date firstDay, Date lastDay) throws RemoteException, Exception; - + /** - * This method finds existing owners + * This method finds existing owners * */ - public Vector getOwners() throws RemoteException, + public Vector getOwners() throws RemoteException, Exception; + + /** + * This method obtains an owner's rural houses + * + * @param owner + * object + * + * @return a vector of Rural Houses + */ + public Vector getRuralHouses(Owner owner) + throws RemoteException; + + public Vector getAllRuralHouses() throws RemoteException, Exception; - - - - public Vector getAllRuralHouses()throws RemoteException, - Exception; - + } \ No newline at end of file diff --git a/ruralHouses/src/businessLogic/FacadeImplementation.java b/ruralHouses/src/businessLogic/FacadeImplementation.java index 162a38b..0caab61 100644 --- a/ruralHouses/src/businessLogic/FacadeImplementation.java +++ b/ruralHouses/src/businessLogic/FacadeImplementation.java @@ -2,23 +2,19 @@ package businessLogic; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; - import java.util.Date; import java.util.Vector; - import java.sql.SQLException; import com.db4o.ObjectContainer; import com.db4o.ObjectSet; -import configuration.Config; +import configuration.Config; import dataAccess.DB4oManager; - import domain.Booking; import domain.Offer; import domain.Owner; import domain.RuralHouse; - import exceptions.OfferCanNotBeBooked; public class FacadeImplementation extends UnicastRemoteObject implements ApplicationFacadeInterface { @@ -31,17 +27,6 @@ public class FacadeImplementation extends UnicastRemoteObject implements Applica dbMngr = DB4oManager.getInstance(); } - /** - * This method obtains an owner's rural houses - * - * @param owner object - * - * @return a vector of Rural Houses - */ - public Vector getRuralHouses(Owner owner) - throws RemoteException { - return owner.getRuralHouses(); - } public Offer createOffer(RuralHouse ruralHouse, Date firstDay, Date lastDay, float price) throws RemoteException, Exception { @@ -70,6 +55,19 @@ public class FacadeImplementation extends UnicastRemoteObject implements Applica return dbMngr.getOwners(); } + /** + * This method obtains an owner's rural houses + * + * @param owner object + * + * @return a vector of Rural Houses + */ + public Vector getRuralHouses(Owner owner) + throws RemoteException { + return owner.getRuralHouses(); + } + + public Vector getAllRuralHouses() throws RemoteException, Exception { return dbMngr.getAllRuralHouses(); diff --git a/ruralHouses/src/businessLogic/HouseManager.java b/ruralHouses/src/businessLogic/HouseManager.java new file mode 100644 index 0000000..82eedfc --- /dev/null +++ b/ruralHouses/src/businessLogic/HouseManager.java @@ -0,0 +1,62 @@ +package businessLogic; + +import java.rmi.RemoteException; +import java.util.Date; +import java.util.Vector; + +import dataAccess.DB4oManager; +import domain.Account; +import domain.HouseFeatures; +import domain.Offer; +import domain.Owner; +import domain.RuralHouse; + +public class HouseManager implements HouseManagerInterface { + DB4oManager dbMngr; + + public HouseManager() { + try { + dbMngr = DB4oManager.getInstance(); + } catch (Exception e) { + + e.printStackTrace(); + } + } + + + + @Override + public boolean registerNewHouse(int houseNumber, Owner owner, + String description, String town, int nRooms, int nKitchens, + int nBaths, int nLivings, int nParkings) { + boolean stored = false; + if (nKitchens < 1 || nLivings < 3 || nBaths < 2) + return false; + HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths, + nLivings, nParkings); + 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); + } + + // For future implementation + // @Override + // public void modifyHouse(int houseNumber, Owner owner, String description, + // String town, int nRooms, int nKitchens, int nBaths, int nLivings, + // int nParkings) { + // // TODO Auto-generated method stub + // + // } + + // Maybe returning the offer is not necessary. Depends on GUI + // implementation. + +} diff --git a/ruralHouses/src/businessLogic/HouseManagerInterface.java b/ruralHouses/src/businessLogic/HouseManagerInterface.java new file mode 100644 index 0000000..65e2baa --- /dev/null +++ b/ruralHouses/src/businessLogic/HouseManagerInterface.java @@ -0,0 +1,27 @@ +package businessLogic; + +import java.rmi.RemoteException; +import java.util.Date; +import java.util.Vector; + +import domain.Offer; +import domain.Owner; +import domain.RuralHouse; + +public interface HouseManagerInterface { + + + + public boolean registerNewHouse(int houseNumber, Owner owner, + String description, String town, int nRooms, int nKitchens, + int nBaths, int nLivings, int nParkings); + + // For future implementation + // public void modifyHouse(int houseNumber, Owner owner, + // String description, String town, int nRooms, int nKitchens, + // int nBaths, int nLivings, int nParkings); + + public void removeHouse(int houseNumber); + + +} diff --git a/ruralHouses/src/businessLogic/LoginManager.java b/ruralHouses/src/businessLogic/LoginManager.java index 58ec39b..72ce86b 100644 --- a/ruralHouses/src/businessLogic/LoginManager.java +++ b/ruralHouses/src/businessLogic/LoginManager.java @@ -1,8 +1,6 @@ package businessLogic; - - import java.util.Vector; import dataAccess.DB4oManager; @@ -10,12 +8,11 @@ import domain.Account; import domain.Owner; public class LoginManager implements LoginManagerInterface { - //owners to be separated to accounts later on + DB4oManager dbMngr; - - + public LoginManager() { - + try { dbMngr = DB4oManager.getInstance(); } catch (Exception e) { @@ -24,21 +21,20 @@ public class LoginManager implements LoginManagerInterface { } } - @Override public Owner checkCredentials(String usr, String pwd) { try { Vector account = dbMngr.getAccount(usr, pwd); - if(account.isEmpty()) return null; - else return account.get(0).getOwner(); - + if (account.isEmpty()) + return null; + else + return account.get(0).getOwner(); + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } - - - + } diff --git a/ruralHouses/src/dataAccess/DB4oManager.java b/ruralHouses/src/dataAccess/DB4oManager.java index 3e9fd76..b0e4005 100644 --- a/ruralHouses/src/dataAccess/DB4oManager.java +++ b/ruralHouses/src/dataAccess/DB4oManager.java @@ -7,7 +7,6 @@ import java.util.Vector; //import java.util.Enumeration; //import java.util.Vector; - import businessLogic.BookingManager; import com.db4o.*; @@ -16,105 +15,153 @@ import configuration.Config; import domain.*; import exceptions.OfferCanNotBeBooked; -public class DB4oManager { +public class DB4oManager { private static ObjectContainer db; - private static DB4oManager theDB4oManager=new DB4oManager(); + private static DB4oManager theDB4oManager = new DB4oManager(); + /** + * + */ private DB4oManager() { - Config c=Config.getInstance(); - String dataBaseOpenMode=c.getDataBaseOpenMode(); + Config c = Config.getInstance(); + String dataBaseOpenMode = c.getDataBaseOpenMode(); DB4oManager.openDatabase(dataBaseOpenMode); } + /** + * @param mode + */ public static void openDatabase(String mode) { - Config c=Config.getInstance(); - String db4oFileName=c.getDb4oFilename(); - if (mode.compareTo("open")==0) { - db=Db4o.openFile(Db4o.newConfiguration(), db4oFileName); + Config c = Config.getInstance(); + String db4oFileName = c.getDb4oFilename(); + if (mode.compareTo("open") == 0) { + db = Db4o.openFile(Db4o.newConfiguration(), db4oFileName); db.ext().configure().updateDepth(5); - } else if (mode.compareTo("initialize")==0){ + + } else if (mode.compareTo("initialize") == 0) { try { - new File(db4oFileName).delete(); - db=Db4o.openFile(Db4o.newConfiguration(), db4oFileName); - db.ext().configure().updateDepth(5); - Owner jon = new Owner("Jon"); - Owner alfredo = new Owner("Alfredo"); - jon.addRuralHouse(1, "Ezkioko etxea","Ezkio"); - jon.addRuralHouse(2, "Eskiatzeko etxea","Jaca"); - jon.setBankAccount("1349 5677 21 2133567777"); - alfredo.addRuralHouse(3, "Casa del abuelo","Pitillas"); - alfredo.addRuralHouse(4, "Refugio","Murgia"); - alfredo.setBankAccount("4144 0087 23 9700002133"); - Account jonAcc = new Account("userJon", "passJon",jon); - Account alfredoAcc = new Account("userAlfredo", "passAlfredo",alfredo); - db.store(jon); - db.store(alfredo); - db.store(jonAcc); - db.store(alfredoAcc); - db.commit(); - System.out.println("DataBase Initialized"); + new File(db4oFileName).delete(); + db = Db4o.openFile(Db4o.newConfiguration(), db4oFileName); + db.ext().configure().updateDepth(5); + Owner jon = new Owner("Jon"); + Owner alfredo = new Owner("Alfredo"); + jon.addRuralHouse(1, "Ezkioko etxea", "Ezkio", 3, 3, 3, 3, 3); + jon.addRuralHouse(2, "Eskiatzeko etxea", "Jaca", 4, 4, 4, 4, 4); + 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.setBankAccount("4144 0087 23 9700002133"); + Account jonAcc = new Account("userJon", "passJon", jon); + Account alfredoAcc = new Account("userAlfredo", "passAlfredo", + alfredo); + db.store(jon); + db.store(alfredo); + db.store(jonAcc); + db.store(alfredoAcc); + db.commit(); + System.out.println("DataBase Initialized"); } finally { - db.close(); + db.close(); } - + } } - public static ObjectContainer getContainer() { + /** + * @return + */ + public static ObjectContainer getContainer() { return db; } - - + + + /** + * @param rh + */ + public boolean storeRuralHouses(RuralHouse rh) { + DB4oManager.openDatabase("open"); + boolean stored = false; + ObjectContainer db = DB4oManager.getContainer(); + RuralHouse house = new RuralHouse(rh.getHouseNumber(), null, null, + null, null); + try { + ObjectSet result = db.queryByExample(house); + if (result.isEmpty()) { + db.store(rh); + db.commit(); + stored = true; + } + } finally { + db.close(); + } + return stored; + } + /** - * This method finds all existing owners + * This method finds all existing owners * */ - public Vector getOwners() throws RemoteException, - Exception { + + public Vector getOwners() throws RemoteException, Exception { DB4oManager.openDatabase("open"); - ObjectContainer db=DB4oManager.getContainer(); + ObjectContainer db = DB4oManager.getContainer(); try { - Owner proto = new Owner(null,null); + Owner proto = new Owner(null, null); ObjectSet result = db.queryByExample(proto); - Vector owners=new Vector(); - while(result.hasNext()) - owners.add((Owner)result.next()); + Vector owners = new Vector(); + while (result.hasNext()) + owners.add((Owner) result.next()); return owners; } finally { db.close(); } - } - - public Vector getAccount(String usr, String pwd) throws RemoteException, - Exception { + + } + + /** + * @param usr + * @param pwd + * @return + * @throws RemoteException + * @throws Exception + */ + public Vector getAccount(String usr, String pwd) + throws RemoteException, Exception { DB4oManager.openDatabase("open"); - ObjectContainer db=DB4oManager.getContainer(); + ObjectContainer db = DB4oManager.getContainer(); try { - Account proto = new Account(usr,pwd, new Owner(null,null)); + Account proto = new Account(usr, pwd, new Owner(null, null)); ObjectSet result = db.queryByExample(proto); - Vector accounts=new Vector(); - while(result.hasNext()) - accounts.add((Account)result.next()); + Vector accounts = new Vector(); + while (result.hasNext()) + accounts.add((Account) result.next()); return accounts; } finally { db.close(); } } - + + /** + * @return + * @throws RemoteException + * @throws Exception + */ public Vector getAllRuralHouses() throws RemoteException, - Exception { + + Exception { DB4oManager.openDatabase("open"); - ObjectContainer db=DB4oManager.getContainer(); + ObjectContainer db = DB4oManager.getContainer(); try { - RuralHouse proto = new RuralHouse(0,null,null,null); + RuralHouse proto = new RuralHouse(0, null, null, null, null); ObjectSet result = db.queryByExample(proto); - Vector ruralHouses=new Vector(); - while(result.hasNext()) - ruralHouses.add((RuralHouse)result.next()); + Vector ruralHouses = new Vector(); + while (result.hasNext()) + ruralHouses.add((RuralHouse) result.next()); return ruralHouses; } finally { db.close(); @@ -122,57 +169,71 @@ public class DB4oManager { } /** - * This method creates an offer with a house number, first day, last day and price - * precondition: There are no overlapping offers + * This method creates an offer with a house number, first day, last day and + * price precondition: There are no overlapping offers + * * @param House * number, start day, last day and price * @return None */ - public Offer createOffer(RuralHouse ruralHouse, Date firstDay, Date lastDay, - float price) throws RemoteException, Exception { + + public Offer createOffer(RuralHouse ruralHouse, Date firstDay, + Date lastDay, float price) throws RemoteException, Exception { DB4oManager.openDatabase("open"); - ObjectContainer db=DB4oManager.getContainer(); + ObjectContainer db = DB4oManager.getContainer(); Offer o; try { - RuralHouse proto = new RuralHouse(ruralHouse.getHouseNumber(), null, - ruralHouse.getDescription(), ruralHouse.getTown()); - ObjectSet result = db.queryByExample(proto); - RuralHouse rh=(RuralHouse)result.next(); - o=rh.createOffer(firstDay, lastDay, price); - db.store(o); - db.commit(); - } - finally{ - db.close(); + RuralHouse proto = new RuralHouse(ruralHouse.getHouseNumber(), + null, ruralHouse.getDescription(), ruralHouse.getTown(), + ruralHouse.getFeatures()); + ObjectSet result = db.queryByExample(proto); + RuralHouse rh = (RuralHouse) result.next(); + o = rh.createOffer(firstDay, lastDay, price); + db.store(o); + db.commit(); + } finally { + db.close(); } return o; } - public RuralHouse getRuralHouse(RuralHouse rh){ - + + /** + * @param rh + * @return + */ + public RuralHouse getRuralHouse(RuralHouse rh) { + DB4oManager.openDatabase("open"); try { - ObjectContainer db=DB4oManager.getContainer(); + ObjectContainer db = DB4oManager.getContainer(); RuralHouse proto = new RuralHouse(rh.getHouseNumber(), null, - rh.getDescription(), rh.getTown()); + + rh.getDescription(), rh.getTown(), rh.getFeatures()); ObjectSet result = db.queryByExample(proto); - return rh=(RuralHouse)result.next(); + return rh = (RuralHouse) result.next(); } catch (Exception exc) { exc.printStackTrace(); return null; - } - finally { + } finally { db.close(); } + } + /** + * @param offer + * @param clientTelephoneNumber + * @return + * @throws OfferCanNotBeBooked + */ public Booking createBooking(Offer offer, String clientTelephoneNumber) throws OfferCanNotBeBooked { DB4oManager.openDatabase("open"); try { - Booking b=null; - if (offer!=null) { - b=offer.createBook(clientTelephoneNumber); + Booking b = null; + if (offer != null) { + b = offer.createBook(clientTelephoneNumber); db.store(b); db.store(offer); db.commit(); @@ -181,20 +242,37 @@ public class DB4oManager { } catch (Exception exc) { exc.printStackTrace(); return null; + } finally { + db.close(); } - finally { + + } + + public void removeHouse(int houseNumber) { + ObjectContainer db = DB4oManager.getContainer(); + RuralHouse house = new RuralHouse(houseNumber, null, null, null, null); + try { + ObjectSet result = db.queryByExample(house); + if (!result.isEmpty()) { + RuralHouse found = (RuralHouse) result.get(0); + db.delete(found); + db.commit(); + } + } catch (Exception exc) { + exc.printStackTrace(); + } finally { db.close(); } + } /** - * This method returns the instance of the DB4oManager class + * This method returns the instance of the DB4oManager class * * @return the db4o manager */ - public static DB4oManager getInstance() { + public static DB4oManager getInstance() { return theDB4oManager; } } - diff --git a/ruralHouses/src/domain/HouseFeatures.java b/ruralHouses/src/domain/HouseFeatures.java new file mode 100644 index 0000000..c26de8a --- /dev/null +++ b/ruralHouses/src/domain/HouseFeatures.java @@ -0,0 +1,21 @@ +package domain; + +public class HouseFeatures { + + private int nRooms; + private int nKitchens; + private int nBaths; + private int nLivings; + private int nParkings; + + public HouseFeatures(int nRooms, int nKitchens, int nBaths, int nLivings, + int nParkings) { + super(); + this.nRooms = nRooms; + this.nKitchens = nKitchens; + this.nBaths = nBaths; + this.nLivings = nLivings; + this.nParkings = nParkings; + } + +} diff --git a/ruralHouses/src/domain/Owner.java b/ruralHouses/src/domain/Owner.java index 35f390c..cd68e3c 100644 --- a/ruralHouses/src/domain/Owner.java +++ b/ruralHouses/src/domain/Owner.java @@ -7,18 +7,18 @@ import java.util.Vector; public class Owner implements Serializable { private String bankAccount = ""; - private String name=""; + private String name = ""; private Vector ruralHouses; public Owner(String name) { - this.name=name; - ruralHouses=new Vector(); + this.name = name; + ruralHouses = new Vector(); } public Owner(String name, String bankAccount) { - this.bankAccount=bankAccount; - this.name=name; - ruralHouses=new Vector(); + this.bankAccount = bankAccount; + this.name = name; + ruralHouses = new Vector(); } public String getName() { @@ -37,17 +37,22 @@ public class Owner implements Serializable { this.bankAccount = bankAccount; } - public Vector getRuralHouses() { - return ruralHouses; + public Vector getRuralHouses(){ + return this.ruralHouses; } - public RuralHouse addRuralHouse(int houseNumber, String description, String city) { - RuralHouse rh=new RuralHouse(houseNumber, this, description, city); + + + public RuralHouse addRuralHouse(int houseNumber, String description, + 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, description, town,feature); ruralHouses.add(rh); return rh; } - - public String toString(){ + + public String toString() { return name; } diff --git a/ruralHouses/src/domain/RuralHouse.java b/ruralHouses/src/domain/RuralHouse.java index 13a751d..7087a66 100644 --- a/ruralHouses/src/domain/RuralHouse.java +++ b/ruralHouses/src/domain/RuralHouse.java @@ -13,19 +13,23 @@ public class RuralHouse implements Serializable { private String description; private Owner owner; private String town; + private HouseFeatures features; public Vector offers; public RuralHouse() { super(); } - public RuralHouse(int houseNumber, Owner owner, String description, String town) { + public RuralHouse(int houseNumber, Owner owner, String description, String town ,HouseFeatures features) { this.houseNumber = houseNumber; this.description = description; this.owner = owner; this.town = town; + this.features = features; offers=new Vector(); } + + public int getHouseNumber() { return houseNumber; @@ -58,7 +62,13 @@ public class RuralHouse implements Serializable { public void setTown(String town) { this.town=town; } - + public HouseFeatures getFeatures() { + return features; + } + + public void setFeatures(HouseFeatures features) { + this.features = features; + } public String toString() { return this.houseNumber + ": " + this.town; } @@ -123,6 +133,7 @@ public class RuralHouse implements Serializable { return availableOffers; } + /** * This method obtains the offer that match exactly with a given dates that has not been booked * @@ -140,5 +151,7 @@ public class RuralHouse implements Serializable { } return null; } + + } diff --git a/ruralHouses/src/gui/DeleteHouseGUI.java b/ruralHouses/src/gui/DeleteHouseGUI.java new file mode 100644 index 0000000..0395a15 --- /dev/null +++ b/ruralHouses/src/gui/DeleteHouseGUI.java @@ -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 index 4a7bfba..656d76f 100644 --- a/ruralHouses/src/gui/HousesRelatedOwnerGUI.java +++ b/ruralHouses/src/gui/HousesRelatedOwnerGUI.java @@ -2,6 +2,7 @@ package gui; import java.awt.BorderLayout; import java.awt.EventQueue; +import java.awt.Frame; import javax.swing.JFrame; import javax.swing.JPanel; @@ -34,7 +35,6 @@ public class HousesRelatedOwnerGUI extends JFrame { public HousesRelatedOwnerGUI(Owner o) { this.getContentPane().setLayout(null); owner = o; - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 562); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); @@ -43,54 +43,52 @@ public class HousesRelatedOwnerGUI extends JFrame { JButton btnCreateHouses = new JButton("Create Houses"); btnCreateHouses.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - //TODO this button must direct to the House create GUI + 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 this button must direct to the House modify GUI + + /* 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) { - //TODO this button must direct to the House delete GUI + Frame a = new DeleteHouseGUI(owner); + a.setVisible(true); } }); - - JLabel lblDisabledYet = new JLabel("Disabled yet"); - lblDisabledYet.setFont(new Font("Courier New", Font.PLAIN, 19)); - lblDisabledYet.setForeground(Color.RED); GroupLayout gl_contentPane = new GroupLayout(contentPane); gl_contentPane.setHorizontalGroup( - gl_contentPane.createParallelGroup(Alignment.TRAILING) + gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addGap(110) .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING) - .addComponent(btnDeleteHouses, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE) - .addComponent(btnModifyHouses, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE) - .addComponent(btnCreateHouses, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)) + .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)) - .addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup() - .addGap(127) - .addComponent(lblDisabledYet) - .addContainerGap(165, Short.MAX_VALUE)) ); gl_contentPane.setVerticalGroup( gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() - .addGap(37) - .addComponent(lblDisabledYet) - .addGap(28) + .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(186, Short.MAX_VALUE)) + .addContainerGap(394, Short.MAX_VALUE)) ); contentPane.setLayout(gl_contentPane); } diff --git a/ruralHouses/src/gui/IntroduceOfferGUI.java b/ruralHouses/src/gui/LoginGUI.java similarity index 72% rename from ruralHouses/src/gui/IntroduceOfferGUI.java rename to ruralHouses/src/gui/LoginGUI.java index 876a1b9..caeb1cd 100644 --- a/ruralHouses/src/gui/IntroduceOfferGUI.java +++ b/ruralHouses/src/gui/LoginGUI.java @@ -14,7 +14,7 @@ import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.Color; -public class IntroduceOfferGUI extends JFrame { +public class LoginGUI extends JFrame { private static final long serialVersionUID= 1L; private JPanel jContentPane = null; @@ -23,7 +23,7 @@ public class IntroduceOfferGUI extends JFrame { private LoginManagerInterface loginManager = new LoginManager(); private JLabel loginFeedback; - public IntroduceOfferGUI() { + public LoginGUI() { super(); initialize(); } @@ -60,25 +60,9 @@ public class IntroduceOfferGUI extends JFrame { JButton loginButton = new JButton("Login"); loginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { - Owner owner = loginManager.checkCredentials(usernameField.getText(),new String(passwordField.getPassword())); - if(owner==null){ - loginFeedback.setText("Incorrect username or password"); - }else{ - Vector ownerHouseList=null; - try{ - ownerHouseList = StartWindow.getBusinessLogic().getRuralHouses(owner); - }catch (Exception e){ - e.printStackTrace(); - } - if(!ownerHouseList.isEmpty()){ - Frame a = new OwnerMenuGUI(owner); - a.setVisible(true); - } - else if(ownerHouseList.isEmpty()) - loginFeedback.setText("Login OK , but no houses in your name"); - } - } + jButton_ActionPerformed(arg0); + } }); loginButton.setBounds(164, 179, 117, 25); jContentPane.add(loginButton); @@ -91,7 +75,21 @@ public class IntroduceOfferGUI extends JFrame { } return jContentPane; } + + 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{ + + + + this.setVisible(false); + Frame a = new OwnerMenuGUI(owner); + a.setVisible(true); + } + } } // @jve:decl-index=0:visual-constraint="222,33" diff --git a/ruralHouses/src/gui/ModifyHouseGUI.java b/ruralHouses/src/gui/ModifyHouseGUI.java new file mode 100644 index 0000000..a273b6e --- /dev/null +++ b/ruralHouses/src/gui/ModifyHouseGUI.java @@ -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 index 4139091..bb72996 100644 --- a/ruralHouses/src/gui/NewHouseGUI.java +++ b/ruralHouses/src/gui/NewHouseGUI.java @@ -9,12 +9,21 @@ 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 { @@ -24,6 +33,7 @@ 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; @@ -46,15 +56,16 @@ public class NewHouseGUI extends JFrame { * Create the frame. */ public NewHouseGUI(Owner o) { + this.setTitle("New House"); + setBackground(Color.WHITE); this.getContentPane().setLayout(null); owner = o; - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setBounds(100, 100, 450, 583); + 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 = new JLabel("House Code:"); lblCode.setHorizontalAlignment(SwingConstants.RIGHT); Code_f = new JTextField(); @@ -66,10 +77,12 @@ public class NewHouseGUI extends JFrame { Town_f = new JTextField(); Town_f.setColumns(10); - lblDescription = new JLabel("Description:"); + 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:"); @@ -103,63 +116,84 @@ public class NewHouseGUI extends JFrame { 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() - .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) - .addGap(18) - .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)) + .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(lblTown, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) + .addComponent(lblKitchen, 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) + .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) - .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) - .addComponent(lblDescription, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_contentPane.createSequentialGroup() - .addGap(10) - .addComponent(description_f, GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)))) - .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)))))) + .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))) .addGroup(gl_contentPane.createSequentialGroup() - .addGap(140) - .addComponent(btnRegister))) - .addContainerGap()) + .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) @@ -168,39 +202,34 @@ public class NewHouseGUI extends JFrame { .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) + .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) + .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)) - .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) + .addComponent(lblKitchen))) + .addPreferredGap(ComponentPlacement.RELATED, 206, Short.MAX_VALUE) .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addGap(3) - .addComponent(lblParkings)) + .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(41) + .addGap(88) .addComponent(btnRegister) .addGap(54)) ); diff --git a/ruralHouses/src/gui/OwnerMenuGUI.java b/ruralHouses/src/gui/OwnerMenuGUI.java index 4cc4f43..532d373 100644 --- a/ruralHouses/src/gui/OwnerMenuGUI.java +++ b/ruralHouses/src/gui/OwnerMenuGUI.java @@ -32,9 +32,9 @@ public class OwnerMenuGUI extends JFrame { * Create the frame. */ public OwnerMenuGUI(Owner o) { + this.setTitle("Owner Menu"); this.getContentPane().setLayout(null); owner = o; - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 473); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); diff --git a/ruralHouses/src/gui/StartWindow.java b/ruralHouses/src/gui/StartWindow.java index f5e5b10..f33bc0f 100644 --- a/ruralHouses/src/gui/StartWindow.java +++ b/ruralHouses/src/gui/StartWindow.java @@ -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() { @@ -87,7 +87,7 @@ public class StartWindow extends JFrame { createOfferButton.setAlignmentX(Component.CENTER_ALIGNMENT); createOfferButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { - JFrame a = new IntroduceOfferGUI(); + JFrame a = new LoginGUI(); a.setVisible(true); } });