Search in sources :

Example 21 with SimpleAction

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

the class ExchangeRateSeriesConfig method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(getLabel()));
    MenuManager subMenu = new MenuManager(Messages.LabelExchangeRate);
    available.stream().forEach(ts -> {
        SimpleAction action = new SimpleAction(ts.getLabel(), a -> {
            series = ts;
            String code = ts.getBaseCurrency() + '/' + ts.getTermCurrency();
            delegate.getWidget().getConfiguration().put(Dashboard.Config.EXCHANGE_RATE_SERIES.name(), code);
            delegate.getClient().markDirty();
        });
        action.setChecked(series.equals(ts));
        subMenu.add(action);
    });
    manager.add(subMenu);
}
Also used : LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IMenuManager(org.eclipse.jface.action.IMenuManager) MenuManager(org.eclipse.jface.action.MenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 22 with SimpleAction

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

the class LabelConfig method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(delegate.getWidget().getLabel()));
    manager.add(new SimpleAction(Messages.MenuRenameLabel, a -> {
        InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.MenuRenameLabel, Messages.ColumnLable, delegate.getWidget().getLabel(), null);
        if (dialog.open() != InputDialog.OK)
            return;
        delegate.getWidget().setLabel(dialog.getValue());
        delegate.getClient().markDirty();
    }));
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) IMenuManager(org.eclipse.jface.action.IMenuManager) Messages(name.abuchen.portfolio.ui.Messages) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) Display(org.eclipse.swt.widgets.Display) InputDialog(org.eclipse.jface.dialogs.InputDialog) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 23 with SimpleAction

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

the class ReportingPeriodConfig method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(getReportingPeriod().toString()));
    MenuManager subMenu = new MenuManager(Messages.LabelReportingPeriod);
    subMenu.add(new LabelOnly(reportingPeriod != null ? getReportingPeriod().toString() : Messages.LabelUsingDashboardDefaultReportingPeriod));
    subMenu.add(new Separator());
    subMenu.add(new SimpleAction(Messages.MenuUseDashboardDefaultReportingPeriod, a -> {
        reportingPeriod = null;
        delegate.getWidget().getConfiguration().remove(Dashboard.Config.REPORTING_PERIOD.name());
        delegate.getClient().markDirty();
    }));
    delegate.getDashboardData().getDefaultReportingPeriods().stream().forEach(p -> subMenu.add(new SimpleAction(p.toString(), a -> {
        reportingPeriod = p;
        delegate.getWidget().getConfiguration().put(Dashboard.Config.REPORTING_PERIOD.name(), p.getCode());
        delegate.getClient().markDirty();
    })));
    subMenu.add(new Separator());
    subMenu.add(new SimpleAction(Messages.LabelReportingAddPeriod, a -> {
        ReportingPeriodDialog dialog = new ReportingPeriodDialog(Display.getDefault().getActiveShell(), getReportingPeriod());
        if (dialog.open() == ReportingPeriodDialog.OK) {
            reportingPeriod = dialog.getReportingPeriod();
            if (!delegate.getDashboardData().getDefaultReportingPeriods().contains(reportingPeriod))
                delegate.getDashboardData().getDefaultReportingPeriods().add(reportingPeriod);
            delegate.getWidget().getConfiguration().put(Dashboard.Config.REPORTING_PERIOD.name(), reportingPeriod.getCode());
            delegate.getClient().markDirty();
        }
    }));
    manager.add(subMenu);
}
Also used : Separator(org.eclipse.jface.action.Separator) FormatStyle(java.time.format.FormatStyle) Dashboard(name.abuchen.portfolio.model.Dashboard) MenuManager(org.eclipse.jface.action.MenuManager) ReportingPeriodDialog(name.abuchen.portfolio.ui.dialogs.ReportingPeriodDialog) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) IOException(java.io.IOException) Display(org.eclipse.swt.widgets.Display) PortfolioPlugin(name.abuchen.portfolio.ui.PortfolioPlugin) IMenuManager(org.eclipse.jface.action.IMenuManager) Messages(name.abuchen.portfolio.ui.Messages) DateTimeFormatter(java.time.format.DateTimeFormatter) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator) ReportingPeriodDialog(name.abuchen.portfolio.ui.dialogs.ReportingPeriodDialog)

Example 24 with SimpleAction

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

the class DashboardView method widgetMenuAboutToShow.

private void widgetMenuAboutToShow(IMenuManager manager, WidgetDelegate delegate) {
    manager.add(new Separator(INFO_MENU_GROUP_NAME));
    // $NON-NLS-1$
    manager.add(new Separator("edit"));
    delegate.getWidgetConfigs().forEach(c -> c.menuAboutToShow(manager));
    manager.add(new Separator());
    manager.add(new SimpleAction(Messages.MenuDeleteWidget, a -> {
        Composite composite = findCompositeFor(delegate);
        if (composite == null)
            throw new IllegalArgumentException();
        Composite parent = composite.getParent();
        Dashboard.Column column = (Dashboard.Column) parent.getData();
        if (!column.getWidgets().remove(delegate.getWidget()))
            throw new IllegalArgumentException();
        composite.dispose();
        parent.layout();
        markDirty();
    }));
}
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) Dashboard(name.abuchen.portfolio.model.Dashboard) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Example 25 with SimpleAction

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

the class DataSeriesConfig method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(dataSeries.getLabel()));
    MenuManager subMenu = new MenuManager(Messages.LabelDataSeries);
    subMenu.add(new LabelOnly(dataSeries.getLabel()));
    subMenu.add(new Separator());
    subMenu.add(new SimpleAction(Messages.MenuSelectDataSeries, a -> doAddSeries(false)));
    if (supportsBenchmarks)
        subMenu.add(new SimpleAction(Messages.MenuSelectBenchmarkDataSeries, a -> doAddSeries(true)));
    manager.add(subMenu);
}
Also used : Separator(org.eclipse.jface.action.Separator) Dashboard(name.abuchen.portfolio.model.Dashboard) MenuManager(org.eclipse.jface.action.MenuManager) DataSeries(name.abuchen.portfolio.ui.views.dataseries.DataSeries) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) List(java.util.List) IMenuManager(org.eclipse.jface.action.IMenuManager) Messages(name.abuchen.portfolio.ui.Messages) ListSelectionDialog(name.abuchen.portfolio.ui.dialogs.ListSelectionDialog) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) DataSeriesLabelProvider(name.abuchen.portfolio.ui.views.dataseries.DataSeriesLabelProvider) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) MenuManager(org.eclipse.jface.action.MenuManager) 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