mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-24 08:12:39 -08:00
Populate the history table.
This commit is contained in:
parent
61ead67535
commit
02b87bfae4
|
@ -4,6 +4,8 @@ import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import org.nwapw.abacus.Abacus;
|
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_SYNTAX = "Syntax Error";
|
||||||
private static final String ERR_EVAL = "Evaluation Error";
|
private static final String ERR_EVAL = "Evaluation Error";
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TableView<HistoryModel> historyTable;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<HistoryModel, String> inputColumn;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<HistoryModel, String> parsedColumn;
|
||||||
|
@FXML
|
||||||
|
private TableColumn<HistoryModel, String> outputColumn;
|
||||||
@FXML
|
@FXML
|
||||||
private Text outputText;
|
private Text outputText;
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -30,6 +40,10 @@ public class AbacusController {
|
||||||
public void initialize(){
|
public void initialize(){
|
||||||
abacus = new Abacus();
|
abacus = new Abacus();
|
||||||
historyData = FXCollections.observableArrayList();
|
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
|
@FXML
|
||||||
|
@ -47,8 +61,11 @@ public class AbacusController {
|
||||||
inputButton.setDisable(false);
|
inputButton.setDisable(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inputButton.setDisable(false);
|
|
||||||
outputText.setText(evaluatedNumber.toString());
|
outputText.setText(evaluatedNumber.toString());
|
||||||
|
historyData.add(new HistoryModel(inputField.getText(), constructedTree.toString(), evaluatedNumber.toString()));
|
||||||
|
|
||||||
|
inputButton.setDisable(false);
|
||||||
|
inputField.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,15 @@
|
||||||
<TabPane>
|
<TabPane>
|
||||||
<Tab text="Calculator" closable="false">
|
<Tab text="Calculator" closable="false">
|
||||||
<BorderPane>
|
<BorderPane>
|
||||||
|
<center>
|
||||||
|
<TableView fx:id="historyTable">
|
||||||
|
<columns>
|
||||||
|
<TableColumn fx:id="inputColumn" text="Input" sortable="false"/>
|
||||||
|
<TableColumn fx:id="parsedColumn" text="Parsed" sortable="false"/>
|
||||||
|
<TableColumn fx:id="outputColumn" text="Output" sortable="false"/>
|
||||||
|
</columns>
|
||||||
|
</TableView>
|
||||||
|
</center>
|
||||||
<bottom>
|
<bottom>
|
||||||
<VBox>
|
<VBox>
|
||||||
<ScrollPane prefHeight="50" vbarPolicy="NEVER">
|
<ScrollPane prefHeight="50" vbarPolicy="NEVER">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user