Search in sources :

Example 6 with LabelOnly

use of name.abuchen.portfolio.ui.util.LabelOnly in project portfolio by buchen.

the class ReviewExtractedItemsPage method showContextMenu.

private void showContextMenu(IMenuManager manager) {
    IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
    boolean atLeastOneImported = false;
    boolean atLeastOneNotImported = false;
    for (Object element : selection.toList()) {
        ExtractedEntry entry = (ExtractedEntry) element;
        // an entry will be imported if it is marked as to be
        // imported *and* not a duplicate
        atLeastOneImported = atLeastOneImported || entry.isImported();
        // an entry will not be imported if it marked as not to be
        // imported *or* if it is marked as duplicate
        atLeastOneNotImported = atLeastOneNotImported || !entry.isImported();
    }
    // provide a hint to the user why the entry is struck out
    if (selection.size() == 1) {
        ExtractedEntry entry = (ExtractedEntry) selection.getFirstElement();
        // 
        entry.getStatus().filter(// 
        s -> s.getCode() != ImportAction.Status.Code.OK).forEach(s -> {
            Images image = // 
            s.getCode() == ImportAction.Status.Code.WARNING ? Images.WARNING : Images.ERROR;
            manager.add(new LabelOnly(s.getMessage(), image.descriptor()));
        });
    }
    if (atLeastOneImported) {
        manager.add(new Action(Messages.LabelDoNotImport) {

            @Override
            public void run() {
                for (Object element : ((IStructuredSelection) tableViewer.getSelection()).toList()) ((ExtractedEntry) element).setImported(false);
                tableViewer.refresh();
            }
        });
    }
    if (atLeastOneNotImported) {
        manager.add(new Action(Messages.LabelDoImport) {

            @Override
            public void run() {
                for (Object element : ((IStructuredSelection) tableViewer.getSelection()).toList()) ((ExtractedEntry) element).setImported(true);
                tableViewer.refresh();
            }
        });
    }
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) StyledString(org.eclipse.jface.viewers.StyledString) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) AbstractWizardPage(name.abuchen.portfolio.ui.wizards.AbstractWizardPage) IStatus(org.eclipse.core.runtime.IStatus) Extractor(name.abuchen.portfolio.datatransfer.Extractor) ViewerCell(org.eclipse.jface.viewers.ViewerCell) Composite(org.eclipse.swt.widgets.Composite) ImportAction(name.abuchen.portfolio.datatransfer.ImportAction) AbstractClientJob(name.abuchen.portfolio.ui.AbstractClientJob) CheckCurrenciesAction(name.abuchen.portfolio.datatransfer.actions.CheckCurrenciesAction) Button(org.eclipse.swt.widgets.Button) Account(name.abuchen.portfolio.model.Account) MenuManager(org.eclipse.jface.action.MenuManager) Status(org.eclipse.core.runtime.Status) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Collectors(java.util.stream.Collectors) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) List(java.util.List) Styler(org.eclipse.jface.viewers.StyledString.Styler) SWT(org.eclipse.swt.SWT) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Label(org.eclipse.swt.widgets.Label) IntStream(java.util.stream.IntStream) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) LocalDateTime(java.time.LocalDateTime) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) TextStyle(org.eclipse.swt.graphics.TextStyle) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Table(org.eclipse.swt.widgets.Table) OptionalInt(java.util.OptionalInt) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ArrayList(java.util.ArrayList) Annotated(name.abuchen.portfolio.model.Annotated) Messages(name.abuchen.portfolio.ui.Messages) CheckValidTypesAction(name.abuchen.portfolio.datatransfer.actions.CheckValidTypesAction) ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) DetectDuplicatesAction(name.abuchen.portfolio.datatransfer.actions.DetectDuplicatesAction) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) AccountTransferEntry(name.abuchen.portfolio.model.AccountTransferEntry) Portfolio(name.abuchen.portfolio.model.Portfolio) Combo(org.eclipse.swt.widgets.Combo) FormLayout(org.eclipse.swt.layout.FormLayout) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Action(org.eclipse.jface.action.Action) FormAttachment(org.eclipse.swt.layout.FormAttachment) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PortfolioPlugin(name.abuchen.portfolio.ui.PortfolioPlugin) StyledCellLabelProvider(org.eclipse.jface.viewers.StyledCellLabelProvider) AssistantPDFExtractor(name.abuchen.portfolio.datatransfer.pdf.AssistantPDFExtractor) FormDataFactory(name.abuchen.portfolio.ui.util.FormDataFactory) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) Collections(java.util.Collections) LabelProvider(org.eclipse.jface.viewers.LabelProvider) PortfolioTransferEntry(name.abuchen.portfolio.model.PortfolioTransferEntry) ImportAction(name.abuchen.portfolio.datatransfer.ImportAction) CheckCurrenciesAction(name.abuchen.portfolio.datatransfer.actions.CheckCurrenciesAction) CheckValidTypesAction(name.abuchen.portfolio.datatransfer.actions.CheckValidTypesAction) DetectDuplicatesAction(name.abuchen.portfolio.datatransfer.actions.DetectDuplicatesAction) Action(org.eclipse.jface.action.Action) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) Images(name.abuchen.portfolio.ui.Images) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 7 with LabelOnly

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

