Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions 7bf57b ... vs 6a5d4d ... for ruralHouses/src/gui/listOfOffers.java

Diff revisions: vs.
  @@ -2,13 +2,11 @@
2 2
3 3 import java.awt.Font;
4 4 import java.awt.Rectangle;
5 - import java.awt.event.ActionEvent;
6 - import java.awt.event.ActionListener;
5 + import java.awt.event.MouseAdapter;
6 + import java.awt.event.MouseEvent;
7 7 import java.util.Enumeration;
8 - import java.util.LinkedList;
9 8 import java.util.Vector;
10 9
11 - import javax.swing.JButton;
12 10 import javax.swing.JFrame;
13 11 import javax.swing.JLabel;
14 12 import javax.swing.JPanel;
  @@ -17,11 +15,8 @@
17 15 import javax.swing.border.EmptyBorder;
18 16 import javax.swing.table.DefaultTableModel;
19 17
20 - import businessLogic.BookingManager;
21 - import domain.Booking;
22 18 import domain.Offer;
23 19 import domain.Owner;
24 - import domain.RuralHouse;
25 20
26 21 public class listOfOffers extends JFrame {
27 22
  @@ -32,7 +27,7 @@
32 27 private JPanel contentPane;
33 28 private JTable table;
34 29 private Owner owner;
35 - private BookingManager bookM = new BookingManager();
30 +
36 31 private DefaultTableModel tableModel;
37 32 private Vector<Offer> offers = new Vector<Offer>();
38 33
  @@ -66,12 +61,12 @@
66 61 lblNewLabel
67 62 .setText("There are not bookings to be confirmed or denied");
68 63 else
69 - lblNewLabel.setText("List of bookings:");
64 + lblNewLabel.setText("List of offers:");
70 65 JScrollPane scrollPane = new JScrollPane();
71 66 scrollPane.setBounds(new Rectangle(45, 305, 320, 116));
72 67 scrollPane.setBounds(23, 113, 536, 271);
73 68 contentPane.add(scrollPane);
74 -
69 +
75 70 table = new JTable() {
76 71 private static final long serialVersionUID = 1L;
77 72
  @@ -79,35 +74,22 @@
79 74 return false;
80 75 };
81 76 };
77 +
82 78 scrollPane.setViewportView(table);
83 79 tableModel = new DefaultTableModel(null, new String[] { "Offer #",
84 - "FirstDay", "LastDay", "Price" });
80 + "FirstDay", "LastDay", "Price" ,"RuralHouse"});
85 81
86 82 // Maybe there is a better way to avoid interaction.
87 83 // table.setEnabled(false);
88 84 table.setModel(tableModel);
89 -
90 - JButton btnNewButton = new JButton("Confirm Booking");
91 - btnNewButton.addActionListener(new ActionListener() {
92 - public void actionPerformed(ActionEvent e) {
93 - if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
94 -
95 - }
96 - }
97 - });
98 - btnNewButton.setBounds(88, 396, 169, 25);
99 - contentPane.add(btnNewButton);
100 -
101 - JButton btnDenyAddition = new JButton("Deny Booking");
102 - btnDenyAddition.addActionListener(new ActionListener() {
103 - public void actionPerformed(ActionEvent arg0) {
104 - if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
105 -
106 - }
85 + table.addMouseListener( new MouseAdapter(){
86 + @Override
87 + public void mouseClicked(MouseEvent arg0) {
88 + int row = table.getSelectedRow();
89 + listOfBookingRequestsGUI feat = new listOfBookingRequestsGUI(offers.get(row));
90 + feat.setVisible(true);
107 91 }
108 92 });
109 - btnDenyAddition.setBounds(300, 396, 169, 25);
110 - contentPane.add(btnDenyAddition);
111 93 Enumeration<Offer> rhs = this.offers.elements();
112 94 while (rhs.hasMoreElements()) {
113 95 Offer of = rhs.nextElement();
  @@ -116,6 +98,7 @@
116 98 row.add(of.getFirstDay());
117 99 row.add(of.getLastDay());
118 100 row.add(of.getPrice());
101 + row.add(of.getRuralHouse().getHouseName());
119 102 tableModel.addRow(row);
120 103
121 104 }