Search in sources :

Example 1 with Pair

use of name.abuchen.portfolio.util.Pair in project portfolio by buchen.

the class SecuritiesPerformanceView method createCommonColumns.

private void createCommonColumns() {
    // shares held
    // $NON-NLS-1$
    Column column = new Column("shares", Messages.ColumnSharesOwned, SWT.RIGHT, 80);
    column.setLabelProvider(new // NOSONAR
    SharesLabelProvider() {

        @Override
        public Long getValue(Object e) {
            return ((SecurityPerformanceRecord) e).getSharesHeld();
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "sharesHeld"));
    recordColumns.addColumn(column);
    // security name
    column = new NameColumn(getClient());
    column.getEditingSupport().addListener(new TouchClientListener(getClient()));
    column.setSortDirction(SWT.UP);
    recordColumns.addColumn(column);
    // cost value - fifo
    // $NON-NLS-1$
    column = new Column("pv", Messages.ColumnPurchaseValue, SWT.RIGHT, 75);
    column.setDescription(Messages.ColumnPurchaseValue_Description + TextUtil.PARAGRAPH_BREAK + Messages.DescriptionDataRelativeToReportingPeriod);
    column.setImage(Images.INTERVAL);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Money.format(((SecurityPerformanceRecord) r).getFifoCost(), getClient().getBaseCurrency());
        }

        @Override
        public String getToolTipText(Object r) {
            return ((SecurityPerformanceRecord) r).explain(SecurityPerformanceRecord.Trails.FIFO_COST).isPresent() ? SecurityPerformanceRecord.Trails.FIFO_COST : null;
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCost"));
    recordColumns.addColumn(column);
    // cost value - moving average
    // $NON-NLS-1$
    column = new Column("pvmvavg", Messages.ColumnPurchaseValueMovingAverage, SWT.RIGHT, 75);
    column.setMenuLabel(Messages.ColumnPurchaseValueMovingAverage_MenuLabel);
    column.setDescription(Messages.ColumnPurchaseValueMovingAverage_Description + TextUtil.PARAGRAPH_BREAK + Messages.DescriptionDataRelativeToReportingPeriod);
    column.setImage(Images.INTERVAL);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Money.format(((SecurityPerformanceRecord) r).getMovingAverageCost(), getClient().getBaseCurrency());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "movingAverageCost"));
    column.setVisible(false);
    recordColumns.addColumn(column);
    // cost value per share - fifo
    // $NON-NLS-1$
    column = new Column("pp", Messages.ColumnPurchasePrice, SWT.RIGHT, 75);
    column.setDescription(Messages.ColumnPurchasePrice_Description + TextUtil.PARAGRAPH_BREAK + Messages.DescriptionDataRelativeToReportingPeriod);
    column.setImage(Images.INTERVAL);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.CalculatedQuote.format(((SecurityPerformanceRecord) r).getFifoCostPerSharesHeld(), getClient().getBaseCurrency());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCostPerSharesHeld"));
    recordColumns.addColumn(column);
    // cost value per share - moving average
    // $NON-NLS-1$
    column = new Column("ppmvavg", Messages.ColumnPurchasePriceMovingAverage, SWT.RIGHT, 75);
    column.setMenuLabel(Messages.ColumnPurchasePriceMovingAverage_MenuLabel);
    column.setDescription(Messages.ColumnPurchasePriceMovingAverage_Description + TextUtil.PARAGRAPH_BREAK + Messages.DescriptionDataRelativeToReportingPeriod);
    column.setImage(Images.INTERVAL);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.CalculatedQuote.format(((SecurityPerformanceRecord) r).getMovingAverageCostPerSharesHeld(), getClient().getBaseCurrency());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "movingAverageCostPerSharesHeld"));
    column.setVisible(false);
    recordColumns.addColumn(column);
    // latest / current quote
    // $NON-NLS-1$
    column = new Column("quote", Messages.ColumnQuote, SWT.RIGHT, 75);
    column.setDescription(Messages.ColumnQuote_DescriptionEndOfReportingPeriod);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            SecurityPerformanceRecord record = (SecurityPerformanceRecord) element;
            return Values.Quote.format(record.getQuote(), getClient().getBaseCurrency());
        }

        @Override
        public String getToolTipText(Object element) {
            SecurityPerformanceRecord record = (SecurityPerformanceRecord) element;
            return MessageFormat.format(Messages.TooltipQuoteAtDate, getText(element), Values.Date.format(record.getLatestSecurityPrice().getDate()));
        }
    });
    column.setSorter(ColumnViewerSorter.create(e -> ((SecurityPerformanceRecord) e).getQuote()));
    recordColumns.addColumn(column);
    // change to previous day percent value
    // $NON-NLS-1$
    column = new Column("5", Messages.ColumnChangeOnPrevious, SWT.RIGHT, 60);
    column.setMenuLabel(Messages.ColumnChangeOnPrevious_MenuLabel);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, element -> {
        Optional<Pair<SecurityPrice, SecurityPrice>> previous = ((SecurityPerformanceRecord) element).getSecurity().getLatestTwoSecurityPrices();
        if (previous.isPresent()) {
            double latestQuote = previous.get().getLeft().getValue();
            double previousQuote = previous.get().getRight().getValue();
            return (latestQuote - previousQuote) / previousQuote;
        } else {
            return null;
        }
    }, element -> {
        Optional<Pair<SecurityPrice, SecurityPrice>> previous = ((SecurityPerformanceRecord) element).getSecurity().getLatestTwoSecurityPrices();
        if (previous.isPresent()) {
            return // $NON-NLS-1$
            Messages.ColumnLatestPrice + ": " + MessageFormat.format(Messages.TooltipQuoteAtDate, Values.Quote.format(previous.get().getLeft().getValue()), Values.Date.format(previous.get().getLeft().getDate())) + // //$NON-NLS-1$
            "\n" + Messages.ColumnPreviousPrice + // $NON-NLS-1$
            ": " + MessageFormat.format(Messages.TooltipQuoteAtDate, Values.Quote.format(previous.get().getRight().getValue()), Values.Date.format(previous.get().getRight().getDate()));
        } else {
            return null;
        }
    }));
    column.setSorter(ColumnViewerSorter.create((o1, o2) -> {
        // NOSONAR
        Optional<Pair<SecurityPrice, SecurityPrice>> previous1 = ((SecurityPerformanceRecord) o1).getSecurity().getLatestTwoSecurityPrices();
        Optional<Pair<SecurityPrice, SecurityPrice>> previous2 = ((SecurityPerformanceRecord) o2).getSecurity().getLatestTwoSecurityPrices();
        if (!previous1.isPresent() && !previous2.isPresent())
            return 0;
        if (!previous1.isPresent() && previous2.isPresent())
            return -1;
        if (previous1.isPresent() && !previous2.isPresent())
            return 1;
        double latestQuote1 = previous1.get().getLeft().getValue();
        double previousQuote1 = previous1.get().getRight().getValue();
        double v1 = (latestQuote1 - previousQuote1) / previousQuote1;
        double latestQuote2 = previous2.get().getLeft().getValue();
        double previousQuote2 = previous2.get().getRight().getValue();
        double v2 = (latestQuote2 - previousQuote2) / previousQuote2;
        return Double.compare(v1, v2);
    }));
    recordColumns.addColumn(column);
    // change to previous day absolute value
    // $NON-NLS-1$
    column = new Column("changeonpreviousamount", Messages.ColumnChangeOnPreviousAmount, SWT.RIGHT, 60);
    column.setMenuLabel(Messages.ColumnChangeOnPrevious_MenuLabelAmount);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.CalculatedQuote, element -> {
        Optional<Pair<SecurityPrice, SecurityPrice>> previous = ((SecurityPerformanceRecord) element).getSecurity().getLatestTwoSecurityPrices();
        if (previous.isPresent()) {
            double latestQuote = previous.get().getLeft().getValue();
            double previousQuote = previous.get().getRight().getValue();
            return (long) (latestQuote - previousQuote);
        } else {
            return null;
        }
    }, element -> {
        Optional<Pair<SecurityPrice, SecurityPrice>> previous = ((SecurityPerformanceRecord) element).getSecurity().getLatestTwoSecurityPrices();
        if (previous.isPresent()) {
            return // $NON-NLS-1$
            Messages.ColumnLatestPrice + ": " + MessageFormat.format(Messages.TooltipQuoteAtDate, Values.Quote.format(previous.get().getLeft().getValue()), Values.Date.format(previous.get().getLeft().getDate())) + // //$NON-NLS-1$
            "\n" + Messages.ColumnPreviousPrice + // $NON-NLS-1$
            ": " + MessageFormat.format(Messages.TooltipQuoteAtDate, Values.Quote.format(previous.get().getRight().getValue()), Values.Date.format(previous.get().getRight().getDate()));
        } else {
            return null;
        }
    }));
    column.setSorter(ColumnViewerSorter.create((o1, o2) -> {
        // NOSONAR
        Optional<Pair<SecurityPrice, SecurityPrice>> previous1 = ((SecurityPerformanceRecord) o1).getSecurity().getLatestTwoSecurityPrices();
        Optional<Pair<SecurityPrice, SecurityPrice>> previous2 = ((SecurityPerformanceRecord) o2).getSecurity().getLatestTwoSecurityPrices();
        if (!previous1.isPresent() && !previous2.isPresent())
            return 0;
        if (!previous1.isPresent() && previous2.isPresent())
            return -1;
        if (previous1.isPresent() && !previous2.isPresent())
            return 1;
        double latestQuote1 = previous1.get().getLeft().getValue();
        double previousQuote1 = previous1.get().getRight().getValue();
        double v1 = latestQuote1 - previousQuote1;
        double latestQuote2 = previous2.get().getLeft().getValue();
        double previousQuote2 = previous2.get().getRight().getValue();
        double v2 = latestQuote2 - previousQuote2;
        return Double.compare(v1, v2);
    }));
    recordColumns.addColumn(column);
    // market value
    // $NON-NLS-1$
    column = new Column("mv", Messages.ColumnMarketValue, SWT.RIGHT, 75);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Money.format(((SecurityPerformanceRecord) r).getMarketValue(), getClient().getBaseCurrency());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "marketValue"));
    recordColumns.addColumn(column);
    // fees paid
    // $NON-NLS-1$
    column = new Column("fees", Messages.ColumnFees, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnFees_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Money.format(((SecurityPerformanceRecord) r).getFees(), getClient().getBaseCurrency());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fees"));
    column.setVisible(false);
    recordColumns.addColumn(column);
    // taxes paid
    // $NON-NLS-1$
    column = new Column("taxes", Messages.ColumnTaxes, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Money.format(((SecurityPerformanceRecord) r).getTaxes(), getClient().getBaseCurrency());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "taxes"));
    column.setVisible(false);
    recordColumns.addColumn(column);
    // isin
    column = new IsinColumn();
    column.getEditingSupport().addListener(new TouchClientListener(getClient()));
    column.setVisible(false);
    recordColumns.addColumn(column);
    // ticker
    column = new SymbolColumn();
    column.getEditingSupport().addListener(new TouchClientListener(getClient()));
    column.setVisible(false);
    recordColumns.addColumn(column);
    // wkn
    column = new WknColumn();
    column.getEditingSupport().addListener(new TouchClientListener(getClient()));
    column.setVisible(false);
    recordColumns.addColumn(column);
    // note
    column = new NoteColumn();
    column.getEditingSupport().addListener(new TouchClientListener(getClient()));
    column.setVisible(false);
    recordColumns.addColumn(column);
}
Also used : NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) DND(org.eclipse.swt.dnd.DND) ReportingPeriodListener(name.abuchen.portfolio.ui.util.ReportingPeriodDropDown.ReportingPeriodListener) WknColumn(name.abuchen.portfolio.ui.views.columns.WknColumn) TradesPane(name.abuchen.portfolio.ui.views.panes.TradesPane) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) CopyPasteSupport(name.abuchen.portfolio.ui.util.viewers.CopyPasteSupport) TextUtil(name.abuchen.portfolio.util.TextUtil) Composite(org.eclipse.swt.widgets.Composite) MoneyTrailToolTipSupport(name.abuchen.portfolio.ui.util.viewers.MoneyTrailToolTipSupport) Interval(name.abuchen.portfolio.util.Interval) TouchClientListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.TouchClientListener) UIConstants(name.abuchen.portfolio.ui.UIConstants) Pair(name.abuchen.portfolio.util.Pair) AbstractFinanceView(name.abuchen.portfolio.ui.editor.AbstractFinanceView) IStylingEngine(org.eclipse.e4.ui.services.IStylingEngine) Separator(org.eclipse.jface.action.Separator) ClientFilter(name.abuchen.portfolio.snapshot.filter.ClientFilter) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) Predicate(java.util.function.Predicate) SelectionService(name.abuchen.portfolio.ui.selection.SelectionService) DateLabelProvider(name.abuchen.portfolio.ui.util.viewers.DateLabelProvider) Set(java.util.Set) Security(name.abuchen.portfolio.model.Security) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) SecurityPerformanceRecord(name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord) Collectors(java.util.stream.Collectors) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) Transfer(org.eclipse.swt.dnd.Transfer) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) SymbolColumn(name.abuchen.portfolio.ui.views.columns.SymbolColumn) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) DropDown(name.abuchen.portfolio.ui.util.DropDown) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) Optional(java.util.Optional) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) MarkDirtyClientListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.MarkDirtyClientListener) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IMenuListener(org.eclipse.jface.action.IMenuListener) CalculationLineItemPane(name.abuchen.portfolio.ui.views.panes.CalculationLineItemPane) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) ClientFilterMenu(name.abuchen.portfolio.ui.util.ClientFilterMenu) Images(name.abuchen.portfolio.ui.Images) SecurityPriceChartPane(name.abuchen.portfolio.ui.views.panes.SecurityPriceChartPane) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) SecurityPerformanceSnapshot(name.abuchen.portfolio.snapshot.security.SecurityPerformanceSnapshot) MessageFormat(com.ibm.icu.text.MessageFormat) Messages(name.abuchen.portfolio.ui.Messages) ReportingPeriodDropDown(name.abuchen.portfolio.ui.util.ReportingPeriodDropDown) InformationPanePage(name.abuchen.portfolio.ui.views.panes.InformationPanePage) Taxonomy(name.abuchen.portfolio.model.Taxonomy) MoneyColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.MoneyColorLabelProvider) NumberColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.NumberColorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) ToolTip(org.eclipse.jface.window.ToolTip) Control(org.eclipse.swt.widgets.Control) WknColumn(name.abuchen.portfolio.ui.views.columns.WknColumn) SymbolColumn(name.abuchen.portfolio.ui.views.columns.SymbolColumn) Optional(java.util.Optional) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) SecurityPerformanceRecord(name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) WknColumn(name.abuchen.portfolio.ui.views.columns.WknColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) SymbolColumn(name.abuchen.portfolio.ui.views.columns.SymbolColumn) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) TouchClientListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.TouchClientListener) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn)

