Commit 9bd18e59 authored by Riegel's avatar Riegel
Browse files

Feat: Add saveBtn to ZipEntryManager

2 merge requests!28Version 3.17.0 Release,!26Add ZIP-archive support
Showing with 104 additions and 56 deletions
+104 -56
......@@ -2,6 +2,7 @@ package de.hft.stuttgart.citydoctor2.gui;
import de.hft.stuttgart.citydoctor2.gui.tree.ZipEntryListCell;
import de.hft.stuttgart.citydoctor2.gui.tree.ZipEntryNode;
import de.hft.stuttgart.citydoctor2.utils.ArchivePacker;
import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
......@@ -22,14 +23,17 @@ import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.function.Predicate;
public class ZipEntryManager {
......@@ -96,6 +100,11 @@ public class ZipEntryManager {
@FXML
private ImageView showReportImageView;
@FXML
private Button saveBtn;
@FXML
private ImageView saveImageView;
@FXML
private ListView<ZipEntryNode> entryList;
@FXML
......@@ -165,6 +174,10 @@ public class ZipEntryManager {
Image img = new Image(inStream);
showReportImageView.setImage(img);
}
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/save.png")) {
Image img = new Image(inStream);
saveImageView.setImage(img);
}
} catch (IOException ignored) {
//ignore exceptions
}
......@@ -273,6 +286,19 @@ public class ZipEntryManager {
});
showReportBtn.setDisable(true);
saveBtn.setOnAction(e -> {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Export Zip file");
FileChooser.ExtensionFilter zipFilter = new FileChooser.ExtensionFilter("Zip File", "*.zip");
fileChooser.getExtensionFilters().add(zipFilter);
File f = fileChooser.showSaveDialog(stage.getOwner());
if (f != null) {
ArchivePacker.packArchive(f.getAbsolutePath(), archive);
}
});
saveBtn.setDisable(true);
cancelBtn.setOnAction(e -> stage.close());
}
......@@ -311,9 +337,9 @@ public class ZipEntryManager {
entryList.getSelectionModel().clearSelection();
entryList.getSelectionModel().select(selectionIndex);
showMetadata(entryList.getSelectionModel().getSelectedItem().getEntry());
decompressAllBtn.setDisable(
entryList.getItems().stream().allMatch(zipEntryNode ->
(zipEntryNode.getEntry().isDecompressed()) || zipEntryNode.getEntry().getErrorType() != null));
Predicate<ZipEntryNode> 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)));
}
private void showMetadata(CityGmlZipEntry entry) {
......
......@@ -17,60 +17,82 @@
<VBox xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1">
<children>
<HBox prefHeight="50.0" prefWidth="200.0" spacing="5.0">
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
<children>
<Button fx:id="loadBtn" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="loadImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true"
preserveRatio="true"/>
</graphic>
</Button>
<Button fx:id="decompressBtn" alignment="CENTER" layoutX="15.0" layoutY="15.0"
maxWidth="1.7976931348623157E308" mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="decompressImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true"
preserveRatio="true"/>
</graphic>
</Button>
<Button fx:id="showReportBtn" alignment="CENTER" layoutX="70.0" layoutY="15.0"
maxWidth="1.7976931348623157E308" mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="showReportImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true"
preserveRatio="true"/>
</graphic>
</Button>
<Separator orientation="VERTICAL" prefHeight="200.0"/>
<Button fx:id="decompressAllBtn" alignment="CENTER" layoutX="70.0" layoutY="15.0"
maxWidth="1.7976931348623157E308" mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="decompressAllImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true"
preserveRatio="true"/>
</graphic>
</Button>
<Button fx:id="checkAllBtn" alignment="CENTER" layoutX="126.0" layoutY="15.0"
maxWidth="1.7976931348623157E308" mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="checkAllImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true"
preserveRatio="true"/>
</graphic>
</Button>
<HBox spacing="5.0">
<children>
<Button fx:id="loadBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="loadImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true"
preserveRatio="true"/>
</graphic>
</Button>
<Button fx:id="decompressBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="decompressImageView" fitHeight="32.0" fitWidth="32.0"
pickOnBounds="true" preserveRatio="true"/>
</graphic>
</Button>
<Button fx:id="showReportBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="showReportImageView" fitHeight="32.0" fitWidth="32.0"
pickOnBounds="true" preserveRatio="true"/>
</graphic>
</Button>
<Separator orientation="VERTICAL" prefHeight="200.0"/>
<Button fx:id="decompressAllBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="decompressAllImageView" fitHeight="32.0" fitWidth="32.0"
pickOnBounds="true" preserveRatio="true"/>
</graphic>
</Button>
<Button fx:id="checkAllBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="checkAllImageView" fitHeight="32.0" fitWidth="32.0"
pickOnBounds="true" preserveRatio="true"/>
</graphic>
</Button>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
</HBox>
<HBox alignment="TOP_RIGHT" prefHeight="52.0" prefWidth="124.0">
<children>
<Button fx:id="saveBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
mnemonicParsing="false">
<font>
<Font size="14.0"/>
</font>
<graphic>
<ImageView fx:id="saveImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true"
preserveRatio="true"/>
</graphic>
</Button>
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
</HBox>
</children>
</HBox>
<HBox fillHeight="false" prefHeight="200.0" prefWidth="600.0" VBox.vgrow="ALWAYS">
......
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