use of name.abuchen.portfolio.ui.dialogs.DateSelectionDialog in project portfolio by buchen.
the class StatementOfAssetsView method addCalendarButton.
private void addCalendarButton(ToolBar toolBar) {
AbstractDropDown.create(toolBar, Messages.LabelPortfolioTimeMachine, Images.CALENDAR_OFF.image(), SWT.NONE, (dropDown, manager) -> {
manager.add(new LabelOnly(Values.Date.format(snapshotDate)));
manager.add(new Separator());
SimpleAction action = new SimpleAction(Messages.LabelToday, a -> {
snapshotDate = LocalDate.now();
notifyModelUpdated();
dropDown.getToolItem().setImage(Images.CALENDAR_OFF.image());
});
action.setEnabled(!snapshotDate.equals(LocalDate.now()));
manager.add(action);
manager.add(new SimpleAction(Messages.MenuPickOtherDate, a -> {
DateSelectionDialog dialog = new DateSelectionDialog(getActiveShell());
dialog.setSelection(snapshotDate);
if (dialog.open() != DateSelectionDialog.OK)
return;
if (snapshotDate.equals(dialog.getSelection()))
return;
snapshotDate = dialog.getSelection();
notifyModelUpdated();
dropDown.getToolItem().setImage(LocalDate.now().equals(snapshotDate) ? Images.CALENDAR_OFF.image() : Images.CALENDAR_ON.image());
}));
});
}
Aggregations