Example 2 with Pair

use of name.abuchen.portfolio.util.Pair in project portfolio by buchen.

the class StatementOfAssetsView method addButtons.

@Override
protected void addButtons(final ToolBarManager toolBar) {
    DropDown dropDown = new DropDown(getClient().getBaseCurrency());
    Function<CurrencyUnit, Action> asAction = unit -> {
        Action action = new SimpleAction(unit.getLabel(), a -> {
            dropDown.setLabel(unit.getCurrencyCode());
            getClient().setBaseCurrency(unit.getCurrencyCode());
        });
        action.setChecked(getClient().getBaseCurrency().equals(unit.getCurrencyCode()));
        return action;
    };
    dropDown.setMenuListener(manager -> {
        // put list of favorite units on top
        getClient().getUsedCurrencies().forEach(unit -> manager.add(asAction.apply(unit)));
        // add a separator marker
        manager.add(new Separator());
        // then all available units
        List<Pair<String, List<CurrencyUnit>>> available = CurrencyUnit.getAvailableCurrencyUnitsGrouped();
        for (Pair<String, List<CurrencyUnit>> pair : available) {
            MenuManager submenu = new MenuManager(pair.getLeft());
            manager.add(submenu);
            pair.getRight().forEach(unit -> submenu.add(asAction.apply(unit)));
        }
    });
    toolBar.add(dropDown);
    currencyChangeListener = e -> dropDown.setLabel(e.getNewValue().toString());
    // $NON-NLS-1$
    getClient().addPropertyChangeListener("baseCurrency", currencyChangeListener);
    addCalendarButton(toolBar);
    this.clientFilter = new ClientFilterDropDown(getClient(), getPreferenceStore(), StatementOfAssetsView.class.getSimpleName(), filter -> notifyModelUpdated());
    toolBar.add(clientFilter);
    Action export = new SimpleAction(null, action -> new TableViewerCSVExporter(assetViewer.getTableViewer()).export(// $NON-NLS-1$
    Messages.LabelStatementOfAssets + ".csv"));
    export.setImageDescriptor(Images.EXPORT.descriptor());
    export.setToolTipText(Messages.MenuExportData);
    toolBar.add(export);
    toolBar.add(new DropDown(Messages.MenuShowHideColumns, Images.CONFIG, SWT.NONE, manager -> assetViewer.menuAboutToShow(manager)));
}
Also used : Values(name.abuchen.portfolio.money.Values) Client(name.abuchen.portfolio.model.Client) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) TradeCalendarManager(name.abuchen.portfolio.util.TradeCalendarManager) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) Images(name.abuchen.portfolio.ui.Images) SecurityPriceChartPane(name.abuchen.portfolio.ui.views.panes.SecurityPriceChartPane) TradesPane(name.abuchen.portfolio.ui.views.panes.TradesPane) Function(java.util.function.Function) Inject(javax.inject.Inject) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) SecurityEventsPane(name.abuchen.portfolio.ui.views.panes.SecurityEventsPane) InformationPanePage(name.abuchen.portfolio.ui.views.panes.InformationPanePage) UIConstants(name.abuchen.portfolio.ui.UIConstants) Pair(name.abuchen.portfolio.util.Pair) AbstractFinanceView(name.abuchen.portfolio.ui.editor.AbstractFinanceView) TradeCalendar(name.abuchen.portfolio.util.TradeCalendar) ClientFilterDropDown(name.abuchen.portfolio.ui.util.ClientFilterDropDown) Separator(org.eclipse.jface.action.Separator) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) MenuManager(org.eclipse.jface.action.MenuManager) HistoricalPricesDataQualityPane(name.abuchen.portfolio.ui.views.panes.HistoricalPricesDataQualityPane) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) HistoricalPricesPane(name.abuchen.portfolio.ui.views.panes.HistoricalPricesPane) DateSelectionDialog(name.abuchen.portfolio.ui.dialogs.DateSelectionDialog) 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) DropDown(name.abuchen.portfolio.ui.util.DropDown) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) TransactionsPane(name.abuchen.portfolio.ui.views.panes.TransactionsPane) ToolBarManager(org.eclipse.jface.action.ToolBarManager) Optional(java.util.Optional) Platform(org.eclipse.core.runtime.Platform) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) Control(org.eclipse.swt.widgets.Control) CurrencyUnit(name.abuchen.portfolio.money.CurrencyUnit) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Action(org.eclipse.jface.action.Action) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) ClientFilterDropDown(name.abuchen.portfolio.ui.util.ClientFilterDropDown) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ClientFilterDropDown(name.abuchen.portfolio.ui.util.ClientFilterDropDown) DropDown(name.abuchen.portfolio.ui.util.DropDown) List(java.util.List) Separator(org.eclipse.jface.action.Separator) Pair(name.abuchen.portfolio.util.Pair)

