GUI added to show list of available houses
[RRRRHHHH_Code] / ruralHouses / src / gui / QueryAvailabilityGUI2.java
index b176ef2..d95dcfe 100644 (file)
@@ -10,6 +10,7 @@ import javax.swing.*;
 import java.awt.*;
 import java.awt.event.*;
 
+import businessLogic.HouseManager;
 import businessLogic.OfferManager;
 
 import com.toedter.calendar.JCalendar;
@@ -41,6 +42,7 @@ public class QueryAvailabilityGUI2 extends JFrame {
        private final JLabel lblNewLabel = new JLabel("");
        private final JRadioButton ruralHouseName = new JRadioButton(
                        "Use RuralHouse name");
+       private final   JRadioButton district = new JRadioButton("Use district name");
        private final ButtonGroup buttonGroup = new ButtonGroup();
        private final JMenuBar menuBar = new JMenuBar();
        private final JMenu mnMoreOptions = new JMenu("Search Options");
@@ -54,24 +56,26 @@ 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();
 
-       public QueryAvailabilityGUI2(Vector<RuralHouse> v) {
+       public QueryAvailabilityGUI2() {
                nParkings.setText("");
                nParkings.setColumns(10);
                nBaths.setColumns(10);
                try {
-                       jbInit(v);
+                       jbInit();
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
 
-       private void jbInit(Vector<RuralHouse> v) throws Exception {
+       private void jbInit() throws Exception {
                this.getContentPane().setLayout(null);
                this.setSize(new Dimension(550, 500));
                this.setTitle("Set availability");
 
-               jComboBox1 = new JComboBox(v);
+               //TODO here we should add the districts of villatripas this is just for testing purposes
+               jComboBox1 = new JComboBox(this.houseMan.getAllRuralHouses());
                jComboBox1.setBounds(new Rectangle(115, 30, 115, 20));
                jLabel2.setText("First day :");
                jLabel2.setBounds(new Rectangle(20, 134, 85, 25));
@@ -191,12 +195,11 @@ public class QueryAvailabilityGUI2 extends JFrame {
 
                getContentPane().add(lblNewLabel);
 
-               JRadioButton district = new JRadioButton("Use district name");
-               district.setSelected(true);
-               buttonGroup.add(district);
+               district.setSelected(true);;
                district.setBounds(20, 69, 128, 20);
                getContentPane().add(district);
                buttonGroup.add(ruralHouseName);
+               buttonGroup.add(district);
                ruralHouseName.setBounds(276, 60, 177, 38);
                district.addItemListener(new ItemListener() {
                        @Override
@@ -240,7 +243,12 @@ public class QueryAvailabilityGUI2 extends JFrame {
        }
 
        private void jButton1_actionPerformed(ActionEvent e) {
-               
+               if(this.district.isSelected()){
+                       //show list of houses GUI
+               }
+               else if(this.ruralHouseName.isSelected()){
+                       //show features of specific house
+               }
        }
 
        private void jButton2_actionPerformed(ActionEvent e) {