/**
   * Initialise apply settings.
   *
   * @param currentGeographicalArea the current geographical area
   * @param currentMapAreaSelectionBasket the current map area selection basket
   */
  public void initialiseApplySettings(
      Geography geography,
      AbstractGeographicalArea currentGeographicalArea,
      MapAreaSelectionBasket currentMapAreaSelectionBasket) {

    this.currentGeography = geography;
    this.currentGeographicalArea = currentGeographicalArea;
    this.currentMapAreaSelectionBasket = currentMapAreaSelectionBasket;
    mapAreaSelectionTableView.initialiseForm(
        currentGeographicalArea, currentMapAreaSelectionBasket);
    mapAreaSelectionTableView.showFirstResultPage();

    viewPanel.removeAll();
    viewPanel.add(mapAreaSelectionTableView.getPanel(), BorderLayout.CENTER);
    viewPanel.updateUI();

    // update the map display area
    GeoLevelSelect geoLevelSelect = currentGeographicalArea.getGeoLevelSelect();
    GeoLevelView geoLevelView = currentGeographicalArea.getGeoLevelView();
    GeoLevelArea geoLevelArea = currentGeographicalArea.getGeoLevelArea();

    // remove any observers for the current basket.  We want to clear
    // it without triggering updates elsewhere in the UI
    currentMapAreaSelectionBasket.deleteObservers();
    currentMapAreaSelectionBasket.addObserver(this);

    /*
    ArrayList<MapArea> mapAreas = currentMapAreaSelectionBasket.getMapAreas();
    try {
    	RIFStudySubmissionAPI service
    		= rifSession.getRIFStudySubmissionService();
    	User currentUser = rifSession.getUser();
    	BufferedImage bufferedImage
    		= service.getImage(
    			currentUser,
    			geography,
    			geoLevelSelect,
    			geoLevelArea,
    			geoLevelView,
    			mapAreas);
    	mapImagePanel.setData(bufferedImage);
    	mapImagePanel.repaint();
    }
    catch(RIFServiceException rifServiceException) {
    	ErrorDialog.showError(parentDialog, rifServiceException);
    }
    */

    // update the status panel

    updateBasketStatusPanel();

    // add the basket observers back in
    buildUI();
  }
  /** Update basket status panel. */
  private void updateBasketStatusPanel() {

    try {
      RIFStudySubmissionAPI service = rifSession.getRIFStudySubmissionService();
      User currentUser = rifSession.getUser();
      Geography currentGeography = rifSession.getCurrentGeography();
      GeoLevelSelect currentGeoLevelSelect = currentGeographicalArea.getGeoLevelSelect();
      GeoLevelArea currentGeoLevelArea = currentGeographicalArea.getGeoLevelArea();
      GeoLevelToMap currentGeoLevelToMap = currentGeographicalArea.getGeoLevelToMap();

      // Sensitise the control buttons appropriately to reflect
      // whether basket is empty or not
      if (currentMapAreaSelectionBasket.getSize() == 0) {
        String basketIsEmptyMessage =
            RIFJobSubmissionToolMessages.getMessage("mapAreaListSelectionPanel.basketIsEmpty");
        selectedItemsStatusTextArea.setText(basketIsEmptyMessage);

        // basket is empty
        basketControlButtonPanel.indicateEmptyState();
      } else {
        // current geo level select should only be null
        // when the application is first starting.  By this point,
        // GeoLevelSelect will not have been selected
        MapAreaSummaryData mapAreaSummaryData =
            service.getMapAreaSummaryInformation(
                currentUser,
                currentGeography,
                currentGeoLevelSelect,
                currentGeoLevelArea,
                currentGeoLevelToMap,
                currentMapAreaSelectionBasket.getMapAreas());

        // Display information about the areas currently in the basket
        StringBuilder selectedStatusMessage = new StringBuilder();
        String selectedAreasMessage =
            RIFJobSubmissionToolMessages.getMessage(
                "mapAreaListSelectionPanel.basketAreasMessage",
                String.valueOf(mapAreaSummaryData.getTotalViewAreas()),
                String.valueOf(mapAreaSummaryData.getTotalNumberToMapAreas()),
                currentGeoLevelToMap.getDisplayName());
        selectedStatusMessage.append(selectedAreasMessage);
        String totalAreaTotalPopulationMessage =
            RIFJobSubmissionToolMessages.getMessage(
                "mapAreaListSelectionPanel.totalAreaTotalPopulationMessage",
                String.valueOf(mapAreaSummaryData.getTotalPopulation()),
                String.valueOf(mapAreaSummaryData.getTotalArea()));
        selectedStatusMessage.append(totalAreaTotalPopulationMessage);
        selectedItemsStatusTextArea.setText(selectedStatusMessage.toString());

        basketControlButtonPanel.indicatePopulatedState();
      }
    } catch (RIFServiceException rifServiceException) {
      ErrorDialog.showError(parentDialog, rifServiceException.getErrorMessages());
    }
  }