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;
import de.hft.stuttgart.citydoctor2.parser.*;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import javafx.application.Platform;
import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series;
......@@ -188,6 +189,10 @@ public class CityDoctorController {
**/
}
public void decompressZipEntry(CityGmlZipEntry entry) {
entry.loadEntry(currentConfig);
}
public CityGmlZipArchive getZipArchive() {
return zipArchive;
}
......
......@@ -28,6 +28,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.InputStream;
public class ZipEntryPicker {
......@@ -77,13 +78,14 @@ public class ZipEntryPicker {
@FXML
private Button decompressBtn;
@FXML
private Button decompressImageView;
private ImageView decompressImageView;
@FXML
private ListView<ZipEntryNode> entryList;
private CityDoctorController controller;
private String unknownValueText = Localization.getText("ZipEntryPicker.unknownValue");
public ZipEntryPicker(Window parent, CityDoctorController controller) throws IOException {
......@@ -106,22 +108,45 @@ public class ZipEntryPicker {
entryList.getSelectionModel().selectedItemProperty().addListener((obs, oldI, newI) -> {
if (newI != null) {
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() {
setupButtons();
applyLocalization();
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() {
entriesPane.setText(Localization.getText("ZipEntryPicker.entryListTitle"));
metadataPane.setText(Localization.getText("ZipEntryPicker.metadata"));
......@@ -178,13 +203,17 @@ public class ZipEntryPicker {
} else {
filesizeValue.setText(unknownValueText);
}
if (entry.getErrorType() != null) {
erroneousValue.setText(getErrorText(entry.getErrorType()));
validatedValue.setText(unknownValueText);
objectCountValue.setText(unknownValueText);
loadBtn.setDisable(true);
decompressBtn.setDisable(true);
} else {
erroneousValue.setText(Localization.getText("ZipEntryPicker.no"));
loadBtn.setDisable(!entry.isDecompressed());
decompressBtn.setDisable(entry.isDecompressed());
if (entry.getModel() == null) {
validatedValue.setText(unknownValueText);
objectCountValue.setText(unknownValueText);
......
......@@ -9,6 +9,7 @@ public class ZipEntryListCell extends ListCell<ZipEntryNode> {
super.updateItem(item, empty);
if (!empty || item != null) {
setText(item.getText());
updateColor();
} else {
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