Example 8 with LabelOnly

use of name.abuchen.portfolio.ui.util.LabelOnly in project portfolio by buchen.

the class ExchangeRateSeriesConfig method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(getLabel()));
    MenuManager subMenu = new MenuManager(Messages.LabelExchangeRate);
    available.stream().forEach(ts -> {
        SimpleAction action = new SimpleAction(ts.getLabel(), a -> {
            series = ts;
            String code = ts.getBaseCurrency() + '/' + ts.getTermCurrency();
            delegate.getWidget().getConfiguration().put(Dashboard.Config.EXCHANGE_RATE_SERIES.name(), code);
            delegate.getClient().markDirty();
        });
        action.setChecked(series.equals(ts));
        subMenu.add(action);
    });
    manager.add(subMenu);
}
Also used : LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IMenuManager(org.eclipse.jface.action.IMenuManager) MenuManager(org.eclipse.jface.action.MenuManager) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 9 with LabelOnly

use of name.abuchen.portfolio.ui.util.LabelOnly in project portfolio by buchen.

the class LabelConfig method menuAboutToShow.

@Override
public void menuAboutToShow(IMenuManager manager) {
    manager.appendToGroup(DashboardView.INFO_MENU_GROUP_NAME, new LabelOnly(delegate.getWidget().getLabel()));
    manager.add(new SimpleAction(Messages.MenuRenameLabel, a -> {
        InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(), Messages.MenuRenameLabel, Messages.ColumnLable, delegate.getWidget().getLabel(), null);
        if (dialog.open() != InputDialog.OK)
            return;
        delegate.getWidget().setLabel(dialog.getValue());
        delegate.getClient().markDirty();
    }));
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) IMenuManager(org.eclipse.jface.action.IMenuManager) Messages(name.abuchen.portfolio.ui.Messages) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) Display(org.eclipse.swt.widgets.Display) InputDialog(org.eclipse.jface.dialogs.InputDialog) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction)

Example 10 with LabelOnly

use of name.abuchen.portfolio.ui.util.LabelOnly 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

LabelOnly (name.abuchen.portfolio.ui.util.LabelOnly)11 IMenuManager (org.eclipse.jface.action.IMenuManager)8 Messages (name.abuchen.portfolio.ui.Messages)7 SimpleAction (name.abuchen.portfolio.ui.util.SimpleAction)7 Action (org.eclipse.jface.action.Action)7 MenuManager (org.eclipse.jface.action.MenuManager)6 Separator (org.eclipse.jface.action.Separator)6 List (java.util.List)4 Images (name.abuchen.portfolio.ui.Images)4 SWT (org.eclipse.swt.SWT)4 Composite (org.eclipse.swt.widgets.Composite)4 Display (org.eclipse.swt.widgets.Display)4 Client (name.abuchen.portfolio.model.Client)3 Collections (java.util.Collections)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Dashboard (name.abuchen.portfolio.model.Dashboard)2 Security (name.abuchen.portfolio.model.Security)2 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)2 CurrencyConverterImpl (name.abuchen.portfolio.money.CurrencyConverterImpl)2