Example 3 with Pair

use of name.abuchen.portfolio.util.Pair in project portfolio by buchen.

the class SecuritiesTable method addDeltaColumn.

private // NOSONAR
void addDeltaColumn() {
    Column column;
    // $NON-NLS-1$
    column = new Column("5", Messages.ColumnChangeOnPrevious, SWT.RIGHT, 80);
    column.setMenuLabel(Messages.ColumnChangeOnPrevious_MenuLabel);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, element -> {
        Optional<Pair<SecurityPrice, SecurityPrice>> previous = ((Security) element).getLatestTwoSecurityPrices();
        if (previous.isPresent()) {
            double latestQuote = previous.get().getLeft().getValue();
            double previousQuote = previous.get().getRight().getValue();
            return (latestQuote - previousQuote) / previousQuote;
        } else {
            return null;
        }
    }, element -> {
        Optional<Pair<SecurityPrice, SecurityPrice>> previous = ((Security) element).getLatestTwoSecurityPrices();
        if (previous.isPresent()) {
            return // $NON-NLS-1$
            Messages.ColumnLatestPrice + ": " + MessageFormat.format(Messages.TooltipQuoteAtDate, Values.Quote.format(previous.get().getLeft().getValue()), Values.Date.format(previous.get().getLeft().getDate())) + // //$NON-NLS-1$
            "\n" + Messages.ColumnPreviousPrice + // $NON-NLS-1$
            ": " + MessageFormat.format(Messages.TooltipQuoteAtDate, Values.Quote.format(previous.get().getRight().getValue()), Values.Date.format(previous.get().getRight().getDate()));
        } else {
            return null;
        }
    }));
    column.setSorter(ColumnViewerSorter.create((o1, o2) -> {
        // NOSONAR
        Optional<Pair<SecurityPrice, SecurityPrice>> previous1 = ((Security) o1).getLatestTwoSecurityPrices();
        Optional<Pair<SecurityPrice, SecurityPrice>> previous2 = ((Security) o2).getLatestTwoSecurityPrices();
        if (!previous1.isPresent() && !previous2.isPresent())
            return 0;
        if (!previous1.isPresent() && previous2.isPresent())
            return -1;
        if (previous1.isPresent() && !previous2.isPresent())
            return 1;
        double latestQuote1 = previous1.get().getLeft().getValue();
        double previousQuote1 = previous1.get().getRight().getValue();
        double v1 = (latestQuote1 - previousQuote1) / previousQuote1;
        double latestQuote2 = previous2.get().getLeft().getValue();
        double previousQuote2 = previous2.get().getRight().getValue();
        double v2 = (latestQuote2 - previousQuote2) / previousQuote2;
        return Double.compare(v1, v2);
    }));
    support.addColumn(column);
}
Also used : ReportingPeriodColumnOptions(name.abuchen.portfolio.ui.util.viewers.ReportingPeriodColumnOptions) Client(name.abuchen.portfolio.model.Client) DND(org.eclipse.swt.dnd.DND) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) PortfolioReportNet(name.abuchen.portfolio.online.impl.PortfolioReportNet) CopyPasteSupport(name.abuchen.portfolio.ui.util.viewers.CopyPasteSupport) Matcher(java.util.regex.Matcher) StockSplitWizard(name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) KeyEvent(org.eclipse.swt.events.KeyEvent) Interval(name.abuchen.portfolio.util.Interval) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Separator(org.eclipse.jface.action.Separator) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) MenuManager(org.eclipse.jface.action.MenuManager) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) Transfer(org.eclipse.swt.dnd.Transfer) OptionLabelProvider(name.abuchen.portfolio.ui.util.viewers.OptionLabelProvider) Window(org.eclipse.jface.window.Window) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) Colors(name.abuchen.portfolio.ui.util.Colors) SymbolColumn(name.abuchen.portfolio.ui.views.columns.SymbolColumn) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) SWT(org.eclipse.swt.SWT) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) ConfirmActionWithSelection(name.abuchen.portfolio.ui.util.ConfirmActionWithSelection) BooleanEditingSupport(name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport) InputDialog(org.eclipse.jface.dialogs.InputDialog) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) Images(name.abuchen.portfolio.ui.Images) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ArrayList(java.util.ArrayList) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Messages(name.abuchen.portfolio.ui.Messages) InvestmentPlanDialog(name.abuchen.portfolio.ui.dialogs.transactions.InvestmentPlanDialog) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Taxonomy(name.abuchen.portfolio.model.Taxonomy) NumberColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.NumberColorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) QuoteQualityMetrics(name.abuchen.portfolio.snapshot.QuoteQualityMetrics) Shell(org.eclipse.swt.widgets.Shell) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) IOException(java.io.IOException) UpdateQuotesJob(name.abuchen.portfolio.ui.jobs.UpdateQuotesJob) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) ToolTip(org.eclipse.jface.window.ToolTip) TableViewer(org.eclipse.jface.viewers.TableViewer) BiFunction(java.util.function.BiFunction) WknColumn(name.abuchen.portfolio.ui.views.columns.WknColumn) ImportFromFileDropAdapter(name.abuchen.portfolio.ui.dnd.ImportFromFileDropAdapter) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) ImportFromURLDropAdapter(name.abuchen.portfolio.ui.dnd.ImportFromURLDropAdapter) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) Factory(name.abuchen.portfolio.online.Factory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Pair(name.abuchen.portfolio.util.Pair) AbstractFinanceView(name.abuchen.portfolio.ui.editor.AbstractFinanceView) DateLabelProvider(name.abuchen.portfolio.ui.util.viewers.DateLabelProvider) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) LogoManager(name.abuchen.portfolio.ui.util.LogoManager) List(java.util.List) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) CustomEventWizard(name.abuchen.portfolio.ui.wizards.events.CustomEventWizard) LocalDate(java.time.LocalDate) Watchlist(name.abuchen.portfolio.model.Watchlist) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) Optional(java.util.Optional) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ResultItem(name.abuchen.portfolio.online.SecuritySearchProvider.ResultItem) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) Function(java.util.function.Function) MessageFormat(java.text.MessageFormat) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Action(org.eclipse.jface.action.Action) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Menu(org.eclipse.swt.widgets.Menu) Optional(java.util.Optional) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) SymbolColumn(name.abuchen.portfolio.ui.views.columns.SymbolColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) WknColumn(name.abuchen.portfolio.ui.views.columns.WknColumn) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice)

