Commit fb528f1d authored by Riegel's avatar Riegel
Browse files

Feat: Implement populating of ZipEntryList

parent 6037d7a1
Showing with 66 additions and 3 deletions
+66 -3
...@@ -82,7 +82,6 @@ public class ZipEntryPicker { ...@@ -82,7 +82,6 @@ public class ZipEntryPicker {
this.controller = controller; this.controller = controller;
archive = controller.getZipArchive(); archive = controller.getZipArchive();
VBox box = loader.load(); VBox box = loader.load();
this.controller = controller;
stage = new Stage(); stage = new Stage();
stage.getIcons().add(new Image(MainWindow.class.getResourceAsStream("icons/CityDoctor-Logo-rot_klein.jpg"))); stage.getIcons().add(new Image(MainWindow.class.getResourceAsStream("icons/CityDoctor-Logo-rot_klein.jpg")));
stage.setScene(new Scene(box)); stage.setScene(new Scene(box));
...@@ -94,11 +93,16 @@ public class ZipEntryPicker { ...@@ -94,11 +93,16 @@ public class ZipEntryPicker {
stage.close(); stage.close();
} }
}); });
entryList.getSelectionModel().selectedItemProperty().addListener((obs, oldI, newI) -> {
if (newI != null) {
showMetadata(newI.getEntry());
}
});
} }
public void initialize() { public void initialize() {
applyLanguageControls();
applyLocalization(); applyLocalization();
populateZipEntryList();
} }
private void applyLocalization() { private void applyLocalization() {
...@@ -120,7 +124,66 @@ public class ZipEntryPicker { ...@@ -120,7 +124,66 @@ public class ZipEntryPicker {
cancelBtn.setText(Localization.getText("ZipEntryPicker.cancelBtn")); cancelBtn.setText(Localization.getText("ZipEntryPicker.cancelBtn"));
} }
private void applyLanguageControls() { private void populateZipEntryList() {
entryList.getItems().clear();
entryList.setCellFactory(param -> new ZipEntryListCell());
for (CityGmlZipEntry entry : archive.getEntries()) {
entryList.getItems().add(new ZipEntryNode(entry));
}
}
private void showMetadata(CityGmlZipEntry entry) {
subpathValueTxt.setText(entry.getFileName());
if (entry.getFileSize() != -1L) {
long fileSize = entry.getFileSize();
long KB = 1024L;
long MB = KB * KB;
long GB = MB * KB;
if (fileSize < KB) {
filesizeValue.setText("< 1 KB");
} else if (fileSize < MB) {
filesizeValue.setText(String.format("%s KB", fileSize / KB));
} else if (fileSize < GB) {
filesizeValue.setText(String.format("%s MB", fileSize / MB));
} else {
double gigabytes = (double) fileSize / GB;
filesizeValue.setText(String.format("%.2f GB", gigabytes));
}
} else {
filesizeValue.setText(unknownValueText);
}
if (entry.getErrorType() != null) {
erroneousValue.setText(getErrorText(entry.getErrorType()));
validatedValue.setText(unknownValueText);
objectCountValue.setText(unknownValueText);
} else {
erroneousValue.setText(Localization.getText("ZipEntryPicker.no"));
if (entry.getModel() == null) {
}
}
}
private String getErrorText(ZipEntryErrorType error) {
switch (error) {
case EXCESSIVE_FILESIZE -> {
return Localization.getText("ZipEntryPicker.excessiveFileSize");
}
case INVALID_CITY_GML_FILE -> {
return Localization.getText("ZipEntryPicker.invalidCityGml");
}
default -> {
return Localization.getText("ZipEntryPicker.ioError");
}
}
}
public void show() {
Platform.runLater(() -> {
stage.showAndWait();
});
} }
} }
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