Commit 946bd130 authored by Riegel's avatar Riegel
Browse files

Feat: Added loading of ZipEntry into MainWindow

2 merge requests!28Version 3.17.0 Release,!26Add ZIP-archive support
Showing with 54 additions and 28 deletions
+54 -28
......@@ -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());
......
......@@ -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();
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment