From e3f033d1e5159a25aea5fd90a37e3950c3e9c59a Mon Sep 17 00:00:00 2001 From: Jonas Hinterdorfer Date: Mon, 12 May 2025 14:46:59 +0200 Subject: [PATCH] implemented the question edit --- .../controller/ViewController.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/main/java/at/ionas999/questioncatalog/controller/ViewController.java b/src/main/java/at/ionas999/questioncatalog/controller/ViewController.java index c2abcea..b0254e0 100644 --- a/src/main/java/at/ionas999/questioncatalog/controller/ViewController.java +++ b/src/main/java/at/ionas999/questioncatalog/controller/ViewController.java @@ -77,8 +77,7 @@ public class ViewController { @FXML private void deleteQuestion(ActionEvent actionEvent) { - if(!showConfirmationButton("Do you want to proceed with deletion of the question: \n" + currentQuestion.getQuestion())) - { + if (!showConfirmationButton("Do you want to proceed with deletion of the question: \n" + currentQuestion.getQuestion())) { return; } @@ -90,26 +89,24 @@ public class ViewController { @FXML private void editQuestion(ActionEvent actionEvent) throws SQLException { - if(this.isInEditState){ - this.currentQuestion.setQuestion(this.questionField.getText()); - this.currentQuestion.setAnswer(this.answerField.getText()); - QuestionService.UpdateQuestion(this.currentQuestion); + if (this.isInEditState) { + this.currentQuestion.setQuestion(this.questionField.getText()); + this.currentQuestion.setAnswer(this.answerField.getText()); + QuestionService.UpdateQuestion(this.currentQuestion); - this.editButton.setText("Edit"); - questionListView.refresh(); + this.editButton.setText("Edit"); + questionListView.refresh(); - this.isInEditState = false; - this.setEditableAndSetDisabled(false); - } - else { - this.setEditableAndSetDisabled(true); - this.editButton.setText("Save"); - this.isInEditState = true; - } + this.isInEditState = false; + this.setEditableAndSetDisabled(false); + } else { + this.setEditableAndSetDisabled(true); + this.editButton.setText("Save"); + this.isInEditState = true; + } } - private void setEditableAndSetDisabled(boolean value) - { + private void setEditableAndSetDisabled(boolean value) { questionField.setEditable(value); answerField.setEditable(value); this.questionListView.setDisable(value);