use of jgnash.util.LockedCommodityNode in project jgnash by ccavanaugh.
the class AddRemoveCurrencyController method loadModel.
private void loadModel() {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
// Defaults
final Set<CurrencyNode> defaultNodes = DefaultCurrencies.generateCurrencies();
// Active
final Set<CurrencyNode> activeNodes = engine.getActiveCurrencies();
// Available
final List<CurrencyNode> availNodes = engine.getCurrencies();
// remove any overlap between the available and the default
availNodes.forEach(defaultNodes::remove);
availableList.getItems().addAll(defaultNodes);
final ArrayList<LockedCommodityNode<CurrencyNode>> list = new ArrayList<>();
for (final CurrencyNode node : availNodes) {
if (activeNodes.contains(node)) {
list.add(new LockedCommodityNode<>(node, true));
} else {
list.add(new LockedCommodityNode<>(node, false));
}
}
selectedList.getItems().addAll(list);
FXCollections.sort(availableList.getItems());
FXCollections.sort(selectedList.getItems());
}
Aggregations