implemented the question edit

This commit is contained in:
Jonas Hinterdorfer 2025-05-12 14:46:59 +02:00
parent af87631ff1
commit e3f033d1e5

View File

@ -77,8 +77,7 @@ public class ViewController {
@FXML @FXML
private void deleteQuestion(ActionEvent actionEvent) { 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; return;
} }
@ -90,26 +89,24 @@ public class ViewController {
@FXML @FXML
private void editQuestion(ActionEvent actionEvent) throws SQLException { private void editQuestion(ActionEvent actionEvent) throws SQLException {
if(this.isInEditState){ if (this.isInEditState) {
this.currentQuestion.setQuestion(this.questionField.getText()); this.currentQuestion.setQuestion(this.questionField.getText());
this.currentQuestion.setAnswer(this.answerField.getText()); this.currentQuestion.setAnswer(this.answerField.getText());
QuestionService.UpdateQuestion(this.currentQuestion); QuestionService.UpdateQuestion(this.currentQuestion);
this.editButton.setText("Edit"); this.editButton.setText("Edit");
questionListView.refresh(); questionListView.refresh();
this.isInEditState = false; this.isInEditState = false;
this.setEditableAndSetDisabled(false); this.setEditableAndSetDisabled(false);
} } else {
else { this.setEditableAndSetDisabled(true);
this.setEditableAndSetDisabled(true); this.editButton.setText("Save");
this.editButton.setText("Save"); this.isInEditState = true;
this.isInEditState = true; }
}
} }
private void setEditableAndSetDisabled(boolean value) private void setEditableAndSetDisabled(boolean value) {
{
questionField.setEditable(value); questionField.setEditable(value);
answerField.setEditable(value); answerField.setEditable(value);
this.questionListView.setDisable(value); this.questionListView.setDisable(value);