mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-22 15:30:09 -08:00
Switch HistoryModel to Kotlin to avoid boilerplate.
This commit is contained in:
parent
ff7d90967e
commit
fe92929856
|
@ -243,11 +243,11 @@ public class AbacusController implements PluginListener {
|
|||
enabledPluginView.setItems(enabledPlugins);
|
||||
enabledPluginView.setCellFactory(pluginCellFactory);
|
||||
inputColumn.setCellFactory(cellFactory);
|
||||
inputColumn.setCellValueFactory(cell -> cell.getValue().inputProperty());
|
||||
inputColumn.setCellValueFactory(cell -> cell.getValue().getInputProperty());
|
||||
parsedColumn.setCellFactory(cellFactory);
|
||||
parsedColumn.setCellValueFactory(cell -> cell.getValue().parsedProperty());
|
||||
parsedColumn.setCellValueFactory(cell -> cell.getValue().getParsedProperty());
|
||||
outputColumn.setCellFactory(cellFactory);
|
||||
outputColumn.setCellValueFactory(cell -> cell.getValue().outputProperty());
|
||||
outputColumn.setCellValueFactory(cell -> cell.getValue().getOutputProperty());
|
||||
coreTabPane.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (oldValue.equals(settingsTab)) alertIfApplyNeeded(true);
|
||||
});
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
package org.nwapw.abacus.fx;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
/**
|
||||
* The data model used for storing history entries.
|
||||
*/
|
||||
public class HistoryModel {
|
||||
|
||||
/**
|
||||
* The property used for displaying the column
|
||||
* for the user input.
|
||||
*/
|
||||
private final StringProperty input;
|
||||
/**
|
||||
* The property used for displaying the column
|
||||
* that contains the parsed input.
|
||||
*/
|
||||
private final StringProperty parsed;
|
||||
/**
|
||||
* The property used for displaying the column
|
||||
* that contains the program output.
|
||||
*/
|
||||
private final StringProperty output;
|
||||
|
||||
/**
|
||||
* Creates a new history model with the given variables.
|
||||
*
|
||||
* @param input the user input
|
||||
* @param parsed the parsed input
|
||||
* @param output the program 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input property.
|
||||
*
|
||||
* @return the input property.
|
||||
*/
|
||||
public StringProperty inputProperty() {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input.
|
||||
*
|
||||
* @return the input.
|
||||
*/
|
||||
public String getInput() {
|
||||
return input.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parsed input property.
|
||||
*
|
||||
* @return the parsed input property.
|
||||
*/
|
||||
public StringProperty parsedProperty() {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parsed input.
|
||||
*
|
||||
* @return the parsed input.
|
||||
*/
|
||||
public String getParsed() {
|
||||
return parsed.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the output property.
|
||||
*
|
||||
* @return the output property.
|
||||
*/
|
||||
public StringProperty outputProperty() {
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the program output.
|
||||
*
|
||||
* @return the output.
|
||||
*/
|
||||
public String getOutput() {
|
||||
return output.get();
|
||||
}
|
||||
|
||||
}
|
32
src/main/kotlin/org/nwapw/abacus/fx/HistoryModel.kt
Normal file
32
src/main/kotlin/org/nwapw/abacus/fx/HistoryModel.kt
Normal file
|
@ -0,0 +1,32 @@
|
|||
package org.nwapw.abacus.fx
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
|
||||
/**
|
||||
* A model representing an input / output in the calculator.
|
||||
*
|
||||
* The HistoryModel class stores a record of a single user-provided input,
|
||||
* its parsed form as it was interpreted by the calculator, and the output
|
||||
* that was provided by the calculator. These are represented as properties
|
||||
* to allow easy access by JavaFX cells.
|
||||
*
|
||||
* @param input the user input
|
||||
* @param parsed the parsed version of the input.
|
||||
* @param output the output string.
|
||||
*/
|
||||
class HistoryModel(input: String, parsed: String, output: String){
|
||||
|
||||
/**
|
||||
* The property that holds the input.
|
||||
*/
|
||||
val inputProperty = SimpleStringProperty(input)
|
||||
/**
|
||||
* The property that holds the parsed input.
|
||||
*/
|
||||
val parsedProperty = SimpleStringProperty(parsed)
|
||||
/**
|
||||
* The property that holds the output.
|
||||
*/
|
||||
val outputProperty = SimpleStringProperty(output)
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user