mirror of
https://github.com/DanilaFe/abacus
synced 2024-11-18 00:19:32 -08:00
Add a filter.
This commit is contained in:
parent
4a4d1bc46a
commit
6408ccbb39
|
@ -5,6 +5,7 @@ import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.collections.transformation.FilteredList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.control.cell.CheckBoxListCell;
|
import javafx.scene.control.cell.CheckBoxListCell;
|
||||||
|
@ -97,6 +98,8 @@ public class AbacusController implements PluginListener {
|
||||||
private TextField computationLimitField;
|
private TextField computationLimitField;
|
||||||
@FXML
|
@FXML
|
||||||
private ListView<String> functionListView;
|
private ListView<String> functionListView;
|
||||||
|
@FXML
|
||||||
|
private TextField functionListSearchField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of history entries, created by the users.
|
* The list of history entries, created by the users.
|
||||||
|
@ -118,6 +121,10 @@ public class AbacusController implements PluginListener {
|
||||||
* The list of functions that are registered in the calculator.
|
* The list of functions that are registered in the calculator.
|
||||||
*/
|
*/
|
||||||
private ObservableList<String> functionList;
|
private ObservableList<String> functionList;
|
||||||
|
/**
|
||||||
|
* The filtered list displayed to the user.
|
||||||
|
*/
|
||||||
|
private FilteredList<String> functionFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The abacus instance used for changing the plugin configuration.
|
* The abacus instance used for changing the plugin configuration.
|
||||||
|
@ -222,7 +229,10 @@ public class AbacusController implements PluginListener {
|
||||||
});
|
});
|
||||||
|
|
||||||
functionList = FXCollections.observableArrayList();
|
functionList = FXCollections.observableArrayList();
|
||||||
functionListView.setItems(functionList);
|
functionFilter = new FilteredList<>(functionList, (s) -> true);
|
||||||
|
functionListView.setItems(functionFilter);
|
||||||
|
functionListSearchField.textProperty().addListener((observable, oldValue, newValue) ->
|
||||||
|
functionFilter.setPredicate((newValue.length() == 0) ? ((s) -> true) : ((s) -> s.contains(newValue))));
|
||||||
historyData = FXCollections.observableArrayList();
|
historyData = FXCollections.observableArrayList();
|
||||||
historyTable.setItems(historyData);
|
historyTable.setItems(historyData);
|
||||||
numberImplementationOptions = FXCollections.observableArrayList();
|
numberImplementationOptions = FXCollections.observableArrayList();
|
||||||
|
@ -338,6 +348,7 @@ public class AbacusController implements PluginListener {
|
||||||
enabledPlugins.add(plugin);
|
enabledPlugins.add(plugin);
|
||||||
}
|
}
|
||||||
functionList.addAll(manager.getAllFunctions());
|
functionList.addAll(manager.getAllFunctions());
|
||||||
|
functionList.sort(String::compareTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -61,10 +61,11 @@
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab fx:id="functionListTab" text="Functions" closable="false">
|
<Tab fx:id="functionListTab" text="Functions" closable="false">
|
||||||
<VBox>
|
<VBox spacing="10">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets left="10" right="10" top="10" bottom="10"/>
|
<Insets left="10" right="10" top="10" bottom="10"/>
|
||||||
</padding>
|
</padding>
|
||||||
|
<TextField fx:id="functionListSearchField" maxWidth="Infinity"/>
|
||||||
<ListView maxWidth="Infinity" fx:id="functionListView"/>
|
<ListView maxWidth="Infinity" fx:id="functionListView"/>
|
||||||
</VBox>
|
</VBox>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user