Search in sources :

Example 11 with SimpleAction

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

the class DividendsMatrixTab method addConfigActions.

@Override
public void addConfigActions(IMenuManager manager) {
    Action action = new SimpleAction(Messages.LabelShowOnlyOneYear, a -> {
        showOnlyOneYear = !showOnlyOneYear;
        updateColumns(tableViewer, tableLayout);
    });
    action.setChecked(showOnlyOneYear);
    manager.add(action);
}
Also used : SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 12 with SimpleAction

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

the class TaxonomyView method addView.

private void addView(final ToolBar toolBar, String label, Images image, final int index) {
    Action showDefinition = new SimpleAction(label, Action.AS_CHECK_BOX, a -> activateView(index));
    showDefinition.setImageDescriptor(image.descriptor());
    showDefinition.setToolTipText(label);
    new ActionContributionItem(showDefinition).fill(toolBar, -1);
    viewActions.add(showDefinition);
}
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 13 with SimpleAction

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

the class DataSeriesConfigurator method addCopyFromOtherChartsMenu.

private void addCopyFromOtherChartsMenu(IMenuManager manager) {
    String[] charts = new String[] { // $NON-NLS-1$
    "StatementOfAssetsHistoryView", // $NON-NLS-1$
    Messages.LabelStatementOfAssetsHistory, // $NON-NLS-1$
    "PerformanceChartView", // $NON-NLS-1$
    Messages.LabelPerformanceChart, "ReturnsVolatilityChartView", // $NON-NLS-1$
    Messages.LabelHistoricalReturnsAndVolatiltity };
    MenuManager copyFromOthers = new MenuManager(Messages.ChartSeriesCopySeriesFromOtherChart);
    manager.add(copyFromOthers);
    MenuManager replaceByOthers = new MenuManager(Messages.ChartSeriesReplaceSeriesByOtherChart);
    manager.add(replaceByOthers);
    String currentConfigUUID = store.getActiveUUID();
    for (int ii = 0; ii < charts.length; ii += 2) {
        ConfigurationSet set = client.getSettings().getConfigurationSet(charts[ii] + IDENTIFIER_POSTFIX);
        MenuManager menuCopy = new MenuManager(charts[ii + 1]);
        copyFromOthers.add(menuCopy);
        MenuManager menuReplace = new MenuManager(charts[ii + 1]);
        replaceByOthers.add(menuReplace);
        set.getConfigurations().forEach(config -> {
            if (Objects.equals(currentConfigUUID, config.getUUID()))
                return;
            menuCopy.add(new SimpleAction(config.getName(), a -> {
                List<DataSeries> list = new DataSeriesSerializer().fromString(dataSeriesSet, config.getData());
                list.stream().filter(s -> !selectedSeries.contains(s)).forEach(s -> selectedSeries.add(s));
                fireUpdate();
            }));
            menuReplace.add(new SimpleAction(config.getName(), a -> {
                List<DataSeries> list = new DataSeriesSerializer().fromString(dataSeriesSet, config.getData());
                selectedSeries.clear();
                list.stream().forEach(s -> selectedSeries.add(s));
                fireUpdate();
            }));
        });
    }
}
Also used : Separator(org.eclipse.jface.action.Separator) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Shell(org.eclipse.swt.widgets.Shell) Client(name.abuchen.portfolio.model.Client) Iterator(java.util.Iterator) ConfigurationStore(name.abuchen.portfolio.ui.util.ConfigurationStore) MenuManager(org.eclipse.jface.action.MenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Display(org.eclipse.swt.widgets.Display) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) IMenuManager(org.eclipse.jface.action.IMenuManager) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) Messages(name.abuchen.portfolio.ui.Messages) ConfigurationStoreOwner(name.abuchen.portfolio.ui.util.ConfigurationStore.ConfigurationStoreOwner) ConfigurationSet(name.abuchen.portfolio.model.ConfigurationSet) ListSelectionDialog(name.abuchen.portfolio.ui.dialogs.ListSelectionDialog) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener) ConfigurationSet(name.abuchen.portfolio.model.ConfigurationSet) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ArrayList(java.util.ArrayList) List(java.util.List) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 14 with SimpleAction

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

the class DataSeriesConfigurator method configMenuAboutToShow.

private // NOSONAR
void configMenuAboutToShow(// NOSONAR
IMenuManager manager) {
    for (final DataSeries series : selectedSeries) {
        Action action = new SimpleAction(series.getLabel(), a -> doDeleteSeries(series));
        action.setChecked(true);
        manager.add(action);
    }
    manager.add(new Separator());
    manager.add(new SimpleAction(Messages.ChartSeriesPickerAddItem, a -> doAddSeries(false)));
    if (dataSeriesSet.getUseCase() != DataSeries.UseCase.STATEMENT_OF_ASSETS)
        manager.add(new SimpleAction(Messages.ChartSeriesPickerAddBenchmark, a -> doAddSeries(true)));
    addCopyFromOtherChartsMenu(manager);
    manager.add(new SimpleAction(Messages.MenuResetChartSeries, a -> doResetSeries(null)));
}
Also used : Separator(org.eclipse.jface.action.Separator) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Shell(org.eclipse.swt.widgets.Shell) Client(name.abuchen.portfolio.model.Client) Iterator(java.util.Iterator) ConfigurationStore(name.abuchen.portfolio.ui.util.ConfigurationStore) MenuManager(org.eclipse.jface.action.MenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) Display(org.eclipse.swt.widgets.Display) ArrayList(java.util.ArrayList) Objects(java.util.Objects) List(java.util.List) IMenuManager(org.eclipse.jface.action.IMenuManager) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) Messages(name.abuchen.portfolio.ui.Messages) ConfigurationStoreOwner(name.abuchen.portfolio.ui.util.ConfigurationStore.ConfigurationStoreOwner) ConfigurationSet(name.abuchen.portfolio.model.ConfigurationSet) ListSelectionDialog(name.abuchen.portfolio.ui.dialogs.ListSelectionDialog) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener) 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 15 with SimpleAction

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

the class ClientEditorSidebar method menuAboutToShow.

public void menuAboutToShow(IMenuManager menuManager) {
    // entries is a flat list of all entries
    MenuManager subMenu = null;
    for (Entry entry : sidebar.getEntries()) {
        int indent = entry.getIndent();
        Action action = entry.getAction();
        if (indent == 0) {
            subMenu = new MenuManager(entry.getLabel());
            menuManager.add(subMenu);
        } else {
            if (subMenu == null || action == null)
                continue;
            // cannot use the original action b/c it will not highlight the selected entry
            // in the sidebar
            // $NON-NLS-1$
            String text = indent > Sidebar.STEP ? "- " + action.getText() : action.getText();
            SimpleAction menuAction = new SimpleAction(text, a -> sidebar.select(entry));
            menuAction.setImageDescriptor(action.getImageDescriptor());
            subMenu.add(menuAction);
        }
    }
}
Also used : Entry(name.abuchen.portfolio.ui.Sidebar.Entry) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

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