X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/blobdiff_plain/ba6020dbbdae8fddc57edd4723eb0b3a4a530e14..46d6c37bf669afa1ddb7176d857fd17af0ff3e4f:/ruralHouses/src/gui/listOfRemovalRequestsGUI.java diff --git a/ruralHouses/src/gui/listOfRemovalRequestsGUI.java b/ruralHouses/src/gui/listOfRemovalRequestsGUI.java index da70439..07ee348 100644 --- a/ruralHouses/src/gui/listOfRemovalRequestsGUI.java +++ b/ruralHouses/src/gui/listOfRemovalRequestsGUI.java @@ -29,12 +29,14 @@ public class listOfRemovalRequestsGUI extends JFrame { private DefaultTableModel tableModel; private AdminManager am = new AdminManager(); private Vector houses; - /** + + /** * Create the frame. */ public listOfRemovalRequestsGUI() { + setTitle("Deleting requests"); try { - this.houses= am.getDeletionRequests(); + this.houses = am.getDeletionRequests(); init(); } catch (Exception e) { e.printStackTrace(); @@ -53,42 +55,41 @@ public class listOfRemovalRequestsGUI extends JFrame { lblNewLabel.setBounds(23, 41, 536, 33); contentPane.add(lblNewLabel); if (houses.isEmpty()) - lblNewLabel.setText("There are not houses matching your search"); + lblNewLabel.setText("There are not houses to be deleted"); else - lblNewLabel.setText("List of houses that match your search:"); + lblNewLabel.setText("List of houses to be deleted:"); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(new Rectangle(45, 305, 320, 116)); scrollPane.setBounds(23, 113, 536, 271); contentPane.add(scrollPane); table = new JTable() { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public boolean isCellEditable(int row, int column) { - return false; - }; - }; + public boolean isCellEditable(int row, int column) { + return false; + }; + }; scrollPane.setViewportView(table); - tableModel = new DefaultTableModel(null, new String[] { - "House Name", "Bedrooms", "Kitchens", "Baths", "Parkings", - "Livings" }); - - //Maybe there is a better way to avoid interaction. - //table.setEnabled(false); + tableModel = new DefaultTableModel(null, new String[] { "House Name", + "Bedrooms", "Kitchens", "Baths", "Parkings", "Livings" }); + table.setModel(tableModel); Enumeration en = houses.elements(); RuralHouse rh; JButton btnNewButton = new JButton("Confirm Deletion"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - if (table.getRowCount()!=0) { + if (table.getRowCount() != 0) { HouseManagerInterface hm = new HouseManager(); RuralHouse rh = houses.get(table.getSelectedRow()); - //TODO when the house is not added show a warning to the user. Method below returns a boolean stating that. - hm.removeHouse(rh, rh.getOwner()); - houses.remove(rh); - am.removeHouseDeletionRequests(rh); - Administrator.saveInstance(); + ((DefaultTableModel)table.getModel()).removeRow(houses.indexOf(rh)); + hm.removeHouse(rh, rh.getOwner()); + houses.remove(rh); + am.removeHouseDeletionRequests(rh); + Administrator.saveInstance(); + + } } });