Search in sources :

Example 1 with StockSplitWizard

use of name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard in project portfolio by buchen.

the class SecuritiesTable method fillTransactionContextMenu.

private void fillTransactionContextMenu(IMenuManager manager, Security security) {
    // $NON-NLS-1$
    new OpenDialogAction(view, Messages.SecurityMenuBuy + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.BUY).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(view, Messages.SecurityMenuSell + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.SELL).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(view, Messages.SecurityMenuDividends + "...").type(// 
    AccountTransactionDialog.class).parameters(// 
    AccountTransaction.Type.DIVIDENDS).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(view, AccountTransaction.Type.TAX_REFUND + "...").type(// 
    AccountTransactionDialog.class).parameters(// 
    AccountTransaction.Type.TAX_REFUND).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    manager.add(new AbstractDialogAction(Messages.SecurityMenuStockSplit) {

        @Override
        Dialog createDialog(Security security) {
            StockSplitWizard wizard = new StockSplitWizard(getClient(), security);
            return new WizardDialog(getShell(), wizard);
        }
    });
    if (view.getClient().getActivePortfolios().size() > 1) {
        manager.add(new Separator());
        // 
        new OpenDialogAction(view, Messages.SecurityMenuTransfer).type(// 
        SecurityTransferDialog.class).with(// 
        security).addTo(manager);
    }
    manager.add(new Separator());
    // $NON-NLS-1$
    new OpenDialogAction(view, PortfolioTransaction.Type.DELIVERY_INBOUND.toString() + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.DELIVERY_INBOUND).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(view, PortfolioTransaction.Type.DELIVERY_OUTBOUND.toString() + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.DELIVERY_OUTBOUND).with(// 
    security).onSuccess(// 
    d -> performFinish(security)).addTo(manager);
    manager.add(new Separator());
}
Also used : ReportingPeriodColumnOptions(name.abuchen.portfolio.ui.util.viewers.ReportingPeriodColumnOptions) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) BiFunction(java.util.function.BiFunction) DND(org.eclipse.swt.dnd.DND) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) StockSplitWizard(name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard) Composite(org.eclipse.swt.widgets.Composite) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) KeyEvent(org.eclipse.swt.events.KeyEvent) Factory(name.abuchen.portfolio.online.Factory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Separator(org.eclipse.jface.action.Separator) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) MenuManager(org.eclipse.jface.action.MenuManager) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Collectors(java.util.stream.Collectors) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) Transfer(org.eclipse.swt.dnd.Transfer) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) OptionLabelProvider(name.abuchen.portfolio.ui.util.viewers.OptionLabelProvider) List(java.util.List) UpdateQuotesJob(name.abuchen.portfolio.ui.UpdateQuotesJob) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) Colors(name.abuchen.portfolio.ui.util.Colors) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) Watchlist(name.abuchen.portfolio.model.Watchlist) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) BooleanEditingSupport(name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) Function(java.util.function.Function) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Messages(name.abuchen.portfolio.ui.Messages) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Taxonomy(name.abuchen.portfolio.model.Taxonomy) NumberColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.NumberColorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Shell(org.eclipse.swt.widgets.Shell) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) Menu(org.eclipse.swt.widgets.Menu) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) Dialog(org.eclipse.jface.dialogs.Dialog) StockSplitWizard(name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard) Security(name.abuchen.portfolio.model.Security) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Separator(org.eclipse.jface.action.Separator) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)

Example 2 with StockSplitWizard

use of name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard in project portfolio by buchen.

the class SecurityContextMenu method menuAboutToShow.

public void menuAboutToShow(IMenuManager manager, final Security security, final Portfolio portfolio) {
    if (owner.getClient().getSecurities().isEmpty())
        return;
    // menus to create transactions
    if (security != null && security.getCurrencyCode() == null) {
        manager.add(new BookmarkMenu(owner.getPart(), security));
        return;
    }
    // $NON-NLS-1$
    new OpenDialogAction(owner, Messages.SecurityMenuBuy + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.BUY).with(// 
    portfolio).with(// 
    security).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(owner, Messages.SecurityMenuSell + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.SELL).with(// 
    portfolio).with(// 
    security).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(owner, Messages.SecurityMenuDividends + "...").type(// 
    AccountTransactionDialog.class).parameters(// 
    AccountTransaction.Type.DIVIDENDS).with(// 
    portfolio != null ? portfolio.getReferenceAccount() : null).with(// 
    security).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(owner, AccountTransaction.Type.TAX_REFUND + "...").type(// 
    AccountTransactionDialog.class).parameters(// 
    AccountTransaction.Type.TAX_REFUND).with(// 
    portfolio != null ? portfolio.getReferenceAccount() : null).with(// 
    security).addTo(manager);
    manager.add(new Action(Messages.SecurityMenuStockSplit) {

        @Override
        public void run() {
            StockSplitWizard wizard = new StockSplitWizard(owner.getClient(), security);
            WizardDialog dialog = new WizardDialog(owner.getActiveShell(), wizard);
            if (dialog.open() == Dialog.OK) {
                owner.markDirty();
                owner.notifyModelUpdated();
            }
        }
    });
    if (owner.getClient().getActivePortfolios().size() > 1) {
        manager.add(new Separator());
        // 
        new OpenDialogAction(owner, Messages.SecurityMenuTransfer).type(// 
        SecurityTransferDialog.class).with(// 
        portfolio).with(// 
        security).addTo(manager);
    }
    manager.add(new Separator());
    // $NON-NLS-1$
    new OpenDialogAction(owner, PortfolioTransaction.Type.DELIVERY_INBOUND.toString() + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.DELIVERY_INBOUND).with(// 
    portfolio).with(// 
    security).addTo(manager);
    // $NON-NLS-1$
    new OpenDialogAction(owner, PortfolioTransaction.Type.DELIVERY_OUTBOUND.toString() + "...").type(// 
    SecurityTransactionDialog.class).parameters(// 
    PortfolioTransaction.Type.DELIVERY_OUTBOUND).with(// 
    portfolio).with(// 
    security).addTo(manager);
    if (security != null) {
        manager.add(new Separator());
        manager.add(new BookmarkMenu(owner.getPart(), security));
    }
}
Also used : BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) Action(org.eclipse.jface.action.Action) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) StockSplitWizard(name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Separator(org.eclipse.jface.action.Separator) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)

Aggregations

OpenDialogAction (name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)2 SecurityTransferDialog (name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog)2 BookmarkMenu (name.abuchen.portfolio.ui.util.BookmarkMenu)2 MessageFormat (java.text.MessageFormat)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)1 Client (name.abuchen.portfolio.model.Client)1 LatestSecurityPrice (name.abuchen.portfolio.model.LatestSecurityPrice)1 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)1 Security (name.abuchen.portfolio.model.Security)1 SecurityPrice (name.abuchen.portfolio.model.SecurityPrice)1 Taxonomy (name.abuchen.portfolio.model.Taxonomy)1 Watchlist (name.abuchen.portfolio.model.Watchlist)1 Values (name.abuchen.portfolio.money.Values)1 Factory (name.abuchen.portfolio.online.Factory)1