/** 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()); } }
/** Export map areas. */ private void exportMapAreas() { JFileChooser fileChooser = userInterfaceFactory.createFileChooser(); XMLFileFilter xmlFileFilter = new XMLFileFilter(); fileChooser.setFileFilter(xmlFileFilter); int result = fileChooser.showSaveDialog(parentDialog); if (result != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = XMLFileFilter.ensureFileEndsWithXML(fileChooser.getSelectedFile()); ArrayList<MapArea> mapAreasToWrite = currentMapAreaSelectionBasket.getMapAreas(); MapAreaListWriter mapAreaListWriter = new MapAreaListWriter(); try { mapAreaListWriter.writeFile(selectedFile, mapAreasToWrite); } catch (RIFServiceException rifServiceException) { ErrorDialog.showError(parentDialog, rifServiceException.getErrorMessages()); } }
/** Import map areas. */ private void importMapAreas() { JFileChooser fileChooser = userInterfaceFactory.createFileChooser(); XMLFileFilter xmlFileFilter = new XMLFileFilter(); fileChooser.setFileFilter(xmlFileFilter); int result = fileChooser.showOpenDialog(parentDialog); if (result != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = fileChooser.getSelectedFile(); MapAreaListReader mapAreaListReader = new MapAreaListReader(); try { mapAreaListReader.readFile(selectedFile); ArrayList<MapArea> mapAreasToAdd = mapAreaListReader.getMapAreas(); currentMapAreaSelectionBasket.addMapAreas(mapAreasToAdd); } catch (RIFServiceException rifServiceException) { ErrorDialog.showError(parentDialog, rifServiceException.getErrorMessages()); } }