Search in sources :

Example 26 with ReportingPeriod

use of name.abuchen.portfolio.snapshot.ReportingPeriod 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 27 with ReportingPeriod

use of name.abuchen.portfolio.snapshot.ReportingPeriod in project portfolio by buchen.

the class ChartWidget method update.

@Override
public void update() {
    title.setText(getWidget().getLabel());
    try {
        chart.suspendUpdate(true);
        chart.getTitle().setText(title.getText());
        for (ISeries s : chart.getSeriesSet().getSeries()) chart.getSeriesSet().deleteSeries(s.getId());
        List<DataSeries> series = new DataSeriesSerializer().fromString(dataSeriesSet, get(ChartConfig.class).getData());
        ReportingPeriod reportingPeriod = get(ReportingPeriodConfig.class).getReportingPeriod();
        switch(useCase) {
            case STATEMENT_OF_ASSETS:
                buildAssetSeries(series, reportingPeriod);
                break;
            case PERFORMANCE:
                buildPerformanceSeries(series, reportingPeriod);
                break;
            case RETURN_VOLATILITY:
                throw new UnsupportedOperationException();
            default:
                throw new IllegalArgumentException();
        }
        chart.adjustRange();
    } finally {
        chart.suspendUpdate(false);
    }
    chart.redraw();
}
Also used : ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) DataSeriesSerializer(name.abuchen.portfolio.ui.views.dataseries.DataSeriesSerializer) DataSeries(name.abuchen.portfolio.ui.views.dataseries.DataSeries) ISeries(org.swtchart.ISeries)

Aggregations

ReportingPeriod (name.abuchen.portfolio.snapshot.ReportingPeriod)27 Test (org.junit.Test)14 Client (name.abuchen.portfolio.model.Client)13 ArrayList (java.util.ArrayList)11 Security (name.abuchen.portfolio.model.Security)11 IOException (java.io.IOException)8 TestCurrencyConverter (name.abuchen.portfolio.TestCurrencyConverter)8 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)8 PerformanceIndex (name.abuchen.portfolio.snapshot.PerformanceIndex)8 SecurityPerformanceRecord (name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord)8 SecurityPerformanceSnapshot (name.abuchen.portfolio.snapshot.security.SecurityPerformanceSnapshot)8 Portfolio (name.abuchen.portfolio.model.Portfolio)5 Composite (org.eclipse.swt.widgets.Composite)5 LocalDate (java.time.LocalDate)4 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)4 ExchangeRate (name.abuchen.portfolio.money.ExchangeRate)4 ClientSnapshot (name.abuchen.portfolio.snapshot.ClientSnapshot)4 List (java.util.List)3 Function (java.util.function.Function)3 Collectors (java.util.stream.Collectors)3