Search in sources :

Example 1 with OpenDialogAction

use of name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction 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 OpenDialogAction

use of name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction in project portfolio by buchen.

the class InvestmentPlanListView method fillPlansContextMenu.

private void fillPlansContextMenu(IMenuManager manager) {
    final InvestmentPlan plan = (InvestmentPlan) ((IStructuredSelection) plans.getSelection()).getFirstElement();
    if (plan == null)
        return;
    manager.add(new Action(Messages.InvestmentPlanMenuGenerateTransactions) {

        @Override
        public void run() {
            CurrencyConverterImpl converter = new CurrencyConverterImpl(factory, getClient().getBaseCurrency());
            List<PortfolioTransaction> latest = plan.generateTransactions(converter);
            if (latest.isEmpty()) {
                MessageDialog.openInformation(getActiveShell(), Messages.LabelInfo, MessageFormat.format(Messages.InvestmentPlanInfoNoTransactionsGenerated, Values.Date.format(plan.getDateOfNextTransactionToBeGenerated())));
            } else {
                markDirty();
                plans.refresh();
                transactions.markTransactions(latest);
                transactions.setInput(plan.getPortfolio(), plan.getTransactions());
            }
        }
    });
    manager.add(new Separator());
    // 
    new OpenDialogAction(this, Messages.MenuEditInvestmentPlan).type(InvestmentPlanDialog.class, // 
    d -> d.setPlan(plan)).onSuccess(d -> {
        markDirty();
        plans.setInput(getClient().getPlans());
    }).addTo(manager);
    manager.add(new Action(Messages.InvestmentPlanMenuDelete) {

        @Override
        public void run() {
            getClient().removePlan(plan);
            markDirty();
            plans.setInput(getClient().getPlans());
            transactions.setInput(null, null);
        }
    });
}
Also used : PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) DateEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateEditingSupport) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) ToolBar(org.eclipse.swt.widgets.ToolBar) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) ListEditingSupport(name.abuchen.portfolio.ui.util.viewers.ListEditingSupport) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) InvestmentPlanModel(name.abuchen.portfolio.ui.dialogs.transactions.InvestmentPlanModel) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) InvestmentPlanDialog(name.abuchen.portfolio.ui.dialogs.transactions.InvestmentPlanDialog) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) Separator(org.eclipse.jface.action.Separator) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) Account(name.abuchen.portfolio.model.Account) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) MenuManager(org.eclipse.jface.action.MenuManager) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) Security(name.abuchen.portfolio.model.Security) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) InvestmentPlan(name.abuchen.portfolio.model.InvestmentPlan) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) IMenuManager(org.eclipse.jface.action.IMenuManager) SWT(org.eclipse.swt.SWT) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Collections(java.util.Collections) BooleanEditingSupport(name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport) Action(org.eclipse.jface.action.Action) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) InvestmentPlan(name.abuchen.portfolio.model.InvestmentPlan) ArrayList(java.util.ArrayList) List(java.util.List) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) Separator(org.eclipse.jface.action.Separator) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)

Example 3 with OpenDialogAction

use of name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction in project portfolio by buchen.

the class AccountContextMenu method menuAboutToShow.

public void menuAboutToShow(IMenuManager manager, final Account account, final Security security) {
    if (account == null)
        return;
    for (final AccountTransaction.Type type : // 
    EnumSet.of(// 
    AccountTransaction.Type.DEPOSIT, // 
    AccountTransaction.Type.REMOVAL, // 
    AccountTransaction.Type.TAXES, // 
    AccountTransaction.Type.TAX_REFUND, // 
    AccountTransaction.Type.FEES, // 
    AccountTransaction.Type.FEES_REFUND, // 
    AccountTransaction.Type.INTEREST, AccountTransaction.Type.INTEREST_CHARGE)) {
        // $NON-NLS-1$
        new OpenDialogAction(owner, type.toString() + "...").type(// 
        AccountTransactionDialog.class).parameters(// 
        type).with(// 
        account).with(// 
        security).addTo(manager);
    }
    manager.add(new Separator());
    // 
    new OpenDialogAction(owner, Messages.AccountMenuTransfer).type(// 
    AccountTransferDialog.class).with(// 
    account).addTo(manager);
    manager.add(new Separator());
    if (!owner.getClient().getActivePortfolios().isEmpty() && !owner.getClient().getSecurities().isEmpty()) {
        // preselect a portfolio that has the current
        // account as a reference account
        final Portfolio[] portfolio = new Portfolio[1];
        for (Portfolio p : owner.getClient().getActivePortfolios()) {
            if (p.getReferenceAccount().equals(account)) {
                portfolio[0] = p;
                break;
            }
        }
        // $NON-NLS-1$
        new OpenDialogAction(owner, Messages.SecurityMenuBuy + "...").type(// 
        SecurityTransactionDialog.class).parameters(// 
        PortfolioTransaction.Type.BUY).with(// 
        portfolio[0]).with(// 
        security).addTo(manager);
        // $NON-NLS-1$
        new OpenDialogAction(owner, Messages.SecurityMenuSell + "...").type(// 
        SecurityTransactionDialog.class).parameters(// 
        PortfolioTransaction.Type.SELL).with(// 
        portfolio[0]).with(// 
        security).addTo(manager);
        // $NON-NLS-1$
        new OpenDialogAction(owner, Messages.SecurityMenuDividends + "...").type(// 
        AccountTransactionDialog.class).parameters(// 
        AccountTransaction.Type.DIVIDENDS).with(// 
        account).with(// 
        security).addTo(manager);
    }
}
Also used : Portfolio(name.abuchen.portfolio.model.Portfolio) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Separator(org.eclipse.jface.action.Separator) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)

Example 4 with OpenDialogAction

use of name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction 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)

Example 5 with OpenDialogAction

use of name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction in project portfolio by buchen.

the class InvestmentPlanListView method addNewInvestmentPlanButton.

private void addNewInvestmentPlanButton(ToolBar toolBar) {
    Action action = // 
    new OpenDialogAction(this, Messages.InvestmentPlanMenuCreate).type(InvestmentPlanDialog.class).onSuccess(d -> {
        markDirty();
        plans.setInput(getClient().getPlans());
    });
    action.setImageDescriptor(Images.PLUS.descriptor());
    action.setToolTipText(Messages.InvestmentPlanMenuCreate);
    new ActionContributionItem(action).fill(toolBar, -1);
}
Also used : Action(org.eclipse.jface.action.Action) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) InvestmentPlanDialog(name.abuchen.portfolio.ui.dialogs.transactions.InvestmentPlanDialog) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)

Aggregations

OpenDialogAction (name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction)5 Action (org.eclipse.jface.action.Action)4 Separator (org.eclipse.jface.action.Separator)4 MessageFormat (java.text.MessageFormat)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)2 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)2 Security (name.abuchen.portfolio.model.Security)2 Values (name.abuchen.portfolio.money.Values)2 Images (name.abuchen.portfolio.ui.Images)2 Messages (name.abuchen.portfolio.ui.Messages)2 BooleanEditingSupport (name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport)2 Column (name.abuchen.portfolio.ui.util.viewers.Column)2 ColumnEditingSupport (name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport)2 ModificationListener (name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener)2 ColumnViewerSorter (name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter)2 ShowHideColumnHelper (name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper)2 NoteColumn (name.abuchen.portfolio.ui.views.columns.NoteColumn)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2