private String houseName;
private String description;
private Owner owner;
- private String town;
+ private String district;
private HouseFeatures features;
public Vector<Offer> offers;
public boolean isAccepted;
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<Offer>();
}
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;
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) {
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.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 {
/**
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;
private JTextField parkings_f;
private JLabel lblBaths;
private JTextField baths_f;
- private JButton btnRegister;
- private JComboBox comboBox;
-
+ private JButton btnConfirm;
+ private JComboBox<RuralHouse> houseBox;
+ private RuralHouse rh;
/**
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);
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<RuralHouse>(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)
.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)
.addComponent(lblDescription, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)))))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(140)
- .addComponent(btnRegister)))
+ .addComponent(btnConfirm)))
.addContainerGap())
);
gl_contentPane.setVerticalGroup(
.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)
.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);
--- /dev/null
+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);
+ }
+}