Search in sources :

Example 26 with SimpleAction

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

the class DividendsView method addButtons.

@Override
protected void addButtons(ToolBar toolBar) {
    new StartYearSelectionDropDown(toolBar, model);
    AbstractDropDown dropDown = AbstractDropDown.create(toolBar, Messages.MenuChooseClientFilter, model.getClientFilterMenu().hasActiveFilter() ? Images.FILTER_ON.image() : Images.FILTER_OFF.image(), SWT.NONE, model.getClientFilterMenu()::menuAboutToShow);
    model.getClientFilterMenu().addListener(f -> dropDown.getToolItem().setImage(model.getClientFilterMenu().hasActiveFilter() ? Images.FILTER_ON.image() : Images.FILTER_OFF.image()));
    new AbstractDropDown(toolBar, Messages.MenuExportData, Images.EXPORT.image(), SWT.NONE) {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            final int itemCount = folder.getItemCount();
            for (int ii = 0; ii < itemCount; ii++) {
                DividendsTab tab = (DividendsTab) folder.getItem(ii).getData();
                if (tab != null)
                    tab.addExportActions(manager);
            }
        }
    };
    new AbstractDropDown(toolBar, Messages.MenuConfigureChart, Images.CONFIG.image(), SWT.NONE) {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            Action action = new SimpleAction(Messages.LabelUseGrossDividends, a -> model.setUseGrossValue(!model.usesGrossValue()));
            action.setChecked(model.usesGrossValue());
            manager.add(action);
            DividendsTab tab = (DividendsTab) folder.getSelection().getData();
            if (tab != null) {
                manager.add(new Separator());
                tab.addConfigActions(manager);
            }
        }
    };
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) IMenuManager(org.eclipse.jface.action.IMenuManager) 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