diff --git a/.gitignore b/.gitignore index 7d85cf2..37937b9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,4 @@ classes/ src/main/java/META-INF/ dependency-reduced-pom.xml history.sqlite -themes/ /config/restaurant.state diff --git a/src/main/java/com/rohitawate/restaurant/homewindow/DashboardController.java b/src/main/java/com/rohitawate/restaurant/homewindow/DashboardController.java index 43964e1..0752e82 100644 --- a/src/main/java/com/rohitawate/restaurant/homewindow/DashboardController.java +++ b/src/main/java/com/rohitawate/restaurant/homewindow/DashboardController.java @@ -380,6 +380,10 @@ public class DashboardController implements Initializable { controller.setKeyField(key); controller.setValueField(value); paramsControllers.add(controller); + controller.deleteButton.setOnAction(e -> { + paramsBox.getChildren().remove(headerField); + paramsControllers.remove(controller); + }); paramsBox.getChildren().add(headerField); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/rohitawate/restaurant/homewindow/FileKeyValueFieldController.java b/src/main/java/com/rohitawate/restaurant/homewindow/FileKeyValueFieldController.java index be56a36..b202627 100644 --- a/src/main/java/com/rohitawate/restaurant/homewindow/FileKeyValueFieldController.java +++ b/src/main/java/com/rohitawate/restaurant/homewindow/FileKeyValueFieldController.java @@ -16,6 +16,7 @@ package com.rohitawate.restaurant.homewindow; +import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXCheckBox; import javafx.beans.binding.Bindings; import javafx.fxml.FXML; @@ -33,6 +34,8 @@ public class FileKeyValueFieldController implements Initializable { private TextField fileKeyField, fileValueField; @FXML private JFXCheckBox checkBox; + @FXML + protected JFXButton deleteButton; /* Set to true when user manually un-checks the field diff --git a/src/main/java/com/rohitawate/restaurant/homewindow/FormDataTabController.java b/src/main/java/com/rohitawate/restaurant/homewindow/FormDataTabController.java index 5e72a8c..f2b87cd 100644 --- a/src/main/java/com/rohitawate/restaurant/homewindow/FormDataTabController.java +++ b/src/main/java/com/rohitawate/restaurant/homewindow/FormDataTabController.java @@ -32,7 +32,7 @@ import java.util.ResourceBundle; public class FormDataTabController implements Initializable { @FXML - private VBox headersBox; + private VBox fieldsBox; private List stringControllers; private List fileControllers; @@ -69,13 +69,17 @@ public class FormDataTabController implements Initializable { try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/homewindow/FileKeyValueField.fxml")); - Parent headerField = loader.load(); - ThemeManager.setTheme(headerField); + Parent fileField = loader.load(); + ThemeManager.setTheme(fileField); FileKeyValueFieldController controller = loader.getController(); controller.setFileKeyField(key); controller.setFileValueField(value); + controller.deleteButton.setOnAction(e -> { + fieldsBox.getChildren().remove(fileField); + fileControllers.remove(controller); + }); fileControllers.add(controller); - headersBox.getChildren().add(headerField); + fieldsBox.getChildren().add(fileField); } catch (IOException e) { e.printStackTrace(); } @@ -104,12 +108,16 @@ public class FormDataTabController implements Initializable { try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/homewindow/StringKeyValueField.fxml")); - Parent headerField = loader.load(); + Parent stringField = loader.load(); StringKeyValueFieldController controller = loader.getController(); controller.setKeyField(key); controller.setValueField(value); stringControllers.add(controller); - headersBox.getChildren().add(headerField); + controller.deleteButton.setOnAction(e -> { + fieldsBox.getChildren().remove(stringField); + stringControllers.remove(controller); + }); + fieldsBox.getChildren().add(stringField); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/rohitawate/restaurant/homewindow/HeaderTabController.java b/src/main/java/com/rohitawate/restaurant/homewindow/HeaderTabController.java index 3d3ae55..c9d7b8c 100644 --- a/src/main/java/com/rohitawate/restaurant/homewindow/HeaderTabController.java +++ b/src/main/java/com/rohitawate/restaurant/homewindow/HeaderTabController.java @@ -67,6 +67,10 @@ public class HeaderTabController implements Initializable { controller.setKeyField(key); controller.setValueField(value); controllers.add(controller); + controller.deleteButton.setOnAction(e -> { + headersBox.getChildren().remove(headerField); + controllers.remove(controller); + }); headersBox.getChildren().add(headerField); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/com/rohitawate/restaurant/homewindow/StringKeyValueFieldController.java b/src/main/java/com/rohitawate/restaurant/homewindow/StringKeyValueFieldController.java index 837f71e..98ea34c 100644 --- a/src/main/java/com/rohitawate/restaurant/homewindow/StringKeyValueFieldController.java +++ b/src/main/java/com/rohitawate/restaurant/homewindow/StringKeyValueFieldController.java @@ -16,6 +16,7 @@ package com.rohitawate.restaurant.homewindow; +import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXCheckBox; import javafx.beans.binding.Bindings; import javafx.fxml.FXML; @@ -31,6 +32,8 @@ public class StringKeyValueFieldController implements Initializable { private TextField keyField, valueField; @FXML private JFXCheckBox checkBox; + @FXML + protected JFXButton deleteButton; /* Set to true when user manually un-checks the field diff --git a/src/main/java/com/rohitawate/restaurant/homewindow/URLTabController.java b/src/main/java/com/rohitawate/restaurant/homewindow/URLTabController.java index 6c908d6..b014576 100644 --- a/src/main/java/com/rohitawate/restaurant/homewindow/URLTabController.java +++ b/src/main/java/com/rohitawate/restaurant/homewindow/URLTabController.java @@ -65,13 +65,17 @@ public class URLTabController implements Initializable { try { FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/homewindow/StringKeyValueField.fxml")); - Parent parent = loader.load(); - ThemeManager.setTheme(parent); + Parent stringField = loader.load(); + ThemeManager.setTheme(stringField); StringKeyValueFieldController controller = loader.getController(); controller.setKeyField(key); controller.setValueField(value); + controller.deleteButton.setOnAction(e -> { + fieldsBox.getChildren().remove(stringField); + controllers.remove(controller); + }); controllers.add(controller); - fieldsBox.getChildren().add(parent); + fieldsBox.getChildren().add(stringField); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/resources/fxml/homewindow/FileKeyValueField.fxml b/src/main/resources/fxml/homewindow/FileKeyValueField.fxml index 6a7289c..43afcdb 100644 --- a/src/main/resources/fxml/homewindow/FileKeyValueField.fxml +++ b/src/main/resources/fxml/homewindow/FileKeyValueField.fxml @@ -20,9 +20,11 @@ + + @@ -30,6 +32,15 @@ + + + + + + + + + diff --git a/src/main/resources/fxml/homewindow/FormDataTab.fxml b/src/main/resources/fxml/homewindow/FormDataTab.fxml index 4e68339..725d1ae 100644 --- a/src/main/resources/fxml/homewindow/FormDataTab.fxml +++ b/src/main/resources/fxml/homewindow/FormDataTab.fxml @@ -23,7 +23,7 @@ @@ -67,7 +67,7 @@ - + diff --git a/src/main/resources/fxml/homewindow/StringKeyValueField.fxml b/src/main/resources/fxml/homewindow/StringKeyValueField.fxml index 6b5c9a2..e8e12d7 100644 --- a/src/main/resources/fxml/homewindow/StringKeyValueField.fxml +++ b/src/main/resources/fxml/homewindow/StringKeyValueField.fxml @@ -16,18 +16,30 @@ ~ limitations under the License. --> + - + + + + + + + + + + + +