private void doChangeSecondaryListBox() {
    // as usual, determine the mtfcc from the BTLB
    String mtfcc = getBTLBValue();

    // if the mtfcc is a county based feature but is not a county...
    if (!mtfcc.equals(GeographyUtils.MTFCC.COUNTY) && GeographyUtils.isCountyBasedMtfcc(mtfcc)) {

      // get the state and county FIPS codes
      String geoId = getSLBValue();
      String stateFP = geoId.substring(0, 2);
      String countyFP = geoId.substring(2);

      dispatch.execute(
          new GetLocationsByStateAndCountyAndMtfccAction(mtfcc, stateFP, countyFP),
          new AsyncCallback<GetLocationsByStateAndCountyAndMtfccResult>() {
            @Override
            public void onFailure(Throwable throwable) {
              throwable.printStackTrace();
            }

            @Override
            public void onSuccess(GetLocationsByStateAndCountyAndMtfccResult result) {

              getView().getTertiaryListBox().clear();
              getView().getTertiaryListBox().addItem("-- Select Feature --");
              Map<String, String> resultMap = result.getResult();
              for (String fp : resultMap.keySet()) {
                getView().getTertiaryListBox().addItem(resultMap.get(fp), fp);
              }
            }
          });

      getView().getTertiaryListBox().setEnabled(true);
    }
  }
  @Override
  public void onRedrawMap() {

    getView().getRedrawMapButton().setEnabled(false);

    // figure out which MTFCC the user wants to see
    int mtfccValue = getView().getBorderTypeListBox().getSelectedIndex();
    if (mtfccValue == -1) {
      getView().displayAngryMessage("You must select a border type!");
      return;
    }
    String mtfccCode = getView().getBorderTypeListBox().getValue(mtfccValue);

    String generatedGeoId;
    if (mtfccCode.equals(GeographyUtils.MTFCC.STATE)) {
      generatedGeoId = getPLBValue();
    } else if (mtfccCode.equals(GeographyUtils.MTFCC.COUNTY)) {
      generatedGeoId = getSLBValue();
    } else if (!mtfccCode.equals(GeographyUtils.MTFCC.STATE)
        && GeographyUtils.isStateBasedMtfcc(mtfccCode)) {
      generatedGeoId = getTLBValue();
    } else if (!mtfccCode.equals(GeographyUtils.MTFCC.COUNTY)
        && GeographyUtils.isCountyBasedMtfcc(mtfccCode)) {
      generatedGeoId = getTLBValue();
    } else {
      return;
    }

    // get the feature class name
    int fcnIndex = getView().getFeaturesListBox().getSelectedIndex();
    String featureClassName;
    if (fcnIndex != -1) {
      featureClassName =
          getView()
              .getFeaturesListBox()
              .getValue(fcnIndex); // rot roh! throws arrayindexoutofbounds if no feature selected!
      getEventBus().fireEvent(new RedrawMapEvent(generatedGeoId, mtfccCode, featureClassName));
    } else {
      getEventBus().fireEvent(new RedrawMapEvent(generatedGeoId, mtfccCode));
    }
  }
  private void doChangePrimaryListBox() {

    getView().getSecondaryListBox().clear();
    getView().getTertiaryListBox().clear();

    // as usual, determine the mtfcc from the BTLB
    String mtfcc = getBTLBValue();

    // make sure that if it's just a state, we don't do anything
    if (mtfcc.equals(GeographyUtils.MTFCC.STATE)) {
      return; // exit onChange() so that we don't process via any call to
      // GeographyUtils.isStateBasedMtfcc()
    }

    if (mtfcc.equals(GeographyUtils.MTFCC.COUNTY)) {

      // okay, I'm violating DRY. Hate me if you want.

      String stateFP = getPLBValue();

      dispatch.execute(
          new GetLocationsByStateAndMtfccAction(stateFP, GeographyUtils.MTFCC.COUNTY),
          new AsyncCallback<GetLocationsByStateAndMtfccResult>() {
            @Override
            public void onFailure(Throwable throwable) {
              getView().getSecondaryListBox().setEnabled(false);
              throwable.printStackTrace();
            }

            @Override
            public void onSuccess(GetLocationsByStateAndMtfccResult result) {

              getView().getSecondaryListBox().clear();
              getView().getSecondaryListBox().addItem("-- Select County --");
              Map<String, String> resultMap = result.getResult();
              resultMap.remove(null);
              for (String key : resultMap.keySet()) {
                getView().getSecondaryListBox().addItem(resultMap.get(key), key);
              }
              getView().getSecondaryListBox().setEnabled(true);
            }
          });

      return;
    }

    // if it's a state-based mtfcc, populate the TLB with the location names
    if (GeographyUtils.isStateBasedMtfcc(mtfcc)) {

      String stateFP = getPLBValue();

      dispatch.execute(
          new GetLocationsByStateAndMtfccAction(stateFP, mtfcc),
          new AsyncCallback<GetLocationsByStateAndMtfccResult>() {
            @Override
            public void onFailure(Throwable caught) {
              caught.printStackTrace();
            }

            @Override
            public void onSuccess(GetLocationsByStateAndMtfccResult result) {
              getView().getTertiaryListBox().setEnabled(true);
              Map<String, String> resultMap = result.getResult();
              resultMap.remove(null);
              resultMap.remove(getPLBValue());
              for (String key : resultMap.keySet()) {
                getView().getTertiaryListBox().addItem(resultMap.get(key), key);
              }
            }
          });

      return;
    }

    if (GeographyUtils.isCountyBasedMtfcc(mtfcc)) {

      String stateFP = getPLBValue();

      dispatch.execute(
          new GetLocationsByStateAndMtfccAction(stateFP, GeographyUtils.MTFCC.COUNTY),
          new AsyncCallback<GetLocationsByStateAndMtfccResult>() {
            @Override
            public void onFailure(Throwable throwable) {
              getView().getSecondaryListBox().setEnabled(false);
              throwable.printStackTrace();
            }

            @Override
            public void onSuccess(GetLocationsByStateAndMtfccResult result) {

              getView().getSecondaryListBox().clear();
              getView().getSecondaryListBox().addItem("-- Select County --");
              Map<String, String> resultMap = result.getResult();
              resultMap.remove(null);
              for (String key : resultMap.keySet()) {
                getView().getSecondaryListBox().addItem(resultMap.get(key), key);
              }
              getView().getSecondaryListBox().setEnabled(true);
            }
          });

      return; // exit function to ensure that we don't process via isCountyBasedMtfcc()
    }
  }