Commit 54673522 authored by Riegel's avatar Riegel
Browse files

Feat: Implement ZipEntry decompression

2 merge requests!28Version 3.17.0 Release,!26Add ZIP-archive support
Showing with 44 additions and 9 deletions
+44 -9
...@@ -13,6 +13,7 @@ import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler; ...@@ -13,6 +13,7 @@ import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler;
import de.hft.stuttgart.citydoctor2.parser.*; import de.hft.stuttgart.citydoctor2.parser.*;
import de.hft.stuttgart.citydoctor2.utils.Localization; import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive; import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.scene.chart.XYChart.Data; import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series; import javafx.scene.chart.XYChart.Series;
...@@ -188,6 +189,10 @@ public class CityDoctorController { ...@@ -188,6 +189,10 @@ public class CityDoctorController {
**/ **/
} }
public void decompressZipEntry(CityGmlZipEntry entry) {
entry.loadEntry(currentConfig);
}
public CityGmlZipArchive getZipArchive() { public CityGmlZipArchive getZipArchive() {
return zipArchive; return zipArchive;
} }
......
...@@ -28,6 +28,7 @@ import org.apache.logging.log4j.LogManager; ...@@ -28,6 +28,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
public class ZipEntryPicker { public class ZipEntryPicker {
...@@ -77,13 +78,14 @@ public class ZipEntryPicker { ...@@ -77,13 +78,14 @@ public class ZipEntryPicker {
@FXML @FXML
private Button decompressBtn; private Button decompressBtn;
@FXML @FXML
private Button decompressImageView; private ImageView decompressImageView;
@FXML @FXML
private ListView<ZipEntryNode> entryList; private ListView<ZipEntryNode> entryList;
private CityDoctorController controller; private CityDoctorController controller;
private String unknownValueText = Localization.getText("ZipEntryPicker.unknownValue"); private String unknownValueText = Localization.getText("ZipEntryPicker.unknownValue");
public ZipEntryPicker(Window parent, CityDoctorController controller) throws IOException { public ZipEntryPicker(Window parent, CityDoctorController controller) throws IOException {
...@@ -106,22 +108,45 @@ public class ZipEntryPicker { ...@@ -106,22 +108,45 @@ public class ZipEntryPicker {
entryList.getSelectionModel().selectedItemProperty().addListener((obs, oldI, newI) -> { entryList.getSelectionModel().selectedItemProperty().addListener((obs, oldI, newI) -> {
if (newI != null) { if (newI != null) {
showMetadata(newI.getEntry()); showMetadata(newI.getEntry());
// Disable loadBtn when entry is erroneous
loadBtn.setDisable(newI.getEntry().getErrorType() != null);
} }
}); });
cancelBtn.setOnAction(e -> stage.close());
loadBtn.setOnAction(e -> {
CityGmlZipEntry entry = entryList.getSelectionModel().getSelectedItem().getEntry();
});
} }
public void initialize() { public void initialize() {
setupButtons();
applyLocalization(); applyLocalization();
populateZipEntryList(); populateZipEntryList();
} }
private void setupButtons() {
try {
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/decompress_zipEntry.png")) {
Image img = new Image(inStream);
decompressImageView.setImage(img);
}
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/load_zipEntry.png")) {
Image img = new Image(inStream);
loadImageView.setImage(img);
}
} catch (IOException ignored) {
//ignore exceptions
}
decompressBtn.setOnAction(e -> {
CityGmlZipEntry entry = entryList.getSelectionModel().getSelectedItem().getEntry();
controller.decompressZipEntry(entry);
populateZipEntryList(entryList.getSelectionModel().getSelectedIndex());
});
loadBtn.setOnAction(e -> {
CityGmlZipEntry entry = entryList.getSelectionModel().getSelectedItem().getEntry();
});
cancelBtn.setOnAction(e -> stage.close());
}
private void applyLocalization() { private void applyLocalization() {
entriesPane.setText(Localization.getText("ZipEntryPicker.entryListTitle")); entriesPane.setText(Localization.getText("ZipEntryPicker.entryListTitle"));
metadataPane.setText(Localization.getText("ZipEntryPicker.metadata")); metadataPane.setText(Localization.getText("ZipEntryPicker.metadata"));
...@@ -178,13 +203,17 @@ public class ZipEntryPicker { ...@@ -178,13 +203,17 @@ public class ZipEntryPicker {
} else { } else {
filesizeValue.setText(unknownValueText); filesizeValue.setText(unknownValueText);
} }
if (entry.getErrorType() != null) { if (entry.getErrorType() != null) {
erroneousValue.setText(getErrorText(entry.getErrorType())); erroneousValue.setText(getErrorText(entry.getErrorType()));
validatedValue.setText(unknownValueText); validatedValue.setText(unknownValueText);
objectCountValue.setText(unknownValueText); objectCountValue.setText(unknownValueText);
loadBtn.setDisable(true);
decompressBtn.setDisable(true);
} else { } else {
erroneousValue.setText(Localization.getText("ZipEntryPicker.no")); erroneousValue.setText(Localization.getText("ZipEntryPicker.no"));
loadBtn.setDisable(!entry.isDecompressed());
decompressBtn.setDisable(entry.isDecompressed());
if (entry.getModel() == null) { if (entry.getModel() == null) {
validatedValue.setText(unknownValueText); validatedValue.setText(unknownValueText);
objectCountValue.setText(unknownValueText); objectCountValue.setText(unknownValueText);
......
...@@ -9,6 +9,7 @@ public class ZipEntryListCell extends ListCell<ZipEntryNode> { ...@@ -9,6 +9,7 @@ public class ZipEntryListCell extends ListCell<ZipEntryNode> {
super.updateItem(item, empty); super.updateItem(item, empty);
if (!empty || item != null) { if (!empty || item != null) {
setText(item.getText()); setText(item.getText());
updateColor();
} else { } else {
setText(null); setText(null);
} }
......
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