From 5d5f4004957d834df9fca0c91d24da0031be1122 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Fri, 13 Sep 2019 01:05:29 +0200 Subject: [PATCH] Removed editing facilities --- .../jstudy/controller/EditController.java | 70 ------------------- .../resources/es/kauron/jstudy/view/edit.fxml | 33 --------- 2 files changed, 103 deletions(-) delete mode 100644 src/main/java/es/kauron/jstudy/controller/EditController.java delete mode 100644 src/main/resources/es/kauron/jstudy/view/edit.fxml diff --git a/src/main/java/es/kauron/jstudy/controller/EditController.java b/src/main/java/es/kauron/jstudy/controller/EditController.java deleted file mode 100644 index 30be275..0000000 --- a/src/main/java/es/kauron/jstudy/controller/EditController.java +++ /dev/null @@ -1,70 +0,0 @@ -package es.kauron.jstudy.controller; - -import es.kauron.jstudy.model.TestItem; -import javafx.beans.property.BooleanProperty; -import javafx.collections.ObservableList; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.Initializable; -import javafx.scene.Node; -import javafx.scene.control.TextField; -import javafx.stage.Stage; - -import java.net.URL; -import java.util.ResourceBundle; - -public class EditController implements Initializable { - @FXML - private TextField questionText, answerText; - private ObservableList list; - private int index; - private TestItem item; - private BooleanProperty saved; - private String originalQuestion, originalAnswer; - - @Override - public void initialize(URL url, ResourceBundle rb) { - } - - void setList(ObservableList list, BooleanProperty saved) { - setList(list, -1, saved); - } - - void setList(ObservableList list, int index, BooleanProperty saved) { - this.list = list; // Save attributes correctly - this.index = index; - this.saved = saved; - // Copy current values to textViews - // and initialize item to hold the current object in edition - if (index < 0) item = new TestItem("",""); - else { - questionText.setText(list.get(index).getQuestion()); - answerText.setText(list.get(index).getAnswer()); - item = new TestItem(list.get(index)); - } - originalQuestion = questionText.getText(); - originalAnswer = answerText.getText(); - item.questionProperty().bind(questionText.textProperty()); - item.answerProperty().bind(answerText.textProperty()); - } - - @FXML - protected void onSaveAction(ActionEvent event) { - if (index < 0) { - if (!item.isValid()) - return; - list.add(item); - } else { - list.set(index, item); - } - if (!originalQuestion.equals(item.getQuestion()) || !originalAnswer.equals(item.getAnswer())) saved.set(false); - onCancelAction(event); - } - - @FXML - protected void onCancelAction(ActionEvent event) { - ((Stage) ((Node) event.getSource()) - .getScene().getWindow()) - .close(); - } -} diff --git a/src/main/resources/es/kauron/jstudy/view/edit.fxml b/src/main/resources/es/kauron/jstudy/view/edit.fxml deleted file mode 100644 index d5919f4..0000000 --- a/src/main/resources/es/kauron/jstudy/view/edit.fxml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - -