Search in sources :

Example 1 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class SecuritiesChart method chartConfigAboutToShow.

private void chartConfigAboutToShow(IMenuManager manager) {
    for (ChartDetails detail : ChartDetails.values()) {
        // $NON-NLS-1$
        String buttonDescription = detail.toString().replaceAll(SEPERATOR, "");
        Action action = new SimpleAction(buttonDescription, a -> {
            boolean isActive = chartConfig.contains(detail);
            if (isActive)
                chartConfig.remove(detail);
            else
                chartConfig.add(detail);
            client.setProperty(PREF_KEY, // $NON-NLS-1$
            String.join(// $NON-NLS-1$
            ",", chartConfig.stream().map(ChartDetails::name).collect(Collectors.toList())));
            updateChart();
        });
        action.setChecked(chartConfig.contains(detail));
        manager.add(action);
        if (detail.toString().endsWith(SEPERATOR))
            manager.add(new Separator());
    }
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Example 2 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class ReturnsVolatilityChartView method addConfigButton.

private void addConfigButton(ToolBar toolBar) {
    Action save = new SimpleAction(Messages.MenuSaveChart, a -> configurator.showSaveMenu(getActiveShell()));
    save.setImageDescriptor(Images.SAVE.descriptor());
    save.setToolTipText(Messages.MenuSaveChart);
    new ActionContributionItem(save).fill(toolBar, -1);
    Action config = new SimpleAction(Messages.MenuConfigureChart, a -> configurator.showMenu(getActiveShell()));
    config.setImageDescriptor(Images.CONFIG.descriptor());
    config.setToolTipText(Messages.MenuConfigureChart);
    new ActionContributionItem(config).fill(toolBar, -1);
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 3 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class AccountListView method addNewButton.

private void addNewButton(ToolBar toolBar) {
    SimpleAction.Runnable newAccountAction = a -> {
        Account account = new Account();
        account.setName(Messages.LabelNoName);
        account.setCurrencyCode(getClient().getBaseCurrency());
        getClient().addAccount(account);
        markDirty();
        resetInput();
        accounts.editElement(account, 0);
    };
    AbstractDropDown.create(toolBar, Messages.MenuCreateAccountOrTransaction, Images.PLUS.image(), SWT.NONE, (dd, manager) -> {
        manager.add(new SimpleAction(Messages.AccountMenuAdd, newAccountAction));
        manager.add(new Separator());
        Account account = (Account) accounts.getStructuredSelection().getFirstElement();
        new AccountContextMenu(AccountListView.this).menuAboutToShow(manager, account, null);
    });
}
Also used : NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) Type(name.abuchen.portfolio.model.AccountTransaction.Type) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) AccountSnapshot(name.abuchen.portfolio.snapshot.AccountSnapshot) ToolBar(org.eclipse.swt.widgets.ToolBar) 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) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) KeyEvent(org.eclipse.swt.events.KeyEvent) LocalTime(java.time.LocalTime) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Separator(org.eclipse.jface.action.Separator) Account(name.abuchen.portfolio.model.Account) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) MenuManager(org.eclipse.jface.action.MenuManager) CurrencyEditingSupport(name.abuchen.portfolio.ui.views.columns.CurrencyColumn.CurrencyEditingSupport) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) DateTimeEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateTimeEditingSupport) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) Colors(name.abuchen.portfolio.ui.util.Colors) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Quote(name.abuchen.portfolio.money.Quote) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) LocalDateTime(java.time.LocalDateTime) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) ISeries(org.swtchart.ISeries) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Messages(name.abuchen.portfolio.ui.Messages) AccountTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransferDialog) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) AccountTransferEntry(name.abuchen.portfolio.model.AccountTransferEntry) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) MutableMoney(name.abuchen.portfolio.money.MutableMoney) TimelineChart(name.abuchen.portfolio.ui.util.chart.TimelineChart) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) CTabItem(org.eclipse.swt.custom.CTabItem) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) ChronoUnit(java.time.temporal.ChronoUnit) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolTip(org.eclipse.jface.window.ToolTip) Collections(java.util.Collections) Control(org.eclipse.swt.widgets.Control) Account(name.abuchen.portfolio.model.Account) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Example 4 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class DashboardView method addButtons.

@Override
protected void addButtons(ToolBar toolBar) {
    super.addButtons(toolBar);
    AbstractDropDown.create(toolBar, Messages.MenuConfigureDashboards, Images.SAVE.image(), SWT.NONE, manager -> {
        getClient().getDashboards().forEach(d -> {
            Action action = new SimpleAction(d.getName(), a -> selectDashboard(d));
            action.setChecked(d.equals(dashboard));
            manager.add(action);
        });
        manager.add(new Separator());
        manager.add(new SimpleAction(Messages.ConfigurationNew, a -> createNewDashboard(null)));
        manager.add(new SimpleAction(Messages.ConfigurationDuplicate, a -> createNewDashboard(dashboard)));
        manager.add(new SimpleAction(Messages.ConfigurationRename, a -> renameDashboard(dashboard)));
        manager.add(new SimpleAction(Messages.ConfigurationDelete, a -> deleteDashboard(dashboard)));
    });
    AbstractDropDown.create(toolBar, Messages.MenuConfigureCurrentDashboard, Images.CONFIG.image(), SWT.NONE, manager -> manager.add(new SimpleAction(Messages.MenuNewDashboardColumn, a -> createNewColumn())));
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) DND(org.eclipse.swt.dnd.DND) ToolBar(org.eclipse.swt.widgets.ToolBar) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Inject(javax.inject.Inject) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) AbstractHistoricView(name.abuchen.portfolio.ui.views.AbstractHistoricView) DragSource(org.eclipse.swt.dnd.DragSource) InfoToolTip(name.abuchen.portfolio.ui.util.InfoToolTip) DropTarget(org.eclipse.swt.dnd.DropTarget) Separator(org.eclipse.jface.action.Separator) Dashboard(name.abuchen.portfolio.model.Dashboard) MenuManager(org.eclipse.jface.action.MenuManager) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) Transfer(org.eclipse.swt.dnd.Transfer) Consumer(java.util.function.Consumer) IMenuManager(org.eclipse.jface.action.IMenuManager) StringJoiner(java.util.StringJoiner) SWT(org.eclipse.swt.SWT) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) Control(org.eclipse.swt.widgets.Control) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Example 5 with SimpleAction

use of name.abuchen.portfolio.ui.util.SimpleAction in project portfolio by buchen.

the class DashboardView method buildColumn.

private Composite buildColumn(Composite composite, Dashboard.Column column) {
    Composite columnControl = new Composite(composite, SWT.NONE);
    columnControl.setBackground(composite.getBackground());
    columnControl.setData(column);
    GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 0).applyTo(columnControl);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(columnControl);
    addDropListener(columnControl);
    // Each column has an empty composite at the bottom to serve as target
    // for the column context menu. A separate composite is needed because
    // *all* context menus attached to nested composites are always shown.
    Composite filler = new Composite(columnControl, SWT.NONE);
    filler.setBackground(columnControl.getBackground());
    GridDataFactory.fillDefaults().grab(true, true).applyTo(filler);
    columnControl.setData(FILLER_KEY, filler);
    new ContextMenu(filler, manager -> {
        MenuManager subMenu = new MenuManager(Messages.MenuNewWidget);
        for (WidgetFactory type : WidgetFactory.values()) subMenu.add(new SimpleAction(type.getLabel(), a -> addNewWidget(columnControl, type)));
        manager.add(subMenu);
        manager.add(new Separator());
        manager.add(new SimpleAction(Messages.MenuAddNewDashboardColumnLeft, a -> createNewColumn(column, columnControl)));
        manager.add(new SimpleAction(Messages.MenuDeleteDashboardColumn, a -> deleteColumn(columnControl)));
    }).hook();
    return columnControl;
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) DND(org.eclipse.swt.dnd.DND) ToolBar(org.eclipse.swt.widgets.ToolBar) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Inject(javax.inject.Inject) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) AbstractHistoricView(name.abuchen.portfolio.ui.views.AbstractHistoricView) DragSource(org.eclipse.swt.dnd.DragSource) InfoToolTip(name.abuchen.portfolio.ui.util.InfoToolTip) DropTarget(org.eclipse.swt.dnd.DropTarget) Separator(org.eclipse.jface.action.Separator) Dashboard(name.abuchen.portfolio.model.Dashboard) MenuManager(org.eclipse.jface.action.MenuManager) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) Transfer(org.eclipse.swt.dnd.Transfer) Consumer(java.util.function.Consumer) IMenuManager(org.eclipse.jface.action.IMenuManager) StringJoiner(java.util.StringJoiner) SWT(org.eclipse.swt.SWT) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Aggregations

SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)26 Action (org.eclipse.jface.action.Action)20 IMenuManager (org.eclipse.jface.action.IMenuManager)20 Messages (name.abuchen.portfolio.ui.Messages)17 Separator (org.eclipse.jface.action.Separator)16 MenuManager (org.eclipse.jface.action.MenuManager)14 Display (org.eclipse.swt.widgets.Display)13 Inject (javax.inject.Inject)11 SWT (org.eclipse.swt.SWT)11 Images (name.abuchen.portfolio.ui.Images)10 AbstractDropDown (name.abuchen.portfolio.ui.util.AbstractDropDown)9 Composite (org.eclipse.swt.widgets.Composite)9 List (java.util.List)8 LocalDate (java.time.LocalDate)7 Control (org.eclipse.swt.widgets.Control)7 LabelOnly (name.abuchen.portfolio.ui.util.LabelOnly)6 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)6 Image (org.eclipse.swt.graphics.Image)6 Client (name.abuchen.portfolio.model.Client)5 Values (name.abuchen.portfolio.money.Values)5