private void loadAccountTree() { final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); if (engine != null) { RootAccount r = engine.getRootAccount(); final TreeItem<Account> root = new TreeItem<>(r); root.setExpanded(true); treeTableView.setRoot(root); loadChildren(root); } else { treeTableView.setRoot(null); } }
@Override public void messagePosted(final Message event) { switch (event.getEvent()) { case ACCOUNT_ADD: case ACCOUNT_MODIFY: case ACCOUNT_REMOVE: reload(); break; case TRANSACTION_ADD: case TRANSACTION_REMOVE: treeTableView .refresh(); // TODO implement a better model that listens to account balance changes break; case FILE_CLOSING: Platform.runLater(() -> treeTableView.setRoot(null)); MessageBus.getInstance() .unregisterListener( this, MessageChannel.SYSTEM, MessageChannel.ACCOUNT, MessageChannel.TRANSACTION); break; default: break; } }