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;
}
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();
}
}
}
});
}
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);
}
Aggregations