X-Git-Url: https://git.piment-noir.org/?p=Persons_Comparator.git;a=blobdiff_plain;f=src%2FPersonView.java;h=901ce90158131b4f237ed5ca2c96a23a6152235e;hp=803fcf50498e42fbaa70e723e8faffbc38010578;hb=9f1e899962a92c9c1b8d3713eca0524964465014;hpb=a9c1e3ed70af9286718689befc35aae0c2eeb49c diff --git a/src/PersonView.java b/src/PersonView.java index 803fcf5..901ce90 100644 --- a/src/PersonView.java +++ b/src/PersonView.java @@ -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));