RRRRHHHH_Code
b09f345318baa9ca734e11c87f52f8522d7cc1fb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
package gui; import java.awt.Font; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.rmi.Naming; import java.rmi.RemoteException; import java.util.Enumeration; import java.util.Vector; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableModel; import common.AdminInterface; import common.HouseInterface; import configuration.___IntNames; import domain.RuralHouse; public class listOfRemovalRequestsGUI extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JPanel contentPane; private JTable table; private DefaultTableModel tableModel; private AdminInterface am = null; private Vector<RuralHouse> houses; /** * Create the frame. */ public listOfRemovalRequestsGUI() { try { am = (AdminInterface) Naming.lookup(___IntNames.AdminManager); } catch (Exception e1) { System.out.println("Error accessing remote authentication: " + e1.toString()); } setTitle("Deleting requests"); try { this.houses = am.getDeletionRequests(); init(); } catch (Exception e) { e.printStackTrace(); } } private void init() throws Exception { setBounds(100, 100, 600, 450); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel lblNewLabel = new JLabel(); lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27)); lblNewLabel.setBounds(23, 41, 536, 33); contentPane.add(lblNewLabel); if (houses.isEmpty()) lblNewLabel.setText("There are not houses to be deleted"); else 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; 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" }); table.setModel(tableModel); Enumeration<RuralHouse> en = houses.elements(); RuralHouse rh; JButton btnNewButton = new JButton("Confirm Deletion"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (table.getRowCount() != 0 && table.getSelectedRow() != -1) { HouseInterface hm = null; try { hm = (HouseInterface) Naming .lookup(___IntNames.HouseManager); } catch (Exception e1) { System.out .println("Error accessing remote authentication: " + e1.toString()); } RuralHouse rh = houses.get(table.getSelectedRow()); try { hm.removeHouse(rh, rh.getOwner()); am.removeHouseDeletionRequests(rh); am.saveInstance(); } catch (RemoteException e1) { e1.printStackTrace(); } ((DefaultTableModel) table.getModel()).removeRow(houses .indexOf(rh)); houses.remove(rh); } } }); btnNewButton.setBounds(90, 396, 169, 25); contentPane.add(btnNewButton); JButton btnNewButton_1 = new JButton("Deny Deletion"); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (table.getRowCount() != 0 && table.getSelectedRow() != -1) { RuralHouse rh = houses.get(table.getSelectedRow()); ((DefaultTableModel) table.getModel()).removeRow(houses .indexOf(rh)); houses.remove(rh); try { am.removeHouseDeletionRequests(rh); am.saveInstance(); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); btnNewButton_1.setBounds(291, 396, 169, 25); contentPane.add(btnNewButton_1); while (en.hasMoreElements()) { rh = en.nextElement(); Vector<Object> row = new Vector<Object>(); row.add(rh.getHouseName()); row.add(rh.getFeatures().getnRooms()); row.add(rh.getFeatures().getnKitchens()); row.add(rh.getFeatures().getnBaths()); row.add(rh.getFeatures().getnParkings()); row.add(rh.getFeatures().getnLivings()); tableModel.addRow(row); } } } |
Commits for RRRRHHHH_CoderuralHouses/src/gui/listOfRemovalRequestsGUI.java
Revision | Author | Commited | Message |
---|---|---|---|
ccac99 ... Diff | pinene | Wed 20 May, 2015 16:42:17 +0000 | Merge branch ‘master’ of ssh://xp-dev.com/RRRRHHHH_Code Conflicts: |
d30bcc ... Diff | pinene | Wed 20 May, 2015 16:32:33 +0000 | cleaning |
4f8bcc ... Diff | epinzolas001 | Mon 18 May, 2015 09:49:54 +0000 | Merge conflicts solutioned |
d7fd17 ... Diff | Eneko Pinzolas Murua | Mon 27 Apr, 2015 12:01:38 +0000 | Started creating the booking interface for the owners. |
520867 ... Diff | pinene | Sun 19 Apr, 2015 14:09:12 +0000 | tmp |
46d6c3 ... Diff | camjan | Wed 15 Apr, 2015 17:08:42 +0000 | Debbugin continues... |
2ac167 ... Diff | Eneko Pinzolas Murua | Wed 15 Apr, 2015 13:53:44 +0000 | admin completed |
e2ae30 ... Diff | Eneko Pinzolas Murua | Tue 14 Apr, 2015 15:07:35 +0000 | imports leaned |
66f0c8 ... | Eneko Pinzolas Murua | Sun 12 Apr, 2015 18:11:42 +0000 | Model modified so that owners now request for a new house insetion or a house removal. Furthermore, all Administrator GUI and bussines logic create. However, Login GUI and BussinesLogic are to be modified so that they integrate Admin identification. |