From 946bd13035b3d1f9b9ce769f21ea7a011bd20e5f Mon Sep 17 00:00:00 2001 From: Riegel <alexander.riegel@hft-stuttgart.de> Date: Wed, 8 Jan 2025 14:20:46 +0100 Subject: [PATCH] Feat: Added loading of ZipEntry into MainWindow --- .../citydoctor2/gui/CityDoctorController.java | 72 +++++++++++-------- .../citydoctor2/gui/ZipEntryPicker.java | 10 +++ 2 files changed, 54 insertions(+), 28 deletions(-) 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 b95233d..33de933 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 924ce9a..4b644e5 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(); }); -- GitLab