/** 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());
    }
  }
  /**
   * Instantiates a new map area list selection panel.
   *
   * @param parentDialog the parent dialog
   * @param rifSession the rif session
   */
  public MapAreaListSelectionPanel(JDialog parentDialog, RIFStudySubmissionToolSession rifSession) {

    this.parentDialog = parentDialog;
    this.rifSession = rifSession;
    this.userInterfaceFactory = rifSession.getUIFactory();

    String noDataDisplayedText =
        RIFJobSubmissionToolMessages.getMessage("mapAreaListSelectionPanel.noDataDisplayed");
    noDataDisplayedPanel =
        new NoDataAvailablePanel(userInterfaceFactory, noDataDisplayedText, true);

    mapAreaSelectionTableView = new MapAreaSelectionTableView(parentDialog, rifSession, true);
    // mapAreaSelectionTableView.updateDisplay();
    viewPanel = userInterfaceFactory.createBorderLayoutPanel();
    selectedItemsStatusTextArea = userInterfaceFactory.createNonEditableTextArea(4, 30);

    // mapImagePanel = new MapImagePanel();
    panel = userInterfaceFactory.createPanel();

    basketControlButtonPanel = new ListEditingButtonPanel(userInterfaceFactory);
  }