@FXML @Override public void handleEnterAction() { if (validateForm()) { if (modTrans == null) { // new transaction Transaction newTrans = buildTransaction(); ReconcileManager.reconcileTransaction( accountProperty.get(), newTrans, getReconciledState()); newTrans = attachmentPane.buildTransaction(newTrans); // chain the transaction build final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); if (engine != null) { engine.addTransaction(newTrans); } } else { Transaction newTrans = buildTransaction(); newTrans.setDateEntered(modTrans.getDateEntered()); // restore the reconciled state of the previous old transaction for (final Account a : modTrans.getAccounts()) { if (!a.equals(accountProperty.get())) { ReconcileManager.reconcileTransaction(a, newTrans, modTrans.getReconciled(a)); } } /* * Reconcile the modified transaction for this account. * This must be performed last to ensure consistent results per the ReconcileManager rules */ ReconcileManager.reconcileTransaction( accountProperty.get(), newTrans, getReconciledState()); newTrans = attachmentPane.buildTransaction(newTrans); // chain the transaction build final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT); if (engine != null && engine.removeTransaction(modTrans)) { engine.addTransaction(newTrans); } } clearForm(); if (payeeTextField != null) { payeeTextField.requestFocus(); } else { memoTextField.requestFocus(); } } }
@Override public void messagePosted(final Message event) { final Account a = (Account) event.getObject(MessageProperty.ACCOUNT); if (account.equals(a)) { final SecurityNode node = (SecurityNode) event.getObject(MessageProperty.COMMODITY); EventQueue.invokeLater( new Runnable() { @Override public void run() { switch (event.getEvent()) { case ACCOUNT_REMOVE: MessageBus.getInstance() .unregisterListener( AccountSecurityComboBox.this, MessageChannel.ACCOUNT, MessageChannel.COMMODITY); model.removeAllElements(); account = null; break; case ACCOUNT_SECURITY_ADD: model.addElement(node); break; case SECURITY_REMOVE: case ACCOUNT_SECURITY_REMOVE: CommodityNode snode = getSelectedNode(); model.removeElement(node); if (snode != null && node != null) { if (snode.equals(node)) { setSelectedItem(null); } } break; case SECURITY_MODIFY: updateNode(node); break; default: } } }); } }