use of jgnash.util.NotNull in project jgnash by ccavanaugh.
the class SplitMergeSharesSlipController method buildTransaction.
@NotNull
@Override
public Transaction buildTransaction() {
final Transaction transaction;
if (tranType == TransactionType.SPLITSHARE) {
transaction = TransactionFactory.generateSplitXTransaction(accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), datePicker.getValue(), memoTextField.getText());
} else {
transaction = TransactionFactory.generateMergeXTransaction(accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), datePicker.getValue(), memoTextField.getText());
}
transaction.setNumber(numberComboBox.getValue());
return attachmentPane.buildTransaction(transaction);
}
use of jgnash.util.NotNull in project jgnash by ccavanaugh.
the class ReinvestDividendSlipController method modifyTransaction.
@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
if (!(transaction instanceof InvestmentTransaction) || transaction.getTransactionType() != TransactionType.REINVESTDIV) {
throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
}
clearForm();
datePicker.setValue(transaction.getLocalDate());
numberComboBox.setValue(transaction.getNumber());
feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
gainLossPane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentGainLossEntries());
transaction.getTransactionEntries().stream().filter(e -> e instanceof TransactionEntryReinvestDivX).forEach(e -> {
final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoTextField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityComboBox.setSecurityNode(entry.getSecurityNode());
});
modTrans = transaction;
modTrans = attachmentPane.modifyTransaction(modTrans);
setReconciledState(transaction.getReconciled(accountProperty().get()));
}
use of jgnash.util.NotNull in project jgnash by ccavanaugh.
the class SellShareSlipController method modifyTransaction.
@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
if (!(transaction instanceof InvestmentTransaction) || transaction.getTransactionType() != TransactionType.SELLSHARE) {
throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
}
clearForm();
datePicker.setValue(transaction.getLocalDate());
numberComboBox.setValue(transaction.getNumber());
feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
gainLossPane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentGainLossEntries());
transaction.getTransactionEntries().stream().filter(e -> e instanceof TransactionEntrySellX).forEach(e -> {
final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoTextField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityComboBox.setSecurityNode(entry.getSecurityNode());
if (entry.getCreditAccount().equals(accountProperty().get())) {
accountExchangePane.setSelectedAccount(entry.getDebitAccount());
accountExchangePane.setExchangedAmount(entry.getDebitAmount().abs());
} else {
Logger.getLogger(SellShareSlipController.class.getName()).warning("was not expected");
}
});
modTrans = transaction;
modTrans = attachmentPane.modifyTransaction(modTrans);
setReconciledState(transaction.getReconciled(accountProperty().get()));
}
use of jgnash.util.NotNull in project jgnash by ccavanaugh.
the class DividendSlipController method buildTransaction.
@NotNull
@Override
public Transaction buildTransaction() {
BigDecimal incomeExchangedAmount = decimalTextField.getDecimal().negate();
BigDecimal accountExchangedAmount = decimalTextField.getDecimal();
if (!incomeExchangePane.getSelectedAccount().getCurrencyNode().equals(accountProperty().get().getCurrencyNode())) {
incomeExchangedAmount = incomeExchangePane.exchangeAmountProperty().get().negate();
}
if (!accountExchangePane.getSelectedAccount().getCurrencyNode().equals(accountProperty().get().getCurrencyNode())) {
accountExchangedAmount = accountExchangePane.exchangeAmountProperty().get();
}
final Transaction transaction = TransactionFactory.generateDividendXTransaction(incomeExchangePane.getSelectedAccount(), accountProperty().get(), accountExchangePane.getSelectedAccount(), securityComboBox.getValue(), decimalTextField.getDecimal(), incomeExchangedAmount, accountExchangedAmount, datePicker.getValue(), memoTextField.getText());
transaction.setNumber(numberComboBox.getValue());
return transaction;
}
use of jgnash.util.NotNull in project jgnash by ccavanaugh.
the class TableViewManager method retrieveOldColumnWidths.
@NotNull
private double[] retrieveOldColumnWidths() {
// zero length array instead of null to protect against NPE
double[] columnWidths = new double[0];
// no need to retrieve old column widths more than once
if (preferenceKeyFactory.get() != null) {
final String uuid = preferenceKeyFactory.get().get();
final Preferences preferences = Preferences.userRoot().node(preferencesUserRoot + PREF_NODE_REG_WIDTH);
final String widths = preferences.get(uuid, null);
if (widths != null) {
columnWidths = EncodeDecode.decodeDoubleArray(widths);
}
}
return columnWidths;
}
Aggregations