diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java index b95233d4ce23406fd7058a7a05fd298ef5e3baa4..33de93340d52d5c0a19cdf13bbf5b2d4c1e0dfd0 100644 --- a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java @@ -148,7 +148,7 @@ public class CityDoctorController { private void loadCityGmlZipFile(String path, int numberOfRoundingPlaces, ProgressListener l, boolean useValidation, boolean lowMemory) throws CityGmlParseException, InvalidGmlFileException { - currentChecker = null; + currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory); zipArchive = CityGmlZipArchive.register(path); @@ -160,33 +160,6 @@ public class CityDoctorController { throw new RuntimeException(e); } }); - /** - model = CityGmlParser.parseCityGmlFile(path, currentConfig, l, handler, true); - if (!validationIssues.isEmpty()) { - StringJoiner sj = new StringJoiner("\n"); - validationIssues.stream().forEach(sj::add); - throw new InvalidGmlFileException(sj.toString()); - } - mainWindow.getClickHandler().setConfig(currentConfig); - sourceFile = path; - renderer.reset(); - Platform.runLater(() -> { - mainWindow.addFileNameToTitle(path); - mainWindow.getCheckButton().setDisable(false); - mainWindow.getLod1Btn().setDisable(false); - mainWindow.getLod2Btn().setDisable(false); - mainWindow.getLod3Btn().setDisable(false); - mainWindow.getLod4Btn().setDisable(false); - mainWindow.getWorldBtn().setDisable(false); - mainWindow.getSaveBtn().setDisable(false); - mainWindow.getResetCameraBtn().setDisable(false); - mainWindow.getHideRoofBtn().setDisable(false); - mainWindow.getNorthArrow().setVisible(true); - mainWindow.alignNorthArrow(); - setupFeatureTabs(); - buildTrees(); - }); - **/ } public void decompressZipEntry(CityGmlZipEntry entry, ProgressListener l) { @@ -197,6 +170,49 @@ public class CityDoctorController { return zipArchive; } + public void loadZipEntry(CityGmlZipEntry entry) { + if (!entry.isDecompressed()) { + entry.loadEntry(currentConfig); + } + if (entry.getErrorType() != null) { + throw new IllegalArgumentException("Attempted to load erroneous zip entry"); + } + try { + Platform.runLater(() -> { + mainWindow.getOpenBtn().setDisable(true); + mainWindow.getWriteReportButton().setDisable(true); + mainWindow.getMeshGroup().getChildren().clear(); + clearTrees(); + mainWindow.resetSearchBar(); + mainWindow.resetFilterComboBox(); + }); + currentChecker = null; + model = entry.getModel(); + mainWindow.getClickHandler().setConfig(currentConfig); + sourceFile = entry.getArchive().getArchivePath().toString(); + renderer.reset(); + Platform.runLater(() -> { + mainWindow.addFileNameToTitle(entry.getArchive().getArchivePath().toString()); + mainWindow.getCheckButton().setDisable(false); + mainWindow.getLod1Btn().setDisable(false); + mainWindow.getLod2Btn().setDisable(false); + mainWindow.getLod3Btn().setDisable(false); + mainWindow.getLod4Btn().setDisable(false); + mainWindow.getWorldBtn().setDisable(false); + mainWindow.getSaveBtn().setDisable(false); + mainWindow.getResetCameraBtn().setDisable(false); + mainWindow.getHideRoofBtn().setDisable(false); + mainWindow.getNorthArrow().setVisible(true); + mainWindow.alignNorthArrow(); + setupFeatureTabs(); + buildTrees(); + }); + } finally { + Platform.runLater(() -> mainWindow.getOpenBtn().setDisable(false)); + } + + } + private void setupFeatureTabs() { mainWindow.setDisableOfFeatureTab(FeatureType.BUILDING, model.getBuildings().isEmpty()); mainWindow.setDisableOfFeatureTab(FeatureType.VEGETATION, model.getVegetation().isEmpty()); diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryPicker.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryPicker.java index 924ce9a5a15fdb82f5ce2cde7cfb28790cadff79..4b644e55adcfdfe91276b4eabecf62e80a06614c 100644 --- a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryPicker.java +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryPicker.java @@ -170,6 +170,16 @@ public class ZipEntryPicker { loadBtn.setOnAction(e -> { disableTaskButtons(); CityGmlZipEntry entry = entryList.getSelectionModel().getSelectedItem().getEntry(); + if (entry.getErrorType() != null) { + /** + * Button is disabled when an erroneous entry gets selected. + * Silently fail in case an erroneous entry is somehow selected on Action. + */ + logger.debug("IllegalState: loadBtn was pressed while an erroneous entry was selected"); + return; + } + controller.loadZipEntry(entry); + stage.hide(); });