Example 4 with Pair

use of name.abuchen.portfolio.util.Pair in project portfolio by buchen.

the class SecuritiesTable method addDeltaAmountColumn.

private // NOSONAR
void addDeltaAmountColumn() {
    Column column;
    // $NON-NLS-1$
    column = new Column("changeonpreviousamount", Messages.ColumnChangeOnPreviousAmount, SWT.RIGHT, 80);
    column.setMenuLabel(Messages.ColumnChangeOnPrevious_MenuLabelAmount);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.CalculatedQuote, element -> {
        Optional<Pair<SecurityPrice, SecurityPrice>> previous = ((Security) element).getLatestTwoSecurityPrices();
        if (previous.isPresent()) {
            double latestQuote = previous.get().getLeft().getValue();
            double previousQuote = previous.get().getRight().getValue();
            return (long) (latestQuote - previousQuote);
        } else {
            return null;
        }
    }, element -> {
        Optional<Pair<SecurityPrice, SecurityPrice>> previous = ((Security) element).getLatestTwoSecurityPrices();
        if (previous.isPresent()) {
            return // $NON-NLS-1$
            Messages.ColumnLatestPrice + ": " + MessageFormat.format(Messages.TooltipQuoteAtDate, Values.Quote.format(previous.get().getLeft().getValue()), Values.Date.format(previous.get().getLeft().getDate())) + // //$NON-NLS-1$
            "\n" + Messages.ColumnPreviousPrice + // $NON-NLS-1$
            ": " + MessageFormat.format(Messages.TooltipQuoteAtDate, Values.Quote.format(previous.get().getRight().getValue()), Values.Date.format(previous.get().getRight().getDate()));
        } else {
            return null;
        }
    }));
    column.setSorter(ColumnViewerSorter.create((o1, o2) -> {
        // NOSONAR
        Optional<Pair<SecurityPrice, SecurityPrice>> previous1 = ((Security) o1).getLatestTwoSecurityPrices();
        Optional<Pair<SecurityPrice, SecurityPrice>> previous2 = ((Security) o2).getLatestTwoSecurityPrices();
        if (!previous1.isPresent() && !previous2.isPresent())
            return 0;
        if (!previous1.isPresent() && previous2.isPresent())
            return -1;
        if (previous1.isPresent() && !previous2.isPresent())
            return 1;
        double latestQuote1 = previous1.get().getLeft().getValue();
        double previousQuote1 = previous1.get().getRight().getValue();
        double v1 = latestQuote1 - previousQuote1;
        double latestQuote2 = previous2.get().getLeft().getValue();
        double previousQuote2 = previous2.get().getRight().getValue();
        double v2 = latestQuote2 - previousQuote2;
        return Double.compare(v1, v2);
    }));
    support.addColumn(column);
}
Also used : ReportingPeriodColumnOptions(name.abuchen.portfolio.ui.util.viewers.ReportingPeriodColumnOptions) Client(name.abuchen.portfolio.model.Client) DND(org.eclipse.swt.dnd.DND) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) PortfolioReportNet(name.abuchen.portfolio.online.impl.PortfolioReportNet) CopyPasteSupport(name.abuchen.portfolio.ui.util.viewers.CopyPasteSupport) Matcher(java.util.regex.Matcher) StockSplitWizard(name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) KeyEvent(org.eclipse.swt.events.KeyEvent) Interval(name.abuchen.portfolio.util.Interval) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Separator(org.eclipse.jface.action.Separator) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) MenuManager(org.eclipse.jface.action.MenuManager) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) Transfer(org.eclipse.swt.dnd.Transfer) OptionLabelProvider(name.abuchen.portfolio.ui.util.viewers.OptionLabelProvider) Window(org.eclipse.jface.window.Window) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) Colors(name.abuchen.portfolio.ui.util.Colors) SymbolColumn(name.abuchen.portfolio.ui.views.columns.SymbolColumn) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) SWT(org.eclipse.swt.SWT) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) ConfirmActionWithSelection(name.abuchen.portfolio.ui.util.ConfirmActionWithSelection) BooleanEditingSupport(name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport) InputDialog(org.eclipse.jface.dialogs.InputDialog) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) Images(name.abuchen.portfolio.ui.Images) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ArrayList(java.util.ArrayList) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Messages(name.abuchen.portfolio.ui.Messages) InvestmentPlanDialog(name.abuchen.portfolio.ui.dialogs.transactions.InvestmentPlanDialog) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Taxonomy(name.abuchen.portfolio.model.Taxonomy) NumberColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.NumberColorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) QuoteQualityMetrics(name.abuchen.portfolio.snapshot.QuoteQualityMetrics) Shell(org.eclipse.swt.widgets.Shell) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) IOException(java.io.IOException) UpdateQuotesJob(name.abuchen.portfolio.ui.jobs.UpdateQuotesJob) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) ToolTip(org.eclipse.jface.window.ToolTip) TableViewer(org.eclipse.jface.viewers.TableViewer) BiFunction(java.util.function.BiFunction) WknColumn(name.abuchen.portfolio.ui.views.columns.WknColumn) ImportFromFileDropAdapter(name.abuchen.portfolio.ui.dnd.ImportFromFileDropAdapter) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) ImportFromURLDropAdapter(name.abuchen.portfolio.ui.dnd.ImportFromURLDropAdapter) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) Factory(name.abuchen.portfolio.online.Factory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Pair(name.abuchen.portfolio.util.Pair) AbstractFinanceView(name.abuchen.portfolio.ui.editor.AbstractFinanceView) DateLabelProvider(name.abuchen.portfolio.ui.util.viewers.DateLabelProvider) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) LogoManager(name.abuchen.portfolio.ui.util.LogoManager) List(java.util.List) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) CustomEventWizard(name.abuchen.portfolio.ui.wizards.events.CustomEventWizard) LocalDate(java.time.LocalDate) Watchlist(name.abuchen.portfolio.model.Watchlist) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) Optional(java.util.Optional) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ResultItem(name.abuchen.portfolio.online.SecuritySearchProvider.ResultItem) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) Function(java.util.function.Function) MessageFormat(java.text.MessageFormat) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Action(org.eclipse.jface.action.Action) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Menu(org.eclipse.swt.widgets.Menu) Optional(java.util.Optional) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) SymbolColumn(name.abuchen.portfolio.ui.views.columns.SymbolColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) WknColumn(name.abuchen.portfolio.ui.views.columns.WknColumn) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice)

