@FXML private void initialize() { deleteButton.setDisable(true); reconcileButton.setDisable(true); initializeTreeTableView(); Platform.runLater(this::loadAccountTree); MessageBus.getInstance() .registerListener( this, MessageChannel.SYSTEM, MessageChannel.ACCOUNT, MessageChannel.TRANSACTION); // Register invalidation listeners to force a reload typeFilter.addListener(observable -> reload()); selectedAccountProperty.addListener( (observable, oldValue, newValue) -> { updateButtonStates(); }); modifyButton.disableProperty().bind(selectedAccountProperty.isNull()); AccountBalanceDisplayManager.getAccountBalanceDisplayModeProperty() .addListener( (observable, oldValue, newValue) -> { treeTableView.refresh(); }); }
@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; } }