changeorder-view hinzugefügt
This commit is contained in:
@@ -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<com.example.vpr_javafx.Order> changeOrder(String userLogin) {
|
||||
|
||||
public ArrayList<com.example.vpr_javafx.Order> changeOrder(String userLogin, ListView<String> ListViewDelete) {
|
||||
ArrayList<String> chosenMeals = new ArrayList<>();
|
||||
ObservableList<String> chosenMealsObservable = FXCollections.observableList(chosenMeals);
|
||||
ArrayList<com.example.vpr_javafx.Order> changedOrderList = new ArrayList<>();
|
||||
List<String> 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.");
|
||||
|
@@ -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();}
|
||||
}
|
@@ -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<String> chosenMeals;
|
||||
@FXML
|
||||
private ListView<String> 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<String> getLabelValueWithRadio(ActionEvent event)
|
||||
|
Reference in New Issue
Block a user