import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
-import businessLogic.AdminManager;
+import common.AdminInterface;
+
+import configuration.___IntNames;
import domain.Districs;
import domain.HouseFeatures;
import domain.Owner;
private JLabel lblBaths;
private JTextField baths_f;
private JButton btnRegister;
- private AdminManager am;
+ private AdminInterface am = null;
private JComboBox<String> comboBox;
public RequestNewHouseGUI(Owner o) {
comboBox = new JComboBox<String>(new DefaultComboBoxModel<String>(
Districs.longNames()));
- am = new AdminManager();
+ try {
+ am = (AdminInterface) Naming
+ .lookup(___IntNames.AdminManager);
+ } catch (Exception e1) {
+ System.out.println("Error accessing remote authentication: "
+ + e1.toString());
+ }
this.setTitle("New House");
setBackground(Color.WHITE);
this.getContentPane().setLayout(null);
//TODO when the house is not added show a warning to the user. Method below returns a boolean stating that.
rh = new RuralHouse(Code_f.getText(),
owner, description_f.getText(),
- (String) comboBox.getSelectedItem() ,new HouseFeatures(Integer.parseInt(rooms_f.getText()),
+ (String) comboBox.getSelectedItem(), new HouseFeatures(Integer.parseInt(rooms_f.getText()),
Integer.parseInt(kitchens_f.getText()),
Integer.parseInt(baths_f.getText()),
Integer.parseInt(lRooms_f.getText()),
Integer.parseInt(parkings_f.getText())) );
}
- catch(NumberFormatException e ){
+ catch(NumberFormatException e){
e.printStackTrace();
}
- if(am.addAdditionRequest(rh)){
- feedback.setText("Request sended");
- }else{
- feedback.setText("Request cannot be sended(Already added)");
+ try {
+ if(am.addAdditionRequest(rh)){
+ am.saveInstance();
+ feedback.setText("Request sended");
+ }else{
+ feedback.setText("Request cannot be sended(Already added)");
+ }
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
}
});