Search in sources :

Example 1 with DateSelectionDialog

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());
        }));
    });
}
Also used : Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) ToolBar(org.eclipse.swt.widgets.ToolBar) Images(name.abuchen.portfolio.ui.Images) Inject(javax.inject.Inject) Composite(org.eclipse.swt.widgets.Composite) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) Messages(name.abuchen.portfolio.ui.Messages) ClientFilterDropDown(name.abuchen.portfolio.ui.util.ClientFilterDropDown) Separator(org.eclipse.jface.action.Separator) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) DateSelectionDialog(name.abuchen.portfolio.ui.dialogs.DateSelectionDialog) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) List(java.util.List) PropertyChangeListener(java.beans.PropertyChangeListener) IMenuManager(org.eclipse.jface.action.IMenuManager) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) Collections(java.util.Collections) ClientSnapshot(name.abuchen.portfolio.snapshot.ClientSnapshot) Control(org.eclipse.swt.widgets.Control) DateSelectionDialog(name.abuchen.portfolio.ui.dialogs.DateSelectionDialog) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Separator(org.eclipse.jface.action.Separator)

Aggregations

PropertyChangeListener (java.beans.PropertyChangeListener)1 LocalDate (java.time.LocalDate)1 Collections (java.util.Collections)1 List (java.util.List)1 Inject (javax.inject.Inject)1 Client (name.abuchen.portfolio.model.Client)1 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)1 CurrencyConverterImpl (name.abuchen.portfolio.money.CurrencyConverterImpl)1 CurrencyUnit (name.abuchen.portfolio.money.CurrencyUnit)1 ExchangeRateProviderFactory (name.abuchen.portfolio.money.ExchangeRateProviderFactory)1 Values (name.abuchen.portfolio.money.Values)1 ClientSnapshot (name.abuchen.portfolio.snapshot.ClientSnapshot)1 AbstractFinanceView (name.abuchen.portfolio.ui.AbstractFinanceView)1 Images (name.abuchen.portfolio.ui.Images)1 Messages (name.abuchen.portfolio.ui.Messages)1 DateSelectionDialog (name.abuchen.portfolio.ui.dialogs.DateSelectionDialog)1 AbstractDropDown (name.abuchen.portfolio.ui.util.AbstractDropDown)1 ClientFilterDropDown (name.abuchen.portfolio.ui.util.ClientFilterDropDown)1 LabelOnly (name.abuchen.portfolio.ui.util.LabelOnly)1 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)1