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.SwingConstants;
import javax.swing.border.EmptyBorder;
-import businessLogic.HouseManager;
+import common.HouseInterface;
+
+import configuration.___IntNames;
import domain.Districs;
import domain.HouseFeatures;
import domain.Owner;
/**
* Create the frame.
*/
- public ModifyHouseGUI(Owner o) {
+ public ModifyHouseGUI(final Owner o) {
this.distric=Districs.longNames();
- comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+ comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
+
this.distric));
this.getContentPane().setLayout(null);
owner = o;
baths_f.getText()), new Integer(
lRooms_f.getText()), new Integer(
parkings_f.getText())));
- HouseManager hm = new HouseManager();
-
- if (hm.registerNewHouse(newRh)) {
- owner.getRuralHouses().remove(rh);
- owner.getRuralHouses().add(newRh);
- houseBox.removeItem(rh);
- feedback.setText("House properly modified");
- } else
- feedback.setText("Imposible to modify the house");
+ 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();
+ }
}
});
-
- houseBox = new JComboBox<RuralHouse>(o.getRuralHouses());
+ 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());