diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryManager.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryManager.java index 0678a0835d02ba477b389d878c44ff33c8356d11..d0a2a44b19abcfc18209d75ec24c7f857f396f14 100644 --- a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryManager.java +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryManager.java @@ -116,7 +116,12 @@ public class ZipEntryManager { private int currentlyLoadedEntry = -1; private CheckDialog dialog; - private String unknownValueText = Localization.getText("ZipEntryManager.unknownValue"); + private final String unknownValueText = Localization.getText("ZipEntryManager.unknownValue"); + + private static final Predicate entryDecompressed = node -> + (node.getEntry().isDecompressed() || node.getEntry().getErrorType() != null); + private static final Predicate entryValidated = entryDecompressed.and(node -> + (node.getEntry().getModel() != null && node.getEntry().getModel().isValidated())); public ZipEntryManager(Window parent, CityDoctorController controller) throws IOException { FXMLLoader loader = new FXMLLoader(ZipEntryManager.class.getResource("ZipEntryManager.fxml")); @@ -192,7 +197,7 @@ public class ZipEntryManager { Platform.runLater(() -> progress.setProgress(progressValue)) ); Platform.runLater(() -> { - populateZipEntryList(entryList.getSelectionModel().getSelectedIndex()); + refresh(); progress.setProgress(0); setEntryListLocked(false); }); @@ -250,7 +255,7 @@ public class ZipEntryManager { } Platform.runLater(() -> { subProgress.setVisible(false); - populateZipEntryList(entryList.getSelectionModel().getSelectedIndex()); + refresh(); progress.setProgress(0); setEntryListLocked(false); }); @@ -344,9 +349,8 @@ public class ZipEntryManager { entryList.getSelectionModel().clearSelection(); entryList.getSelectionModel().select(selectionIndex); showMetadata(entryList.getSelectionModel().getSelectedItem().getEntry()); - Predicate allEntriesDecompressed = node -> (node.getEntry().isDecompressed() || node.getEntry().getErrorType() != null); - decompressAllBtn.setDisable(entryList.getItems().stream().allMatch(allEntriesDecompressed)); - saveBtn.setDisable(entryList.getItems().stream().allMatch(Predicate.not(allEntriesDecompressed))); + decompressAllBtn.setDisable(entryList.getItems().stream().allMatch(entryDecompressed)); + saveBtn.setDisable(entryList.getItems().stream().noneMatch(entryValidated)); } private void showMetadata(CityGmlZipEntry entry) { @@ -403,6 +407,8 @@ public class ZipEntryManager { decompressBtn.setDisable(true); loadBtn.setDisable(true); decompressAllBtn.setDisable(true); + showReportBtn.setDisable(true); + saveBtn.setDisable(true); } public void refresh() { @@ -429,9 +435,7 @@ public class ZipEntryManager { } public void show() { - Platform.runLater(() -> { - stage.showAndWait(); - }); - populateZipEntryList(entryList.getSelectionModel().getSelectedIndex()); + Platform.runLater(() -> stage.showAndWait()); + refresh(); } }