use of jgnash.engine.message.Message in project jgnash by ccavanaugh.
the class Engine method removeCommodity.
public boolean removeCommodity(final CurrencyNode node) {
boolean status = true;
dataLock.writeLock().lock();
try {
if (isCommodityNodeUsed(node)) {
status = false;
} else {
clearObsoleteExchangeRates();
moveObjectToTrash(node);
}
Message message;
if (status) {
message = new Message(MessageChannel.COMMODITY, ChannelEvent.CURRENCY_REMOVE, this);
} else {
message = new Message(MessageChannel.COMMODITY, ChannelEvent.CURRENCY_REMOVE_FAILED, this);
}
message.setObject(MessageProperty.COMMODITY, node);
messageBus.fireEvent(message);
return status;
} finally {
dataLock.writeLock().unlock();
}
}
use of jgnash.engine.message.Message in project jgnash by ccavanaugh.
the class Engine method postTransactionRemove.
private void postTransactionRemove(final Transaction transaction, final boolean result) {
for (Account a : transaction.getAccounts()) {
Message message;
if (result) {
message = new Message(MessageChannel.TRANSACTION, ChannelEvent.TRANSACTION_REMOVE, this);
} else {
message = new Message(MessageChannel.TRANSACTION, ChannelEvent.TRANSACTION_REMOVE_FAILED, this);
}
message.setObject(MessageProperty.ACCOUNT, a);
message.setObject(MessageProperty.TRANSACTION, transaction);
messageBus.fireEvent(message);
}
}
use of jgnash.engine.message.Message in project jgnash by ccavanaugh.
the class Engine method setAccountNumber.
/**
* Sets the account number of an account.
*
* @param account account to change
* @param number new account number
*/
public void setAccountNumber(final Account account, final String number) {
dataLock.writeLock().lock();
try {
account.setAccountNumber(number);
getAccountDAO().updateAccount(account);
Message message = new Message(MessageChannel.ACCOUNT, ChannelEvent.ACCOUNT_MODIFY, this);
message.setObject(MessageProperty.ACCOUNT, account);
messageBus.fireEvent(message);
logInfo(rb.getString("Message.AccountModify"));
} finally {
dataLock.writeLock().unlock();
}
}
use of jgnash.engine.message.Message in project jgnash by ccavanaugh.
the class Engine method setPreference.
public void setPreference(@NotNull final String key, @Nullable final String value) {
dataLock.writeLock().lock();
try {
getConfig().setPreference(key, value);
getConfigDAO().update(getConfig());
// clear stale cached reference
config = null;
Message message = new Message(MessageChannel.CONFIG, ChannelEvent.CONFIG_MODIFY, this);
message.setObject(MessageProperty.CONFIG, getConfig());
messageBus.fireEvent(message);
} finally {
dataLock.writeLock().unlock();
}
}
use of jgnash.engine.message.Message in project jgnash by ccavanaugh.
the class BudgetManagerDialog method deleteBudget.
private void deleteBudget() {
Engine e = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(e);
List<BudgetObject> values = budgetList.getSelectedValuesList();
if (!values.isEmpty()) {
String message = values.size() == 1 ? rb.getString("Message.ConfirmBudgetDelete") : rb.getString("Message.ConfirmMultipleBudgetDelete");
if (YesNoDialog.showYesNoDialog(UIApplication.getFrame(), new JLabel(message), rb.getString("Title.Confirm"))) {
values.stream().filter(value -> !e.removeBudget(value.getBudget())).forEach(value -> StaticUIMethods.displayError(rb.getString("Message.Error.BudgetRemove")));
}
}
}
Aggregations