RRRRHHHH_Code
ccac9974c8183f7f0d30e8cabd84ee0386e8cd97
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 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
package gui; import java.awt.Color; import java.awt.Component; 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.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import common.BookingInterface; import configuration.___IntNames; import domain.Booking; import domain.Offer; public class listOfBookingRequestsGUI extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JPanel contentPane; private JTable table; private Offer off; private BookingInterface bookM = null; private DefaultTableModel tableModel; private Vector<Booking> bookings = new Vector<Booking>(); /** * Create the frame. */ public listOfBookingRequestsGUI(Offer of) { setTitle("Adding requests"); this.off = of; try { init(); } catch (Exception e) { e.printStackTrace(); } } private void init() throws Exception { setBounds(100, 100, 600, 500); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); this.bookings = this.off.getBookings(); JLabel lblNewLabel = new JLabel(); lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27)); lblNewLabel.setBounds(23, 41, 536, 33); contentPane.add(lblNewLabel); 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[] { "Booking Number", "Booking Date", "Name", "E-mail", "Telephone" }); table.setModel(tableModel); JButton btnNewButton = new JButton("Confirm Booking"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { bookM = (BookingInterface) Naming .lookup(___IntNames.BookingManager); } catch (Exception e1) { System.out .println("Error accessing remote authentication: " + e1.toString()); } if (table.getRowCount() != 0 && table.getSelectedRow() != -1) { if (table.getRowCount() != 0 && table.getSelectedRow() != -1) { Booking book = bookings.get(table.getSelectedRow()); try { bookM.acceptBooking(book); } catch (RemoteException e1) { e1.printStackTrace(); } contentPane.setVisible(false); } } } }); btnNewButton.setBounds(33, 396, 169, 25); contentPane.add(btnNewButton); JButton btnDenyAddition = new JButton("Deny Booking"); btnDenyAddition.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { bookM = (BookingInterface) Naming .lookup(___IntNames.BookingManager); } catch (Exception e1) { System.out .println("Error accessing remote authentication: " + e1.toString()); } if (table.getRowCount() != 0 && table.getSelectedRow() != -1) { Booking book = bookings.get(table.getSelectedRow()); try { bookM.denyBooking(book); } catch (RemoteException e) { e.printStackTrace(); } ((DefaultTableModel) table.getModel()).removeRow(table .getSelectedRow()); bookings.remove(book); } } }); if (bookings.isEmpty()) lblNewLabel .setText("There are not bookings to be confirmed or denied"); else { lblNewLabel.setText("List of bookings:"); if (this.bookings.get(0).getOffer().isBooked()) { btnDenyAddition.setEnabled(false); btnNewButton.setEnabled(false); } } btnDenyAddition.setBounds(390, 395, 169, 25); contentPane.add(btnDenyAddition); Enumeration<Booking> en = this.bookings.elements(); Booking book; while (en.hasMoreElements()) { book = en.nextElement(); Vector<Object> row = new Vector<Object>(); row.add(book.getBookNumber()); row.add(book.getBookDate()); row.add(book.getClient().getName()); row.add(book.getClient().getMailAccount()); row.add(book.getClient().getTelephone()); tableModel.addRow(row); } table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { /** * */ private static final long serialVersionUID = 1L; @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col); if (!bookings.get(row).getOffer().isBooked()) { setBackground(Color.RED); setForeground(Color.BLACK); } else { setBackground(Color.GREEN); setForeground(Color.BLACK); } return this; } }); } } |
Commits for RRRRHHHH_CoderuralHouses/src/gui/listOfBookingRequestsGUI.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 |
6a5d4d ... Diff | camjan | Sun 17 May, 2015 20:35:45 +0000 | Booking confirmation and e-mail service added. Some bugs to be solved. |
7bf57b ... Diff | camjan | Sun 17 May, 2015 11:59:22 +0000 | Possibility of registering new owners added |
0f75b2 ... Diff | camjan | Sat 16 May, 2015 14:34:49 +0000 | Username is saved hashed and password hashed and salted |
d7fd17 ... | Eneko Pinzolas Murua | Mon 27 Apr, 2015 12:01:38 +0000 | Started creating the booking interface for the owners. |