From 02b87bfae4ecd26e944e56080ac046250bf42f76 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Mon, 31 Jul 2017 22:29:44 -0700 Subject: [PATCH] Populate the history table. --- .../org/nwapw/abacus/fx/AbacusController.java | 19 ++++++++++++++++++- src/main/resources/abacus.fxml | 9 +++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/nwapw/abacus/fx/AbacusController.java b/src/main/java/org/nwapw/abacus/fx/AbacusController.java index c765a8e..e1d141e 100644 --- a/src/main/java/org/nwapw/abacus/fx/AbacusController.java +++ b/src/main/java/org/nwapw/abacus/fx/AbacusController.java @@ -4,6 +4,8 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.text.Text; import org.nwapw.abacus.Abacus; @@ -15,6 +17,14 @@ public class AbacusController { private static final String ERR_SYNTAX = "Syntax Error"; private static final String ERR_EVAL = "Evaluation Error"; + @FXML + private TableView historyTable; + @FXML + private TableColumn inputColumn; + @FXML + private TableColumn parsedColumn; + @FXML + private TableColumn outputColumn; @FXML private Text outputText; @FXML @@ -30,6 +40,10 @@ public class AbacusController { public void initialize(){ abacus = new Abacus(); historyData = FXCollections.observableArrayList(); + historyTable.setItems(historyData); + inputColumn.setCellValueFactory(cell -> cell.getValue().inputProperty()); + parsedColumn.setCellValueFactory(cell -> cell.getValue().parsedProperty()); + outputColumn.setCellValueFactory(cell -> cell.getValue().outputProperty()); } @FXML @@ -47,8 +61,11 @@ public class AbacusController { inputButton.setDisable(false); return; } - inputButton.setDisable(false); outputText.setText(evaluatedNumber.toString()); + historyData.add(new HistoryModel(inputField.getText(), constructedTree.toString(), evaluatedNumber.toString())); + + inputButton.setDisable(false); + inputField.setText(""); } } diff --git a/src/main/resources/abacus.fxml b/src/main/resources/abacus.fxml index 7b001f2..c25978a 100644 --- a/src/main/resources/abacus.fxml +++ b/src/main/resources/abacus.fxml @@ -12,6 +12,15 @@ +
+ + + + + + + +