Search in sources :

Example 1 with LockedCommodityNode

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());
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) ArrayList(java.util.ArrayList) LockedCommodityNode(jgnash.util.LockedCommodityNode) Engine(jgnash.engine.Engine)

Aggregations

ArrayList (java.util.ArrayList)1 CurrencyNode (jgnash.engine.CurrencyNode)1 Engine (jgnash.engine.Engine)1 LockedCommodityNode (jgnash.util.LockedCommodityNode)1