Example 5 with Pair

use of name.abuchen.portfolio.util.Pair in project portfolio by buchen.

the class TimelineChartToolTip method createComposite.

@Override
protected void createComposite(Composite parent) {
    final Composite container = new Composite(parent, SWT.NONE);
    RowLayout layout = new RowLayout(SWT.VERTICAL);
    layout.center = true;
    container.setLayout(layout);
    Composite data = new Composite(container, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(data);
    Label left = new Label(data, SWT.NONE);
    left.setText(categoryEnabled ? getChart().getAxisSet().getXAxis(0).getTitle().getText() : Messages.ColumnDate);
    Label right = new Label(data, SWT.NONE);
    right.setText(formatXAxisData(getFocusedObject()));
    List<Pair<ISeries, Double>> values = computeValues(getChart().getSeriesSet().getSeries());
    if (reverseLabels)
        Collections.reverse(values);
    if (isAltPressed())
        Collections.sort(values, (l, r) -> r.getValue().compareTo(l.getValue()));
    for (Pair<ISeries, Double> value : values) {
        ISeries series = value.getKey();
        Color color = series instanceof ILineSeries ? ((ILineSeries) series).getLineColor() : ((IBarSeries) series).getBarColor();
        ColoredLabel cl = new ColoredLabel(data, SWT.NONE);
        cl.setBackdropColor(color);
        cl.setText(series.getId());
        GridDataFactory.fillDefaults().grab(true, false).applyTo(cl);
        right = new Label(data, SWT.RIGHT);
        DecimalFormat valueFormat = overrideValueFormat.getOrDefault(series.getId(), defaultValueFormat);
        right.setText(valueFormat.format(value.getRight()));
        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(right);
    }
    Object focus = getFocusedObject();
    extraInfoProvider.forEach(provider -> provider.accept(container, focus));
    Label hint = new Label(data, SWT.NONE);
    hint.setText(Messages.TooltipHintPressAlt);
    hint.setFont(this.resourceManager.createFont(FontDescriptor.createFrom(data.getFont()).increaseHeight(-3).withStyle(SWT.ITALIC)));
    GridDataFactory.fillDefaults().span(2, 1).applyTo(hint);
}
Also used : Arrays(java.util.Arrays) Values(name.abuchen.portfolio.money.Values) Date(java.util.Date) IAxis(org.swtchart.IAxis) HashMap(java.util.HashMap) JFaceResources(org.eclipse.jface.resource.JFaceResources) ISeries(org.swtchart.ISeries) Function(java.util.function.Function) Event(org.eclipse.swt.widgets.Event) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Chart(org.swtchart.Chart) Calendar(java.util.Calendar) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) ILineSeries(org.swtchart.ILineSeries) Pair(name.abuchen.portfolio.util.Pair) FontDescriptor(org.eclipse.jface.resource.FontDescriptor) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) ColoredLabel(name.abuchen.portfolio.ui.util.swt.ColoredLabel) DecimalFormat(java.text.DecimalFormat) Set(java.util.Set) IBarSeries(org.swtchart.IBarSeries) ZoneId(java.time.ZoneId) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) List(java.util.List) RowLayout(org.eclipse.swt.layout.RowLayout) Color(org.eclipse.swt.graphics.Color) SWT(org.eclipse.swt.SWT) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) Collections(java.util.Collections) Label(org.eclipse.swt.widgets.Label) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) ILineSeries(org.swtchart.ILineSeries) DecimalFormat(java.text.DecimalFormat) ColoredLabel(name.abuchen.portfolio.ui.util.swt.ColoredLabel) Label(org.eclipse.swt.widgets.Label) ISeries(org.swtchart.ISeries) RowLayout(org.eclipse.swt.layout.RowLayout) ColoredLabel(name.abuchen.portfolio.ui.util.swt.ColoredLabel) Pair(name.abuchen.portfolio.util.Pair)

Aggregations

Pair (name.abuchen.portfolio.util.Pair)12 ArrayList (java.util.ArrayList)8 LocalDate (java.time.LocalDate)7 List (java.util.List)6 Values (name.abuchen.portfolio.money.Values)6 Messages (name.abuchen.portfolio.ui.Messages)6 SWT (org.eclipse.swt.SWT)6 Client (name.abuchen.portfolio.model.Client)5 Composite (org.eclipse.swt.widgets.Composite)5 Optional (java.util.Optional)4 Function (java.util.function.Function)4 Security (name.abuchen.portfolio.model.Security)4 Images (name.abuchen.portfolio.ui.Images)4 AbstractFinanceView (name.abuchen.portfolio.ui.editor.AbstractFinanceView)4 Column (name.abuchen.portfolio.ui.util.viewers.Column)4 ColumnViewerSorter (name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter)4 CopyPasteSupport (name.abuchen.portfolio.ui.util.viewers.CopyPasteSupport)4 ShowHideColumnHelper (name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper)4 Interval (name.abuchen.portfolio.util.Interval)4 Action (org.eclipse.jface.action.Action)4