/** Creates a new instance of GeoPanelController */
  public GeoPanelController(GeoPanel geoPanel) {
    this.geoPanel = geoPanel;
    try {
      model = GeoService.getInstance().getGeoModel();
    } catch (Exception e1) {
      log.debug(this, e1);
    }
    model
        .getClientValueObjectProxy()
        .addListener(
            new ChangeListener() {

              public void stateChanged(ChangeEvent e) {
                update();
              }
            });
    regionModel = new GeoComboBoxModel();
    ArrayList regions = new ArrayList(model.getRegions());
    for (int i = 0, n = regions.size(); i < n; i++) {
      regionModel.addElement(regions.get(i));
    }
    geoPanel.getJComboBox1().setModel(regionModel);
    subregionModel = new GeoComboBoxModel();
    geoPanel.getJComboBox2().setModel(subregionModel);
    countryModel = new GeoComboBoxModel();
    geoPanel.getJComboBox3().setModel(countryModel);
    stateModel = new GeoComboBoxModel();
    geoPanel.getJComboBox4().setModel(stateModel);
  }
  public void refresh() {
    int regionIndex = geoPanel.getJComboBox1().getSelectedIndex();
    int subregionIndex = geoPanel.getJComboBox2().getSelectedIndex();
    int countryIndex = geoPanel.getJComboBox3().getSelectedIndex();
    int stateIndex = geoPanel.getJComboBox4().getSelectedIndex();
    regionModel.reset();
    try {
      model = GeoService.getInstance().getGeoModel();
    } catch (Exception e1) {
      log.debug(this, e1);
    }
    model
        .getClientValueObjectProxy()
        .addListener(
            new ChangeListener() {

              public void stateChanged(ChangeEvent e) {
                update();
              }
            });
    ArrayList regions = new ArrayList(model.getRegions());
    for (int i = 0, n = regions.size(); i < n; i++) {
      regionModel.addElement(regions.get(i));
    }

    geoPanel.getJComboBox1().setModel(regionModel);
    subregionModel = new GeoComboBoxModel();
    geoPanel.getJComboBox2().setModel(subregionModel);

    countryModel = new GeoComboBoxModel();
    geoPanel.getJComboBox3().setModel(countryModel);

    stateModel = new GeoComboBoxModel();
    geoPanel.getJComboBox4().setModel(stateModel);

    if (geoPanel.getJComboBox1().getItemAt(regionIndex) != null) {
      geoPanel.getJComboBox1().setSelectedIndex(regionIndex);
    }
    if (geoPanel.getJComboBox2().getItemAt(subregionIndex) != null) {
      geoPanel.getJComboBox2().setSelectedIndex(subregionIndex);
    }
    if (geoPanel.getJComboBox3().getItemAt(stateIndex) != null) {
      geoPanel.getJComboBox3().setSelectedIndex(countryIndex);
    }
  }