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

Feat: Add saveBtn to ZipEntryManager

parent faa5b330
...@@ -2,6 +2,7 @@ package de.hft.stuttgart.citydoctor2.gui; ...@@ -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.ZipEntryListCell;
import de.hft.stuttgart.citydoctor2.gui.tree.ZipEntryNode; 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.utils.Localization;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive; import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry; import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
...@@ -22,14 +23,17 @@ import javafx.scene.image.ImageView; ...@@ -22,14 +23,17 @@ import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent; import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.Window; import javafx.stage.Window;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.function.Predicate;
public class ZipEntryManager { public class ZipEntryManager {
...@@ -96,6 +100,11 @@ public class ZipEntryManager { ...@@ -96,6 +100,11 @@ public class ZipEntryManager {
@FXML @FXML
private ImageView showReportImageView; private ImageView showReportImageView;
@FXML
private Button saveBtn;
@FXML
private ImageView saveImageView;
@FXML @FXML
private ListView<ZipEntryNode> entryList; private ListView<ZipEntryNode> entryList;
@FXML @FXML
...@@ -165,6 +174,10 @@ public class ZipEntryManager { ...@@ -165,6 +174,10 @@ public class ZipEntryManager {
Image img = new Image(inStream); Image img = new Image(inStream);
showReportImageView.setImage(img); showReportImageView.setImage(img);
} }
try (InputStream inStream = MainWindow.class.getResourceAsStream("icons/save.png")) {
Image img = new Image(inStream);
saveImageView.setImage(img);
}
} catch (IOException ignored) { } catch (IOException ignored) {
//ignore exceptions //ignore exceptions
} }
...@@ -273,6 +286,19 @@ public class ZipEntryManager { ...@@ -273,6 +286,19 @@ public class ZipEntryManager {
}); });
showReportBtn.setDisable(true); 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()); cancelBtn.setOnAction(e -> stage.close());
} }
...@@ -311,9 +337,9 @@ public class ZipEntryManager { ...@@ -311,9 +337,9 @@ public class ZipEntryManager {
entryList.getSelectionModel().clearSelection(); entryList.getSelectionModel().clearSelection();
entryList.getSelectionModel().select(selectionIndex); entryList.getSelectionModel().select(selectionIndex);
showMetadata(entryList.getSelectionModel().getSelectedItem().getEntry()); showMetadata(entryList.getSelectionModel().getSelectedItem().getEntry());
decompressAllBtn.setDisable( Predicate<ZipEntryNode> allEntriesDecompressed = node -> (node.getEntry().isDecompressed() || node.getEntry().getErrorType() != null);
entryList.getItems().stream().allMatch(zipEntryNode -> decompressAllBtn.setDisable(entryList.getItems().stream().allMatch(allEntriesDecompressed));
(zipEntryNode.getEntry().isDecompressed()) || zipEntryNode.getEntry().getErrorType() != null)); saveBtn.setDisable(entryList.getItems().stream().allMatch(Predicate.not(allEntriesDecompressed)));
} }
private void showMetadata(CityGmlZipEntry entry) { private void showMetadata(CityGmlZipEntry entry) {
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
<VBox xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"> <VBox xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1">
<children> <children>
<HBox prefHeight="50.0" prefWidth="200.0" spacing="5.0"> <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> <children>
<Button fx:id="loadBtn" alignment="CENTER" maxWidth="1.7976931348623157E308" mnemonicParsing="false"> <HBox spacing="5.0">
<children>
<Button fx:id="loadBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
mnemonicParsing="false">
<font> <font>
<Font size="14.0"/> <Font size="14.0"/>
</font> </font>
...@@ -30,48 +30,70 @@ ...@@ -30,48 +30,70 @@
preserveRatio="true"/> preserveRatio="true"/>
</graphic> </graphic>
</Button> </Button>
<Button fx:id="decompressBtn" alignment="CENTER" layoutX="15.0" layoutY="15.0" <Button fx:id="decompressBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" mnemonicParsing="false"> mnemonicParsing="false">
<font> <font>
<Font size="14.0"/> <Font size="14.0"/>
</font> </font>
<graphic> <graphic>
<ImageView fx:id="decompressImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" <ImageView fx:id="decompressImageView" fitHeight="32.0" fitWidth="32.0"
preserveRatio="true"/> pickOnBounds="true" preserveRatio="true"/>
</graphic> </graphic>
</Button> </Button>
<Button fx:id="showReportBtn" alignment="CENTER" layoutX="70.0" layoutY="15.0" <Button fx:id="showReportBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" mnemonicParsing="false"> mnemonicParsing="false">
<font> <font>
<Font size="14.0"/> <Font size="14.0"/>
</font> </font>
<graphic> <graphic>
<ImageView fx:id="showReportImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" <ImageView fx:id="showReportImageView" fitHeight="32.0" fitWidth="32.0"
preserveRatio="true"/> pickOnBounds="true" preserveRatio="true"/>
</graphic> </graphic>
</Button> </Button>
<Separator orientation="VERTICAL" prefHeight="200.0"/> <Separator orientation="VERTICAL" prefHeight="200.0"/>
<Button fx:id="decompressAllBtn" alignment="CENTER" layoutX="70.0" layoutY="15.0" <Button fx:id="decompressAllBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" mnemonicParsing="false"> mnemonicParsing="false">
<font> <font>
<Font size="14.0"/> <Font size="14.0"/>
</font> </font>
<graphic> <graphic>
<ImageView fx:id="decompressAllImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" <ImageView fx:id="decompressAllImageView" fitHeight="32.0" fitWidth="32.0"
preserveRatio="true"/> pickOnBounds="true" preserveRatio="true"/>
</graphic> </graphic>
</Button> </Button>
<Button fx:id="checkAllBtn" alignment="CENTER" layoutX="126.0" layoutY="15.0" <Button fx:id="checkAllBtn" alignment="CENTER" maxWidth="1.7976931348623157E308"
maxWidth="1.7976931348623157E308" mnemonicParsing="false"> mnemonicParsing="false">
<font> <font>
<Font size="14.0"/> <Font size="14.0"/>
</font> </font>
<graphic> <graphic>
<ImageView fx:id="checkAllImageView" fitHeight="32.0" fitWidth="32.0" pickOnBounds="true" <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"/> preserveRatio="true"/>
</graphic> </graphic>
</Button> </Button>
</children> </children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
</padding>
</HBox>
</children>
</HBox> </HBox>
<HBox fillHeight="false" prefHeight="200.0" prefWidth="600.0" VBox.vgrow="ALWAYS"> <HBox fillHeight="false" prefHeight="200.0" prefWidth="600.0" VBox.vgrow="ALWAYS">
<children> <children>
......
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