use of name.abuchen.portfolio.ui.views.actions.ConvertDeliveryToBuySellAction in project portfolio by buchen.
the class PortfolioTransactionsViewer method fillTransactionsContextMenu.
private void fillTransactionsContextMenu(IMenuManager manager) {
if (portfolio == null)
return;
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
PortfolioTransaction firstTransaction = (PortfolioTransaction) selection.getFirstElement();
if (firstTransaction != null && selection.size() == 1) {
Action editAction = createEditAction(firstTransaction);
editAction.setAccelerator(SWT.MOD1 | 'E');
manager.add(editAction);
manager.add(new Separator());
if (fullContextMenu && (firstTransaction.getType() == PortfolioTransaction.Type.BUY || firstTransaction.getType() == PortfolioTransaction.Type.SELL)) {
manager.add(new ConvertBuySellToDeliveryAction(owner.getClient(), new TransactionPair<>(portfolio, firstTransaction)));
manager.add(new Separator());
}
if (fullContextMenu && (firstTransaction.getType() == PortfolioTransaction.Type.DELIVERY_INBOUND || firstTransaction.getType() == PortfolioTransaction.Type.DELIVERY_OUTBOUND)) {
manager.add(new ConvertDeliveryToBuySellAction(owner.getClient(), new TransactionPair<>(portfolio, firstTransaction)));
manager.add(new Separator());
}
if (fullContextMenu)
new SecurityContextMenu(owner).menuAboutToShow(manager, firstTransaction.getSecurity(), portfolio);
else
manager.add(new BookmarkMenu(owner.getPart(), firstTransaction.getSecurity()));
} else if (firstTransaction == null) {
new SecurityContextMenu(owner).menuAboutToShow(manager, null, portfolio);
}
if (firstTransaction != null) {
manager.add(new Separator());
manager.add(new Action(Messages.MenuTransactionDelete) {
@Override
public void run() {
Object[] transactions = selection.toArray();
for (Object transaction : transactions) portfolio.deleteTransaction((PortfolioTransaction) transaction, owner.getClient());
owner.markDirty();
owner.notifyModelUpdated();
}
});
}
}
use of name.abuchen.portfolio.ui.views.actions.ConvertDeliveryToBuySellAction in project portfolio by buchen.
the class SecurityListView method transactionMenuAboutToShow.
private // NOSONAR
void transactionMenuAboutToShow(// NOSONAR
IMenuManager manager) {
Security security = (Security) prices.getData(Security.class.toString());
if (security == null)
return;
TransactionPair<?> pair = (TransactionPair<?>) ((IStructuredSelection) transactions.getSelection()).getFirstElement();
if (pair != null) {
Action action = createEditAction(pair);
action.setAccelerator(SWT.MOD1 | 'E');
manager.add(action);
manager.add(new Separator());
if (pair.getTransaction() instanceof PortfolioTransaction) {
Portfolio p = (Portfolio) pair.getOwner();
PortfolioTransaction t = (PortfolioTransaction) pair.getTransaction();
if (t.getType() == PortfolioTransaction.Type.BUY || t.getType() == PortfolioTransaction.Type.SELL) {
manager.add(new ConvertBuySellToDeliveryAction(getClient(), new TransactionPair<>(p, t)));
manager.add(new Separator());
}
if (t.getType() == PortfolioTransaction.Type.DELIVERY_INBOUND || t.getType() == PortfolioTransaction.Type.DELIVERY_OUTBOUND) {
manager.add(new ConvertDeliveryToBuySellAction(getClient(), new TransactionPair<>(p, t)));
manager.add(new Separator());
}
}
}
new SecurityContextMenu(SecurityListView.this).menuAboutToShow(manager, security);
manager.add(new Separator());
manager.add(new Action(Messages.MenuTransactionDelete) {
@Override
public void run() {
TransactionPair<?> pair = (TransactionPair<?>) ((IStructuredSelection) transactions.getSelection()).getFirstElement();
if (pair == null)
return;
pair.deleteTransaction(getClient());
getClient().markDirty();
}
});
}
Aggregations