From: Eneko Pinzolas Murua Date: Wed, 1 Apr 2015 17:46:59 +0000 (+0200) Subject: ModifyHouseGUI created and its link from HouseRelatedOwnerGUI reestablished X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/commitdiff_plain/5ad0ccf52e0a1772c424ac983a7b6e1c00cec879 ModifyHouseGUI created and its link from HouseRelatedOwnerGUI reestablished --- diff --git a/ruralHouses/src/dataAccess/DB4oManager.java b/ruralHouses/src/dataAccess/DB4oManager.java index 5dabd6f..adc1da4 100644 --- a/ruralHouses/src/dataAccess/DB4oManager.java +++ b/ruralHouses/src/dataAccess/DB4oManager.java @@ -255,7 +255,7 @@ public class DB4oManager { openSDB(); RuralHouse proto = new RuralHouse(ruralHouse.getHouseName(), - null, ruralHouse.getDescription(), ruralHouse.getTown(), + null, ruralHouse.getDescription(), ruralHouse.getDistrict(), null); ObjectSet result = db.queryByExample(proto); RuralHouse rh = (RuralHouse) result.next(); diff --git a/ruralHouses/src/domain/RuralHouse.java b/ruralHouses/src/domain/RuralHouse.java index 9b2ca05..2e61137 100644 --- a/ruralHouses/src/domain/RuralHouse.java +++ b/ruralHouses/src/domain/RuralHouse.java @@ -12,7 +12,7 @@ public class RuralHouse implements Serializable { private String houseName; private String description; private Owner owner; - private String town; + private String district; private HouseFeatures features; public Vector offers; public boolean isAccepted; @@ -21,11 +21,11 @@ public class RuralHouse implements Serializable { super(); } - public RuralHouse(String houseName, Owner owner, String description, String town , HouseFeatures features) { + public RuralHouse(String houseName, Owner owner, String description, String ds , HouseFeatures features) { this.houseName = houseName; this.description = description; this.owner = owner; - this.town = town; + this.district = ds; this.features = features; offers=new Vector(); } @@ -56,12 +56,12 @@ public class RuralHouse implements Serializable { this.owner=owner; } - public String getTown() { - return town; + public String getDistrict() { + return district; } - public void setTown(String town) { - this.town=town; + public void setDistrict(String ds) { + this.district=ds; } public HouseFeatures getFeatures() { return features; @@ -71,7 +71,7 @@ public class RuralHouse implements Serializable { this.features = features; } public String toString() { - return this.houseName + ": " + this.town; + return this.houseName + ": " + this.district; } public Offer createOffer(int offerNumber,Date firstDay, Date lastDay, float price) { diff --git a/ruralHouses/src/gui/HousesRelatedOwnerGUI.java b/ruralHouses/src/gui/HousesRelatedOwnerGUI.java index 0045177..a7d292f 100644 --- a/ruralHouses/src/gui/HousesRelatedOwnerGUI.java +++ b/ruralHouses/src/gui/HousesRelatedOwnerGUI.java @@ -49,14 +49,12 @@ public class HousesRelatedOwnerGUI extends JFrame { }); JButton btnModifyHouses = new JButton("Modify Houses"); - btnModifyHouses.setEnabled(false); btnModifyHouses.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - /* TODO to be implemented in a future. Frame a = new ModifyHouseGUI(owner); a.setVisible(true); - */ + } }); diff --git a/ruralHouses/src/gui/ModifyHouseGUI.java b/ruralHouses/src/gui/ModifyHouseGUI.java index a273b6e..737267e 100644 --- a/ruralHouses/src/gui/ModifyHouseGUI.java +++ b/ruralHouses/src/gui/ModifyHouseGUI.java @@ -9,7 +9,10 @@ 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; @@ -17,6 +20,13 @@ import javax.swing.SwingConstants; import javax.swing.JButton; import javax.swing.JComboBox; +import businessLogic.HouseManager; + +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + public class ModifyHouseGUI extends JFrame { /** @@ -25,8 +35,8 @@ 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 lblDistrict; + private JTextField District_f; private JLabel lblDescription; private JTextField description_f; private JLabel lblKitchen; @@ -39,9 +49,9 @@ public class ModifyHouseGUI extends JFrame { private JTextField parkings_f; private JLabel lblBaths; private JTextField baths_f; - private JButton btnRegister; - private JComboBox comboBox; - + private JButton btnConfirm; + private JComboBox houseBox; + private RuralHouse rh; /** @@ -58,11 +68,11 @@ public class ModifyHouseGUI extends JFrame { JLabel lblCode = new JLabel("House Code:"); lblCode.setHorizontalAlignment(SwingConstants.RIGHT); - lblTown = new JLabel("Town:"); - lblTown.setHorizontalAlignment(SwingConstants.RIGHT); + lblDistrict = new JLabel("District:"); + lblDistrict.setHorizontalAlignment(SwingConstants.RIGHT); - Town_f = new JTextField(); - Town_f.setColumns(10); + District_f = new JTextField(); + District_f.setColumns(10); lblDescription = new JLabel("Description:"); lblDescription.setHorizontalAlignment(SwingConstants.RIGHT); @@ -100,9 +110,43 @@ public class ModifyHouseGUI extends JFrame { baths_f = new JTextField(); baths_f.setColumns(10); - btnRegister = new JButton("Register House"); + btnConfirm = new JButton("Confirm"); + btnConfirm.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + + + HouseManager hm = new HouseManager(); + hm.removeHouse(rh, owner); + hm.registerNewHouse(rh.getHouseName(), + owner, + description_f.getText(), + District_f.getText(), + new Integer(rooms_f.getText()), + new Integer(kitchens_f.getText()), + new Integer(baths_f.getText()), + new Integer(lRooms_f.getText()), + new Integer(parkings_f.getText()) + ); + } + }); + + houseBox = new JComboBox(o.getRuralHouses()); + + houseBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + rh = (RuralHouse)houseBox.getSelectedItem(); + District_f.setText(rh.getDistrict()); + description_f.setText(rh.getDescription()); + kitchens_f.setText(Integer.toString(rh.getFeatures().getnKitchens())); + rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms())); + lRooms_f.setText(Integer.toString(rh.getFeatures().getnLivings())); + parkings_f.setText(Integer.toString(rh.getFeatures().getnParkings())); + baths_f.setText(Integer.toString(rh.getFeatures().getnBaths())); + + } + }); - comboBox = new JComboBox(); GroupLayout gl_contentPane = new GroupLayout(contentPane); gl_contentPane.setHorizontalGroup( gl_contentPane.createParallelGroup(Alignment.LEADING) @@ -122,15 +166,15 @@ public class ModifyHouseGUI extends JFrame { .addGroup(gl_contentPane.createSequentialGroup() .addComponent(lblCode) .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 124, GroupLayout.PREFERRED_SIZE)) + .addComponent(houseBox, 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) + .addComponent(lblDistrict, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE) .addGap(18) - .addComponent(Town_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) + .addComponent(District_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPane.createSequentialGroup() .addGap(17) @@ -152,7 +196,7 @@ public class ModifyHouseGUI extends JFrame { .addComponent(lblDescription, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE))))) .addGroup(gl_contentPane.createSequentialGroup() .addGap(140) - .addComponent(btnRegister))) + .addComponent(btnConfirm))) .addContainerGap()) ); gl_contentPane.setVerticalGroup( @@ -164,11 +208,11 @@ public class ModifyHouseGUI extends JFrame { .addGap(60) .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) .addComponent(lblCode) - .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addComponent(houseBox, 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))) + .addComponent(District_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(lblDistrict))) .addGroup(gl_contentPane.createSequentialGroup() .addGap(63) .addComponent(lblDescription) @@ -201,7 +245,7 @@ public class ModifyHouseGUI extends JFrame { .addComponent(lblParkings)) .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(41) - .addComponent(btnRegister) + .addComponent(btnConfirm) .addGap(54)) ); contentPane.setLayout(gl_contentPane); diff --git a/ruralHouses/src/gui/OffersRelatedOwnerGUI.java b/ruralHouses/src/gui/OffersRelatedOwnerGUI.java new file mode 100644 index 0000000..da02608 --- /dev/null +++ b/ruralHouses/src/gui/OffersRelatedOwnerGUI.java @@ -0,0 +1,94 @@ +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 OffersRelatedOwnerGUI extends JFrame { + + /** + * + */ + private static final long serialVersionUID = 1L; + private JPanel contentPane; + private Owner owner; + /** + * Create the frame. + */ + public OffersRelatedOwnerGUI(Owner o) { + this.getContentPane().setLayout(null); + owner = o; + setBounds(100, 100, 450, 562); + contentPane = new JPanel(); + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); + setContentPane(contentPane); + + JButton btnCreateOffers = new JButton("Create Offers"); + btnCreateOffers.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + Frame a = new NewHouseGUI(owner); + a.setVisible(true); + } + }); + + JButton btnModifyOffers = new JButton("Modify Offers"); + btnModifyOffers.setEnabled(false); + btnModifyOffers.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + + /* TODO to be implemented in a future. + Frame a = new ModifyHouseGUI(owner); + a.setVisible(true); + */ + } + }); + + JButton btnDeleteOffers = new JButton("Delete Offers"); + btnDeleteOffers.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Frame a = new DeleteHouseGUI(owner); + a.setVisible(true); + } + }); + GroupLayout gl_contentPane = new GroupLayout(contentPane); + gl_contentPane.setHorizontalGroup( + gl_contentPane.createParallelGroup(Alignment.LEADING) + .addGroup(gl_contentPane.createSequentialGroup() + .addGap(110) + .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING) + .addComponent(btnDeleteOffers, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE) + .addComponent(btnModifyOffers, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE) + .addComponent(btnCreateOffers, GroupLayout.DEFAULT_SIZE, 1125, Short.MAX_VALUE)) + .addGap(121)) + ); + gl_contentPane.setVerticalGroup( + gl_contentPane.createParallelGroup(Alignment.LEADING) + .addGroup(gl_contentPane.createSequentialGroup() + .addGap(88) + .addComponent(btnCreateOffers, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE) + .addGap(40) + .addComponent(btnModifyOffers, GroupLayout.PREFERRED_SIZE, 57, GroupLayout.PREFERRED_SIZE) + .addGap(39) + .addComponent(btnDeleteOffers, GroupLayout.PREFERRED_SIZE, 54, GroupLayout.PREFERRED_SIZE) + .addContainerGap(394, Short.MAX_VALUE)) + ); + contentPane.setLayout(gl_contentPane); + } +} diff --git a/ruralHouses/src/gui/listOfHousesGUI.java b/ruralHouses/src/gui/listOfHousesGUI.java index d610030..0478466 100644 --- a/ruralHouses/src/gui/listOfHousesGUI.java +++ b/ruralHouses/src/gui/listOfHousesGUI.java @@ -68,7 +68,7 @@ public class listOfHousesGUI extends JFrame { if (houses.isEmpty()) textField.setText("No houses Matching"); else - textField.setText(houses.get(0).getTown()); + textField.setText(houses.get(0).getDistrict()); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(new Rectangle(45, 305, 320, 116)); scrollPane.setBounds(23, 113, 536, 271);