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 implemented lacking GUIs and corrected errors --- a927255f6eb55fb1f52738b9b88ce51f9b0ed9bc diff --cc ruralHouses/db/DBjcampos004.yap index 41236b6,0000000..212f8cd mode 100644,000000..100644 Binary files differ diff --cc ruralHouses/src/businessLogic/HouseManager.java index 0000000,21b8925..82eedfc mode 000000,100644..100644 --- a/ruralHouses/src/businessLogic/HouseManager.java +++ b/ruralHouses/src/businessLogic/HouseManager.java @@@ -1,0 -1,72 +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) { - // 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); + } + + // 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 --cc ruralHouses/src/businessLogic/HouseManagerInterface.java index 0000000,7a0656f..65e2baa mode 000000,100644..100644 --- a/ruralHouses/src/businessLogic/HouseManagerInterface.java +++ b/ruralHouses/src/businessLogic/HouseManagerInterface.java @@@ -1,0 -1,28 +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 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, + 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 --cc ruralHouses/src/businessLogic/LoginManager.java index 58ec39b,966168c..72ce86b --- a/ruralHouses/src/businessLogic/LoginManager.java +++ b/ruralHouses/src/businessLogic/LoginManager.java @@@ -1,8 -1,5 +1,6 @@@ package businessLogic; + - - import java.util.Vector; import dataAccess.DB4oManager; diff --cc ruralHouses/src/dataAccess/DB4oManager.java index 3e9fd76,26fa6f3..b0e4005 --- a/ruralHouses/src/dataAccess/DB4oManager.java +++ b/ruralHouses/src/dataAccess/DB4oManager.java @@@ -27,94 -29,134 +29,139 @@@ public class DB4oManager 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.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(); @@@ -128,44 -171,53 +176,57 @@@ * 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"); @@@ -181,10 -233,27 +242,28 @@@ } 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(); } + } /** diff --cc ruralHouses/src/domain/Owner.java index 35f390c,35b0296..cd68e3c --- a/ruralHouses/src/domain/Owner.java +++ b/ruralHouses/src/domain/Owner.java @@@ -37,12 -37,23 +37,17 @@@ public class Owner implements Serializa 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 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, + 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; } diff --cc ruralHouses/src/domain/RuralHouse.java index 13a751d,50e46fa..7087a66 --- a/ruralHouses/src/domain/RuralHouse.java +++ b/ruralHouses/src/domain/RuralHouse.java @@@ -24,8 -25,18 +25,11 @@@ public class RuralHouse implements Seri this.description = description; this.owner = owner; this.town = town; + this.features = features; offers=new Vector(); } + - 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(); - } ++ public int getHouseNumber() { return houseNumber; diff --cc ruralHouses/src/gui/DeleteHouseGUI.java index 0000000,0000000..0395a15 new file mode 100644 --- /dev/null +++ b/ruralHouses/src/gui/DeleteHouseGUI.java @@@ -1,0 -1,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 --cc ruralHouses/src/gui/HousesRelatedOwnerGUI.java index 4a7bfba,0000000..656d76f mode 100644,000000..100644 --- a/ruralHouses/src/gui/HousesRelatedOwnerGUI.java +++ b/ruralHouses/src/gui/HousesRelatedOwnerGUI.java @@@ -1,97 -1,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; - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + 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) { - //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 --cc ruralHouses/src/gui/LoginGUI.java index 876a1b9,ef333d6..caeb1cd --- a/ruralHouses/src/gui/LoginGUI.java +++ b/ruralHouses/src/gui/LoginGUI.java @@@ -60,25 -60,8 +60,9 @@@ public class LoginGUI 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 -74,28 +75,21 @@@ } 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{ - Vector 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"); - } ++ } + } } // @jve:decl-index=0:visual-constraint="222,33" diff --cc ruralHouses/src/gui/ModifyHouseGUI.java index 0000000,0000000..a273b6e new file mode 100644 --- /dev/null +++ b/ruralHouses/src/gui/ModifyHouseGUI.java @@@ -1,0 -1,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 --cc ruralHouses/src/gui/NewHouseGUI.java index 4139091,0000000..bb72996 mode 100644,000000..100644 --- a/ruralHouses/src/gui/NewHouseGUI.java +++ b/ruralHouses/src/gui/NewHouseGUI.java @@@ -1,209 -1,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; - 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(); + Code_f.setColumns(10); + + lblTown = new JLabel("Town:"); + lblTown.setHorizontalAlignment(SwingConstants.RIGHT); + + 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:"); + 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() - .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) + .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))) - .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)) + ); + contentPane.setLayout(gl_contentPane); + } +} diff --cc ruralHouses/src/gui/OwnerMenuGUI.java index 4cc4f43,0000000..532d373 mode 100644,000000..100644 --- a/ruralHouses/src/gui/OwnerMenuGUI.java +++ b/ruralHouses/src/gui/OwnerMenuGUI.java @@@ -1,80 -1,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; - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + 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); + } + +} diff --cc ruralHouses/src/gui/StartWindow.java index f5e5b10,54fe389..f33bc0f --- a/ruralHouses/src/gui/StartWindow.java +++ b/ruralHouses/src/gui/StartWindow.java @@@ -41,7 -41,7 +41,7 @@@ public class StartWindow extends JFram // this.setSize(271, 295); this.setSize(350, 400); this.setContentPane(getJContentPane()); -- this.setTitle("Use Cases"); ++ this.setTitle("Rural Houses"); } private JPanel getJContentPane() {