Merged the two branches, DB separated
[RRRRHHHH_Code] / ruralHouses / src / gui / QueryAvailabilityGUI2.java
index 18555fc..6f4358e 100644 (file)
@@ -12,6 +12,8 @@ import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
 import java.sql.Date;
 import java.text.DateFormat;
 import java.util.Calendar;
@@ -32,10 +34,10 @@ import javax.swing.JRadioButton;
 import javax.swing.JTextField;
 import javax.swing.SwingConstants;
 
-import businessLogic.HouseManager;
-
 import com.toedter.calendar.JCalendar;
+import common.HouseInterface;
 
+import configuration.___IntNames;
 import domain.Districs;
 import domain.RuralHouse;
 
@@ -75,12 +77,20 @@ public class QueryAvailabilityGUI2 extends JFrame {
        private final JTextField nBaths = new JTextField();
        private final JLabel lblParkings = new JLabel("Parking slots:");
        private final JTextField nParkings = new JTextField();
-       private HouseManager houseMan = new HouseManager();
+       private HouseInterface houseMan = null;
        private final JLabel lblNumberOfLivings = new JLabel("Number of Livings:");
        private final JTextField nLivings = new JTextField();
        private final JLabel feedback = new JLabel("");
 
        public QueryAvailabilityGUI2() {
+               
+               try {
+                       houseMan =  (HouseInterface) Naming
+                                       .lookup(___IntNames.HouseManager);
+               } catch (Exception e1) {
+                       System.out.println("Error accessing remote authentication: "
+                                       + e1.toString());
+               }
                nLivings.setText("0");
                nLivings.setColumns(10);
                nParkings.setText("0");
@@ -286,16 +296,22 @@ public class QueryAvailabilityGUI2 extends JFrame {
 
        private void jButton1_actionPerformed(ActionEvent e) {
                if (this.district.isSelected()) {
-                       Vector<RuralHouse> houses = houseMan.getHouses(null, jComboBox1
-                                       .getSelectedItem().toString(), Integer.parseInt(nBedrooms
-                                       .getText()), Integer.parseInt(nKitchens.getText()), Integer
-                                       .parseInt(nBaths.getText()), Integer.parseInt(nParkings
-                                       .getText()), Integer.parseInt(nLivings.getText()));
+                       Vector<RuralHouse> houses = null;
+                       try {
+                               houses = houseMan.getHouses(null, null, jComboBox1
+                                               .getSelectedItem().toString(), Integer.parseInt(nBedrooms
+                                               .getText()), Integer.parseInt(nKitchens.getText()), Integer
+                                               .parseInt(nBaths.getText()), Integer.parseInt(nParkings
+                                               .getText()), Integer.parseInt(nLivings.getText()));
+                       } catch (NumberFormatException | RemoteException e1) {
+                               // TODO Auto-generated catch block
+                               e1.printStackTrace();
+                       }
                        listOfHousesGUI list = new listOfHousesGUI(houses);
                        list.setVisible(true);
                } else if (this.ruralHouseName.isSelected()) {
                        try {
-                               RuralHouse rh = houseMan.getHouses(jTextField3.getText(), null,
+                               RuralHouse rh = houseMan.getHouses(null, jTextField3.getText(), null,
                                                0, 0, 0, 0, 0).get(0);
                                // The next instruction creates a java.sql.Date object from the
                                // date selected in the JCalendar object