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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
package gui; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.rmi.Naming; import java.rmi.RemoteException; import java.util.Vector; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; import common.HouseInterface; import configuration.___IntNames; import domain.Districs; import domain.HouseFeatures; import domain.Owner; import domain.RuralHouse; public class ModifyHouseGUI extends JFrame { /** * */ private static final long serialVersionUID = 1L; private JPanel contentPane; private Owner owner; private JLabel lblDistrict; private JLabel feedback; private JLabel lblDescription; private JTextField description_f; private JLabel lblKitchen; private JTextField kitchens_f; private JLabel lblRooms; private JTextField rooms_f; private JLabel lblLivings; private JTextField lRooms_f; private JLabel lblParkings; private JTextField parkings_f; private JLabel lblBaths; private String[] distric; private JTextField baths_f; private JButton btnConfirm; private JComboBox<RuralHouse> houseBox; private JComboBox<String> comboBox; private RuralHouse rh; /** * Create the frame. */ public ModifyHouseGUI(final Owner o) { this.distric=Districs.longNames(); comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>( this.distric)); this.getContentPane().setLayout(null); owner = o; setBounds(100, 100, 500, 583); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); JLabel lblCode = new JLabel("House Name:"); lblCode.setBounds(15, 88, 64, 14); lblCode.setHorizontalAlignment(SwingConstants.RIGHT); lblDistrict = new JLabel("District:"); lblDistrict.setBounds(39, 119, 70, 14); lblDistrict.setHorizontalAlignment(SwingConstants.RIGHT); lblDescription = new JLabel("Description:"); lblDescription.setBounds(231, 88, 90, 14); lblDescription.setHorizontalAlignment(SwingConstants.RIGHT); description_f = new JTextField(); description_f.setBounds(241, 113, 178, 129); description_f.setColumns(10); lblKitchen = new JLabel("Kitchens:"); lblKitchen.setBounds(230, 316, 70, 14); lblKitchen.setHorizontalAlignment(SwingConstants.RIGHT); kitchens_f = new JTextField(); kitchens_f.setBounds(318, 313, 86, 20); kitchens_f.setColumns(10); lblRooms = new JLabel("Rooms:"); lblRooms.setBounds(39, 316, 70, 14); lblRooms.setHorizontalAlignment(SwingConstants.RIGHT); rooms_f = new JTextField(); rooms_f.setBounds(127, 313, 86, 20); rooms_f.setColumns(10); lblLivings = new JLabel("Living rooms:"); lblLivings.setBounds(237, 354, 63, 14); lblLivings.setHorizontalAlignment(SwingConstants.RIGHT); lRooms_f = new JTextField(); lRooms_f.setBounds(318, 351, 86, 20); lRooms_f.setColumns(10); lblParkings = new JLabel("Parkings:"); lblParkings.setBounds(39, 404, 70, 14); lblParkings.setHorizontalAlignment(SwingConstants.RIGHT); parkings_f = new JTextField(); parkings_f.setBounds(127, 401, 86, 20); parkings_f.setColumns(10); lblBaths = new JLabel("Baths:"); lblBaths.setBounds(39, 354, 70, 14); lblBaths.setHorizontalAlignment(SwingConstants.RIGHT); baths_f = new JTextField(); baths_f.setBounds(127, 351, 86, 20); baths_f.setColumns(10); btnConfirm = new JButton("Confirm"); btnConfirm.setBounds(145, 462, 69, 23); btnConfirm.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { RuralHouse newRh = new RuralHouse(rh.getHouseName(), owner, description_f.getText(), (String)comboBox.getSelectedItem(), new HouseFeatures(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()))); HouseInterface hm= null; try { hm = (HouseInterface) Naming .lookup(___IntNames.HouseManager); } catch (Exception e1) { System.out.println("Error accessing remote authentication: " + e1.toString()); } try { if (hm.registerNewHouse(newRh)) { owner.getRuralHouses().add(newRh); houseBox.removeItem(rh); feedback.setText("House properly modified"); } else feedback.setText("Imposible to modify the house"); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); HouseInterface hm= null; try { hm = (HouseInterface) Naming .lookup(___IntNames.HouseManager); } catch (Exception e1) { System.out.println("Error accessing remote authentication: " + e1.toString()); } Vector<RuralHouse> list = null; try { list = hm.getHouses(o, null, null, 0, 0, 0, 0, 0); } catch (RemoteException e1) { e1.printStackTrace(); } houseBox = new JComboBox<RuralHouse>(list); if (!o.getRuralHouses().isEmpty()) { rh = (RuralHouse) houseBox.getSelectedItem(); comboBox.setSelectedItem(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())); houseBox.setBounds(89, 85, 124, 20); }else{ feedback.setText("Not available houses"); btnConfirm.setEnabled(false); } houseBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { rh = (RuralHouse) houseBox.getSelectedItem(); comboBox.setSelectedItem(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())); } }); contentPane.setLayout(null); contentPane.add(lblParkings); contentPane.add(parkings_f); contentPane.add(lblRooms); contentPane.add(rooms_f); contentPane.add(lblCode); contentPane.add(houseBox); contentPane.add(lblBaths); contentPane.add(baths_f); contentPane.add(lblDistrict); contentPane.add(lblLivings); contentPane.add(lRooms_f); contentPane.add(lblKitchen); contentPane.add(kitchens_f); contentPane.add(description_f); contentPane.add(lblDescription); contentPane.add(btnConfirm); feedback = new JLabel(""); feedback.setBounds(189, 510, 195, 23); contentPane.add(feedback); comboBox.setBounds(127, 116, 86, 20); contentPane.add(comboBox); } } |
Commits for RRRRHHHH_CoderuralHouses/src/gui/ModifyHouseGUI.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. |
153110 ... Diff | Eneko Pinzolas Murua | Sun 19 Apr, 2015 21:47:53 +0000 | debugging |
42679b ... Diff | pinene | Sun 19 Apr, 2015 14:18:02 +0000 | Merge branch ‘master’ of https://xp-dev.com/git/RRRRHHHH_Code Conflicts: |
520867 ... Diff | pinene | Sun 19 Apr, 2015 14:09:12 +0000 | tmp |
837fab ... Diff | Eneko Pinzolas Murua | Sat 18 Apr, 2015 14:09:49 +0000 | no warnings |
d5b843 ... Diff | Eneko Pinzolas Murua | Sat 18 Apr, 2015 14:01:54 +0000 | last version with phone regex |
46d6c3 ... | camjan | Wed 15 Apr, 2015 17:08:42 +0000 | Debbugin continues... |