Search in sources :

Example 1 with ReportingPeriodDialog

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

the class ReportingPeriodColumnOptions method createNewOption.

@Override
public ReportingPeriod createNewOption(Shell shell) {
    ReportingPeriodDialog dialog = new ReportingPeriodDialog(shell, null);
    if (dialog.open() == ReportingPeriodDialog.OK) {
        ReportingPeriod p = dialog.getReportingPeriod();
        defaultOptions.add(p);
        return p;
    }
    return null;
}
Also used : ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) ReportingPeriodDialog(name.abuchen.portfolio.ui.dialogs.ReportingPeriodDialog)

Example 2 with ReportingPeriodDialog

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

the class ReportingPeriodDropDown method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    boolean isFirst = true;
    for (final ReportingPeriod period : periods) {
        Action action = new Action(period.toString()) {

            @Override
            public void run() {
                periods.remove(period);
                periods.addFirst(period);
                setLabel(period.toString());
                if (listener != null)
                    listener.reportingPeriodUpdated();
            }
        };
        if (isFirst)
            action.setChecked(true);
        isFirst = false;
        manager.add(action);
    }
    manager.add(new Separator());
    manager.add(new Action(Messages.LabelReportingAddPeriod) {

        @Override
        public void run() {
            ReportingPeriodDialog dialog = new ReportingPeriodDialog(getToolBar().getShell(), periods.getFirst());
            if (dialog.open() == Dialog.OK) {
                ReportingPeriod period = dialog.getReportingPeriod();
                periods.addFirst(period);
                setLabel(period.toString());
                if (listener != null)
                    listener.reportingPeriodUpdated();
                if (periods.size() > 20)
                    periods.removeLast();
            }
        }
    });
    manager.add(new Action(Messages.MenuReportingPeriodManage) {

        @Override
        public void run() {
            EditReportingPeriodsDialog dialog = new EditReportingPeriodsDialog(getToolBar().getShell());
            dialog.setReportingPeriods(periods);
            if (dialog.open() == Dialog.OK) {
                ReportingPeriod currentSelection = periods.getFirst();
                periods.clear();
                periods.addAll(dialog.getReportingPeriods());
                // make sure at least one entry exists
                if (periods.isEmpty())
                    periods.add(currentSelection);
                if (listener != null && !currentSelection.equals(periods.getFirst())) {
                    setLabel(periods.getFirst().toString());
                    listener.reportingPeriodUpdated();
                }
            }
        }
    });
}
Also used : ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Action(org.eclipse.jface.action.Action) EditReportingPeriodsDialog(name.abuchen.portfolio.ui.dialogs.EditReportingPeriodsDialog) Separator(org.eclipse.jface.action.Separator) ReportingPeriodDialog(name.abuchen.portfolio.ui.dialogs.ReportingPeriodDialog)

Example 3 with ReportingPeriodDialog

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

Aggregations

ReportingPeriod (name.abuchen.portfolio.snapshot.ReportingPeriod)3 ReportingPeriodDialog (name.abuchen.portfolio.ui.dialogs.ReportingPeriodDialog)3 Separator (org.eclipse.jface.action.Separator)2 IOException (java.io.IOException)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 FormatStyle (java.time.format.FormatStyle)1 Dashboard (name.abuchen.portfolio.model.Dashboard)1 Messages (name.abuchen.portfolio.ui.Messages)1 PortfolioPlugin (name.abuchen.portfolio.ui.PortfolioPlugin)1 EditReportingPeriodsDialog (name.abuchen.portfolio.ui.dialogs.EditReportingPeriodsDialog)1 LabelOnly (name.abuchen.portfolio.ui.util.LabelOnly)1 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)1 Action (org.eclipse.jface.action.Action)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Display (org.eclipse.swt.widgets.Display)1