Switch person class usage of Origin class to Country class and use it for distance...
[Persons_Comparator.git] / src / PersonView.java
index 803fcf50498e42fbaa70e723e8faffbc38010578..901ce90158131b4f237ed5ca2c96a23a6152235e 100644 (file)
@@ -84,11 +84,14 @@ public class PersonView extends JComponent implements ActionListener {
         this.originView = originView;
     }
 
+    public RegionView getRegionView() {
+        return regionView;
+    }
+
     public void setRegionView(RegionView regionView) {
         this.regionView = regionView;
     }
 
-
     /**
      * @return
      */
@@ -167,20 +170,23 @@ public class PersonView extends JComponent implements ActionListener {
     public void actionPerformed(ActionEvent actionEvent) {
         //TODO: one can implement a smarter way of getting all inputs values inside the main panel.
         String firstname = this.getFirstnameView().getTextField().getText();
-        String country = null;
-        if (this.getOriginView().getComboBox().getSelectedIndex() != -1)
-            country = (String) this.getOriginView().getComboBox().getSelectedObjects()[0];
+        String countryName = null;
+        if (this.getRegionView().getTree().getLastSelectedPathComponent() != null)
+            countryName = this.getRegionView().getTree().getLastSelectedPathComponent().toString();
+        /*if (this.getOriginView().getComboBox().getSelectedIndex() != -1)
+            countryName = (String) this.getOriginView().getComboBox().getSelectedObjects()[0];*/
         Integer size = (Integer) this.getSizeView().getSpinner().getValue();
         Integer weight = (Integer) this.getWeightView().getComboBox().getSelectedItem();
         String eye_color = (String) this.getEyeView().getColorsList().getSelectedValue();
-        if (firstname.equals("") || country == null || eye_color == null) {
+        if (firstname.equals("") || countryName == null || eye_color == null) {
             JOptionPane.showMessageDialog(this,
                     "Some required fields are missing.",
                     "Error",
                     JOptionPane.ERROR_MESSAGE);
         } else {
             this.getPersonObj().setFirstname(new Firstname(firstname));
-            this.getPersonObj().setOrigin(new Origin(country));
+            //this.getPersonObj().setOrigin(new Origin(countryName));
+            this.getPersonObj().setCountry(new Country(countryName));
             this.getPersonObj().setPersonSize(new Size(size));
             this.getPersonObj().setWeight(new Weight(weight));
             this.getPersonObj().setEye(new Eye(eye_color));