From 61ead6753516dc1fc5e828780dbf2ee83de52470 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 31 Jul 2017 17:49:57 -0700 Subject: [PATCH] Implement the history data model. --- .../org/nwapw/abacus/fx/AbacusController.java | 7 +++- .../org/nwapw/abacus/fx/HistoryModel.java | 42 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/nwapw/abacus/fx/HistoryModel.java diff --git a/src/main/java/org/nwapw/abacus/fx/AbacusController.java b/src/main/java/org/nwapw/abacus/fx/AbacusController.java index d21c034..c765a8e 100644 --- a/src/main/java/org/nwapw/abacus/fx/AbacusController.java +++ b/src/main/java/org/nwapw/abacus/fx/AbacusController.java @@ -1,5 +1,7 @@ package org.nwapw.abacus.fx; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.TextField; @@ -20,11 +22,14 @@ public class AbacusController { @FXML private Button inputButton; + private ObservableList historyData; + private Abacus abacus; @FXML public void initialize(){ abacus = new Abacus(); + historyData = FXCollections.observableArrayList(); } @FXML @@ -37,7 +42,7 @@ public class AbacusController { return; } NumberInterface evaluatedNumber = abacus.evaluateTree(constructedTree); - if(constructedTree == null){ + if(evaluatedNumber == null){ outputText.setText(ERR_EVAL); inputButton.setDisable(false); return; diff --git a/src/main/java/org/nwapw/abacus/fx/HistoryModel.java b/src/main/java/org/nwapw/abacus/fx/HistoryModel.java new file mode 100644 index 0000000..2a267b5 --- /dev/null +++ b/src/main/java/org/nwapw/abacus/fx/HistoryModel.java @@ -0,0 +1,42 @@ +package org.nwapw.abacus.fx; + +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +public class HistoryModel { + + private final StringProperty input; + private final StringProperty parsed; + private final StringProperty output; + + public HistoryModel(String input, String parsed, String output){ + this.input = new SimpleStringProperty(); + this.parsed = new SimpleStringProperty(); + this.output = new SimpleStringProperty(); + this.input.setValue(input); + this.parsed.setValue(parsed); + this.output.setValue(output); + } + + public StringProperty inputProperty() { + return input; + } + public String getInput() { + return input.get(); + } + + public StringProperty parsedProperty() { + return parsed; + } + public String getParsed() { + return parsed.get(); + } + + public StringProperty outputProperty() { + return output; + } + public String getOutput() { + return output.get(); + } + +}