From 8ac02b756be3631498dbaafbcfdd3b3680c2d2af Mon Sep 17 00:00:00 2001 From: pbd2h21avi Date: Wed, 1 Feb 2023 08:51:35 +0100 Subject: [PATCH 1/4] anpassungen Registration-view.fxml --- .../example/vpr_javafx/Registration-view.fxml | 86 +++++++++++++++---- 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/src/main/resources/com/example/vpr_javafx/Registration-view.fxml b/src/main/resources/com/example/vpr_javafx/Registration-view.fxml index 537e19a..ed87212 100644 --- a/src/main/resources/com/example/vpr_javafx/Registration-view.fxml +++ b/src/main/resources/com/example/vpr_javafx/Registration-view.fxml @@ -1,12 +1,12 @@ - + - + - + @@ -23,22 +23,70 @@ - From 30511d32b4f8c6fcc2b0c51b7a8f849132f36fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20D=C3=BCsterhaus?= Date: Wed, 1 Feb 2023 08:52:15 +0100 Subject: [PATCH 2/4] =?UTF-8?q?changeorder-view=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/example/vpr_javafx/Data.java | 31 +++++++------ .../example/vpr_javafx/HelloApplication.java | 4 +- .../example/vpr_javafx/HelloController.java | 41 +++++++++++++++++- .../example/vpr_javafx/ChangeOrder-view.fxml | 12 +++++ .../classes/com/example/vpr_javafx/Data.class | Bin 12791 -> 13641 bytes .../example/vpr_javafx/HelloApplication.class | Bin 1532 -> 1528 bytes .../example/vpr_javafx/HelloController.class | Bin 11951 -> 13432 bytes .../example/vpr_javafx/MenuOverview-view.fxml | 3 +- 8 files changed, 70 insertions(+), 21 deletions(-) create mode 100644 target/classes/com/example/vpr_javafx/ChangeOrder-view.fxml diff --git a/src/main/java/com/example/vpr_javafx/Data.java b/src/main/java/com/example/vpr_javafx/Data.java index d7be404..b294616 100644 --- a/src/main/java/com/example/vpr_javafx/Data.java +++ b/src/main/java/com/example/vpr_javafx/Data.java @@ -1,6 +1,9 @@ package com.example.vpr_javafx; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.scene.control.Alert; +import javafx.scene.control.ListView; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; import org.w3c.dom.Text; @@ -426,8 +429,9 @@ public class Data { * @author Felix Düsterhaus */ - public ArrayList changeOrder(String userLogin) { - + public ArrayList changeOrder(String userLogin, ListView ListViewDelete) { + ArrayList chosenMeals = new ArrayList<>(); + ObservableList chosenMealsObservable = FXCollections.observableList(chosenMeals); ArrayList changedOrderList = new ArrayList<>(); List rows = getRows(); int changedEntries = 0; @@ -436,7 +440,7 @@ public class Data { UIManager.put("OptionPane.noButtonText", "Nein"); UIManager.put("OptionPane.yesButtonText", "Ja"); int result = JOptionPane.showInternalConfirmDialog(null, "Bestellungen wirklich Löschen?", "Bestätigung", JOptionPane.YES_NO_OPTION); - + ListViewDelete.getSelectionModel().getSelectedItems(); if (result == JOptionPane.YES_OPTION) { for (String row : rows) { String[] parts = row.split(";"); @@ -451,20 +455,15 @@ public class Data { changedEntries++; } } - try { - FileWriter writer = new FileWriter("orders2.txt"); - for(com.example.vpr_javafx.Order str: changedOrderList) { - writer.write(str + System.lineSeparator()); + try { + FileWriter writer = new FileWriter("orders2.txt"); + for(com.example.vpr_javafx.Order str: changedOrderList) { + writer.write(str + System.lineSeparator()); + } + writer.close(); + } catch (IOException e) { + e.printStackTrace(); } - writer.close(); - - - - - - } catch (IOException e) { - e.printStackTrace(); - } JOptionPane.showMessageDialog(null, changedEntries + " Bestellungen Gelöscht, Sie können eine neue Bestellung aufgeben"); } else { JOptionPane.showMessageDialog(null, "Bestellung nicht gelöscht."); diff --git a/src/main/java/com/example/vpr_javafx/HelloApplication.java b/src/main/java/com/example/vpr_javafx/HelloApplication.java index a13f2b2..137b8bb 100644 --- a/src/main/java/com/example/vpr_javafx/HelloApplication.java +++ b/src/main/java/com/example/vpr_javafx/HelloApplication.java @@ -20,7 +20,5 @@ public class HelloApplication extends Application { controller.writeAllergene(); } - public static void main(String[] args) { - launch(); - } + public static void main(String[] args) {launch();} } \ No newline at end of file diff --git a/src/main/java/com/example/vpr_javafx/HelloController.java b/src/main/java/com/example/vpr_javafx/HelloController.java index bf5ad6a..fb9d979 100644 --- a/src/main/java/com/example/vpr_javafx/HelloController.java +++ b/src/main/java/com/example/vpr_javafx/HelloController.java @@ -1,5 +1,7 @@ package com.example.vpr_javafx; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -113,6 +115,12 @@ public class HelloController { @FXML private Button btToOrder; @FXML + private Button btToChangeOrder; + @FXML + private Button btDeleteSelection; + @FXML + private Button btToMenu; + @FXML private RadioButton rbMonH1; @FXML private RadioButton rbMonH2; @@ -145,7 +153,10 @@ public class HelloController { @FXML private String imageUrl; + @FXML private ArrayList chosenMeals; + @FXML + private ListView listViewDelete; @FXML protected void OnSignInButton(ActionEvent event) throws IOException @@ -365,7 +376,7 @@ public class HelloController { rbThurH2.setVisible(true); rbFriH1.setVisible(true); rbFriH2.setVisible(true); - + btToChangeOrder.setVisible(true); } @FXML @@ -384,6 +395,34 @@ public class HelloController { chosenMeals.clear(); } + @FXML + protected void ToChangeOrder(ActionEvent event) throws IOException + { + Parent root = FXMLLoader.load(getClass().getResource("ChangeOrder-view.fxml")); + Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); + Scene scene = new Scene(root); + stage.setScene(scene); + stage.show(); + } + + @FXML + protected void deleteSelection() { + final int selectedId = listViewDelete.getSelectionModel().getSelectedIndex(); + //String itemToRemove = listViewDelete.getSelectionModel().getSelectedItem(); + listViewDelete.getItems().remove(selectedId); + Data data = new Data("order.txt"); + data.changeOrder("12345", listViewDelete); + } + + @FXML + protected void ToMenu(ActionEvent event) throws IOException + { + Parent root = FXMLLoader.load(getClass().getResource("MenuOverview-view.fxml")); + Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); + Scene scene = new Scene(root); + stage.setScene(scene); + stage.show(); + } @FXML protected ArrayList getLabelValueWithRadio(ActionEvent event) diff --git a/target/classes/com/example/vpr_javafx/ChangeOrder-view.fxml b/target/classes/com/example/vpr_javafx/ChangeOrder-view.fxml new file mode 100644 index 0000000..0249d91 --- /dev/null +++ b/target/classes/com/example/vpr_javafx/ChangeOrder-view.fxml @@ -0,0 +1,12 @@ + + + + + + + +