mirror of
https://github.com/DanilaFe/abacus
synced 2024-09-07 00:03:05 -07:00
Add a number implementation selector box.
This commit is contained in:
parent
33deb34925
commit
1344090a58
|
@ -72,4 +72,12 @@ public class Configuration {
|
||||||
public String getNumberImplementation() {
|
public String getNumberImplementation() {
|
||||||
return numberImplementation;
|
return numberImplementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the number implementation for the configuration
|
||||||
|
* @param numberImplementation the number implementation.
|
||||||
|
*/
|
||||||
|
public void setNumberImplementation(String numberImplementation) {
|
||||||
|
this.numberImplementation = numberImplementation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,13 @@ public class AbacusController {
|
||||||
private TextField inputField;
|
private TextField inputField;
|
||||||
@FXML
|
@FXML
|
||||||
private Button inputButton;
|
private Button inputButton;
|
||||||
|
@FXML
|
||||||
|
private ComboBox<String> numberImplementationBox;
|
||||||
|
|
||||||
private ObservableList<HistoryModel> historyData;
|
private ObservableList<HistoryModel> historyData;
|
||||||
|
|
||||||
|
private ObservableList<String> numberImplementationOptions;
|
||||||
|
|
||||||
private Abacus abacus;
|
private Abacus abacus;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -40,9 +44,15 @@ public class AbacusController {
|
||||||
Callback<TableColumn<HistoryModel, String>, TableCell<HistoryModel, String>> cellFactory =
|
Callback<TableColumn<HistoryModel, String>, TableCell<HistoryModel, String>> cellFactory =
|
||||||
param -> new CopyableCell<>();
|
param -> new CopyableCell<>();
|
||||||
|
|
||||||
abacus = new Abacus();
|
|
||||||
historyData = FXCollections.observableArrayList();
|
historyData = FXCollections.observableArrayList();
|
||||||
historyTable.setItems(historyData);
|
historyTable.setItems(historyData);
|
||||||
|
numberImplementationOptions = FXCollections.observableArrayList();
|
||||||
|
numberImplementationBox.setItems(numberImplementationOptions);
|
||||||
|
numberImplementationBox.valueProperty().addListener((observable, oldValue, newValue)
|
||||||
|
-> {
|
||||||
|
abacus.getConfiguration().setNumberImplementation(newValue);
|
||||||
|
abacus.getConfiguration().saveTo(Abacus.CONFIG_FILE);
|
||||||
|
});
|
||||||
historyTable.getSelectionModel().setCellSelectionEnabled(true);
|
historyTable.getSelectionModel().setCellSelectionEnabled(true);
|
||||||
inputColumn.setCellFactory(cellFactory);
|
inputColumn.setCellFactory(cellFactory);
|
||||||
inputColumn.setCellValueFactory(cell -> cell.getValue().inputProperty());
|
inputColumn.setCellValueFactory(cell -> cell.getValue().inputProperty());
|
||||||
|
@ -50,6 +60,12 @@ public class AbacusController {
|
||||||
parsedColumn.setCellValueFactory(cell -> cell.getValue().parsedProperty());
|
parsedColumn.setCellValueFactory(cell -> cell.getValue().parsedProperty());
|
||||||
outputColumn.setCellFactory(cellFactory);
|
outputColumn.setCellFactory(cellFactory);
|
||||||
outputColumn.setCellValueFactory(cell -> cell.getValue().outputProperty());
|
outputColumn.setCellValueFactory(cell -> cell.getValue().outputProperty());
|
||||||
|
|
||||||
|
abacus = new Abacus();
|
||||||
|
numberImplementationOptions.addAll(abacus.getPluginManager().getAllNumbers());
|
||||||
|
String actualImplementation = abacus.getConfiguration().getNumberImplementation();
|
||||||
|
String toSelect = (numberImplementationOptions.contains(actualImplementation)) ? actualImplementation : "naive";
|
||||||
|
numberImplementationBox.getSelectionModel().select(toSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.text.Text?>
|
<?import javafx.scene.text.Text?>
|
||||||
|
<?import javafx.scene.layout.HBox?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<BorderPane xmlns="http://javafx.com/javafx"
|
<BorderPane xmlns="http://javafx.com/javafx"
|
||||||
xmlns:fx="http://javafx.com/fxml"
|
xmlns:fx="http://javafx.com/fxml"
|
||||||
fx:controller="org.nwapw.abacus.fx.AbacusController">
|
fx:controller="org.nwapw.abacus.fx.AbacusController">
|
||||||
|
@ -39,7 +41,13 @@
|
||||||
</bottom>
|
</bottom>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab text="Settings" closable="false"/>
|
<Tab text="Settings" closable="false">
|
||||||
|
<GridPane hgap="10" vgap="10">
|
||||||
|
<padding><Insets left="10" right="10" top="10" bottom="10"/></padding>
|
||||||
|
<Label text="Number Implementation" GridPane.columnIndex="0" GridPane.rowIndex="0"/>
|
||||||
|
<ComboBox fx:id="numberImplementationBox" GridPane.columnIndex="1" GridPane.rowIndex="0"/>
|
||||||
|
</GridPane>
|
||||||
|
</Tab>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user