Search in sources :

Example 1 with Column

use of name.abuchen.portfolio.ui.util.viewers.Column 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();
    recordColumns.addColumn(column);
    // cost value - fifo
    // $NON-NLS-1$
    column = new Column("pv", Messages.ColumnPurchaseValue, SWT.RIGHT, 75);
    column.setDescription(Messages.ColumnPurchaseValue_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Money.format(((SecurityPerformanceRecord) r).getFifoCost(), getClient().getBaseCurrency());
        }
    });
    // $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);
    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);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Quote.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);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Quote.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()));
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "fifoCostPerSharesHeld"));
    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 MarkDirtyListener(this));
    column.setVisible(false);
    recordColumns.addColumn(column);
    // note
    column = new NoteColumn();
    column.getEditingSupport().addListener(new MarkDirtyListener(this));
    column.setVisible(false);
    recordColumns.addColumn(column);
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) 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) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) MarkDirtyListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.MarkDirtyListener) SecurityPerformanceRecord(name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn)

Example 2 with Column

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

the class SecuritiesPerformanceView method createBottomTable.

@Override
protected // NOSONAR
void createBottomTable(// NOSONAR
Composite parent) {
    Composite sash = new Composite(parent, SWT.NONE);
    sash.setLayout(new SashLayout(sash, SWT.HORIZONTAL | SWT.END));
    // folder
    CTabFolder folder = new CTabFolder(sash, SWT.BORDER);
    CTabItem item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabChart);
    Composite chartComposite = new Composite(folder, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(2).spacing(0, 0).applyTo(chartComposite);
    item.setControl(chartComposite);
    chart = new SecuritiesChart(chartComposite, getClient(), new CurrencyConverterImpl(factory, getClient().getBaseCurrency()));
    latest = new SecurityDetailsViewer(sash, SWT.BORDER, getClient());
    latest.getControl().setLayoutData(new SashLayoutData(SWTHelper.getPackedWidth(latest.getControl())));
    item = new CTabItem(folder, SWT.NONE);
    item.setText(Messages.SecurityTabTransactions);
    Composite container = new Composite(folder, SWT.NONE);
    item.setControl(container);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    folder.setSelection(0);
    transactions = new TableViewer(container, SWT.FULL_SELECTION);
    ShowHideColumnHelper support = new ShowHideColumnHelper(// $NON-NLS-1$
    SecuritiesPerformanceView.class.getSimpleName() + "@bottom4", // $NON-NLS-1$
    getPreferenceStore(), transactions, layout);
    // date
    Column column = new Column(Messages.ColumnDate, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            Transaction t = (Transaction) e;
            return Values.DateTime.format(t.getDateTime());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(Transaction.class, "dateTime"), SWT.DOWN);
    support.addColumn(column);
    // transaction type
    column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof PortfolioTransaction)
                return ((PortfolioTransaction) t).getType().toString();
            else if (t instanceof AccountTransaction)
                return ((AccountTransaction) t).getType().toString();
            else if (t instanceof DividendTransaction)
                return AccountTransaction.Type.DIVIDENDS.toString();
            else
                return Messages.LabelQuote;
        }
    });
    support.addColumn(column);
    // shares
    column = new Column(Messages.ColumnShares, SWT.None, 80);
    column.setLabelProvider(new // NOSONAR
    SharesLabelProvider() {

        @Override
        public // NOSONAR
        Long getValue(// NOSONAR
        Object t) {
            if (t instanceof PortfolioTransaction)
                return ((PortfolioTransaction) t).getShares();
            else if (t instanceof DividendInitialTransaction)
                return ((DividendInitialTransaction) t).getPosition().getShares();
            else if (t instanceof DividendFinalTransaction)
                return ((DividendFinalTransaction) t).getPosition().getShares();
            else if (t instanceof DividendTransaction)
                return ((DividendTransaction) t).getShares() != 0L ? ((DividendTransaction) t).getShares() : null;
            else
                return null;
        }
    });
    support.addColumn(column);
    // dividend amount
    column = new Column(Messages.ColumnDividendPayment, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnGrossDividend);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return Values.Money.format(((DividendTransaction) t).getGrossValue(), getClient().getBaseCurrency());
            else
                return null;
        }
    });
    support.addColumn(column);
    // dividend per share
    column = new Column(Messages.ColumnDividendPerShare, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return Values.AmountFraction.formatNonZero(((DividendTransaction) t).getDividendPerShare());
            else
                return null;
        }
    });
    support.addColumn(column);
    // dividend per share
    column = new Column(Messages.ColumnPersonalDividendYield, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnPersonalDividendYield_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYield());
            else
                return null;
        }
    });
    support.addColumn(column);
    // dividend per share (moving average)
    column = new Column(Messages.ColumnPersonalDividendYieldMovingAverage, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnPersonalDividendYieldMovingAverage_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return Values.Percent2.formatNonZero(((DividendTransaction) t).getPersonalDividendYieldMovingAverage());
            else
                return null;
        }
    });
    support.addColumn(column);
    // einstandskurs / bewertung
    column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof DividendTransaction)
                return null;
            else
                return Values.Money.format(((Transaction) t).getMonetaryAmount(), getClient().getBaseCurrency());
        }
    });
    support.addColumn(column);
    // purchase quote
    column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof PortfolioTransaction) {
                PortfolioTransaction p = (PortfolioTransaction) t;
                return Values.Quote.format(p.getGrossPricePerShare(), getClient().getBaseCurrency());
            } else
                return null;
        }
    });
    support.addColumn(column);
    // gegenkonto
    column = new Column(Messages.ColumnAccount, SWT.None, 120);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object t) {
            if (t instanceof PortfolioTransaction) {
                PortfolioTransaction p = (PortfolioTransaction) t;
                return p.getCrossEntry() != null ? p.getCrossEntry().getCrossOwner(p).toString() : null;
            } else if (t instanceof DividendTransaction) {
                return ((DividendTransaction) t).getAccount().getName();
            } else {
                return null;
            }
        }
    });
    support.addColumn(column);
    // note
    // $NON-NLS-1$
    column = new Column("note", Messages.ColumnNote, SWT.LEFT, 22);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return ((Transaction) r).getNote();
        }

        @Override
        public Image getImage(Object r) {
            String note = ((Transaction) r).getNote();
            return note != null && note.length() > 0 ? Images.NOTE.image() : null;
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(Transaction.class, "note"));
    support.addColumn(column);
    support.createColumns();
    transactions.getTable().setHeaderVisible(true);
    transactions.getTable().setLinesVisible(true);
    transactions.setContentProvider(ArrayContentProvider.getInstance());
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Image(org.eclipse.swt.graphics.Image) CTabItem(org.eclipse.swt.custom.CTabItem) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) 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) DividendFinalTransaction(name.abuchen.portfolio.snapshot.security.DividendFinalTransaction) DividendInitialTransaction(name.abuchen.portfolio.snapshot.security.DividendInitialTransaction) SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Composite(org.eclipse.swt.widgets.Composite) DividendTransaction(name.abuchen.portfolio.snapshot.security.DividendTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) Transaction(name.abuchen.portfolio.model.Transaction) DividendInitialTransaction(name.abuchen.portfolio.snapshot.security.DividendInitialTransaction) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) DividendTransaction(name.abuchen.portfolio.snapshot.security.DividendTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) DividendFinalTransaction(name.abuchen.portfolio.snapshot.security.DividendFinalTransaction) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 3 with Column

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

the class SecuritiesPerformanceView method createRiskColumns.

private void createRiskColumns() {
    // $NON-NLS-1$
    Column column = new Column("mdd", Messages.ColumnMaxDrawdown, SWT.RIGHT, 60);
    column.setMenuLabel(Messages.LabelMaxDrawdown);
    column.setGroupLabel(Messages.LabelRiskIndicators);
    column.setVisible(false);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Percent2.formatNonZero(((SecurityPerformanceRecord) r).getMaxDrawdown());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "maxDrawdown"));
    recordColumns.addColumn(column);
    // $NON-NLS-1$
    column = new Column("mddduration", Messages.ColumnMaxDrawdownDuration, SWT.RIGHT, 60);
    column.setMenuLabel(Messages.LabelMaxDrawdownDuration);
    column.setGroupLabel(Messages.LabelRiskIndicators);
    column.setVisible(false);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return String.valueOf(((SecurityPerformanceRecord) r).getMaxDrawdownDuration());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "maxDrawdownDuration"));
    recordColumns.addColumn(column);
    // $NON-NLS-1$
    column = new Column("vola", Messages.LabelVolatility, SWT.RIGHT, 80);
    column.setGroupLabel(Messages.LabelRiskIndicators);
    column.setVisible(false);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Percent2.format(((SecurityPerformanceRecord) r).getVolatility());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "volatility"));
    recordColumns.addColumn(column);
    // $NON-NLS-1$
    column = new Column("semivola", Messages.LabelSemiVolatility, SWT.RIGHT, 80);
    column.setGroupLabel(Messages.LabelRiskIndicators);
    column.setVisible(false);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object r) {
            return Values.Percent2.format(((SecurityPerformanceRecord) r).getSemiVolatility());
        }
    });
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "semiVolatility"));
    recordColumns.addColumn(column);
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) 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) SecurityPerformanceRecord(name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord)

Example 4 with Column

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

the class SecuritiesPerformanceView method createAdditionalColumns.

private void createAdditionalColumns() {
    for (Taxonomy taxonomy : getClient().getTaxonomies()) {
        Column column = new TaxonomyColumn(taxonomy);
        column.setVisible(false);
        recordColumns.addColumn(column);
    }
    // 
    getClient().getSettings().getAttributeTypes().filter(// 
    a -> a.supports(Security.class)).forEach(attribute -> {
        Column column = new AttributeColumn(attribute);
        column.setVisible(false);
        column.setEditingSupport(null);
        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) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) DND(org.eclipse.swt.dnd.DND) ToolBar(org.eclipse.swt.widgets.ToolBar) ReportingPeriodListener(name.abuchen.portfolio.ui.util.ReportingPeriodDropDown.ReportingPeriodListener) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Separator(org.eclipse.jface.action.Separator) ClientFilter(name.abuchen.portfolio.snapshot.filter.ClientFilter) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) Predicate(java.util.function.Predicate) SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) 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) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) DividendInitialTransaction(name.abuchen.portfolio.snapshot.security.DividendInitialTransaction) 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) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ClientFilterMenu(name.abuchen.portfolio.ui.util.ClientFilterMenu) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) 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) MarkDirtyListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.MarkDirtyListener) Taxonomy(name.abuchen.portfolio.model.Taxonomy) DividendTransaction(name.abuchen.portfolio.snapshot.security.DividendTransaction) MoneyColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.MoneyColorLabelProvider) NumberColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.NumberColorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) DividendFinalTransaction(name.abuchen.portfolio.snapshot.security.DividendFinalTransaction) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) CTabItem(org.eclipse.swt.custom.CTabItem) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolTip(org.eclipse.jface.window.ToolTip) SWTHelper(name.abuchen.portfolio.ui.util.SWTHelper) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) Taxonomy(name.abuchen.portfolio.model.Taxonomy) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) 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) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn)

Example 5 with Column

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

the class SecuritiesPerformanceView method addPerformanceColumns.

private void addPerformanceColumns() {
    // $NON-NLS-1$
    Column column = new Column("twror", Messages.ColumnTWROR, SWT.RIGHT, 80);
    column.setGroupLabel(Messages.GroupLabelPerformance);
    column.setMenuLabel(Messages.ColumnTWROR_Description);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getTrueTimeWeightedRateOfReturn()));
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "trueTimeWeightedRateOfReturn"));
    recordColumns.addColumn(column);
    // internal rate of return
    // $NON-NLS-1$
    column = new Column("izf", Messages.ColumnIRR, SWT.RIGHT, 80);
    column.setGroupLabel(Messages.GroupLabelPerformance);
    column.setMenuLabel(Messages.ColumnIRR_MenuLabel);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getIrr()));
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "irr"));
    recordColumns.addColumn(column);
    // $NON-NLS-1$
    column = new Column("capitalgains", Messages.ColumnCapitalGains, SWT.RIGHT, 80);
    column.setGroupLabel(Messages.GroupLabelPerformance);
    column.setDescription(Messages.ColumnCapitalGains_Description);
    column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getCapitalGainsOnHoldings(), getClient().getBaseCurrency()));
    column.setVisible(false);
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldings"));
    recordColumns.addColumn(column);
    // $NON-NLS-1$
    column = new Column("capitalgains%", Messages.ColumnCapitalGainsPercent, SWT.RIGHT, 80);
    column.setGroupLabel(Messages.GroupLabelPerformance);
    column.setDescription(Messages.ColumnCapitalGainsPercent_Description);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getCapitalGainsOnHoldingsPercent()));
    column.setVisible(false);
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsPercent"));
    recordColumns.addColumn(column);
    // $NON-NLS-1$
    column = new Column("capitalgainsmvavg", Messages.ColumnCapitalGainsMovingAverage, SWT.RIGHT, 80);
    column.setGroupLabel(Messages.GroupLabelPerformance);
    column.setMenuLabel(Messages.ColumnCapitalGainsMovingAverage_MenuLabel);
    column.setDescription(Messages.ColumnCapitalGainsMovingAverage_Description);
    column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getCapitalGainsOnHoldingsMovingAverage(), getClient().getBaseCurrency()));
    column.setVisible(false);
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsMovingAverage"));
    recordColumns.addColumn(column);
    // $NON-NLS-1$
    column = new Column("capitalgainsmvavg%", Messages.ColumnCapitalGainsMovingAveragePercent, SWT.RIGHT, 80);
    column.setGroupLabel(Messages.GroupLabelPerformance);
    column.setMenuLabel(Messages.ColumnCapitalGainsMovingAveragePercent_MenuLabel);
    column.setDescription(Messages.ColumnCapitalGainsMovingAveragePercent_Description);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getCapitalGainsOnHoldingsMovingAveragePercent()));
    column.setVisible(false);
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "capitalGainsOnHoldingsMovingAveragePercent"));
    recordColumns.addColumn(column);
    // delta
    // $NON-NLS-1$
    column = new Column("delta", Messages.ColumnAbsolutePerformance, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnAbsolutePerformance_Description);
    column.setMenuLabel(Messages.ColumnAbsolutePerformance_MenuLabel);
    column.setGroupLabel(Messages.GroupLabelPerformance);
    column.setLabelProvider(new MoneyColorLabelProvider(element -> ((SecurityPerformanceRecord) element).getDelta(), getClient().getBaseCurrency()));
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "delta"));
    recordColumns.addColumn(column);
    // delta percent
    // $NON-NLS-1$
    column = new Column("delta%", Messages.ColumnAbsolutePerformancePercent, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnAbsolutePerformancePercent_Description);
    column.setMenuLabel(Messages.ColumnAbsolutePerformancePercent_MenuLabel);
    column.setGroupLabel(Messages.GroupLabelPerformance);
    column.setLabelProvider(new NumberColorLabelProvider<>(Values.Percent2, r -> ((SecurityPerformanceRecord) r).getDeltaPercent()));
    // $NON-NLS-1$
    column.setSorter(ColumnViewerSorter.create(SecurityPerformanceRecord.class, "deltaPercent"));
    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) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) DND(org.eclipse.swt.dnd.DND) ToolBar(org.eclipse.swt.widgets.ToolBar) ReportingPeriodListener(name.abuchen.portfolio.ui.util.ReportingPeriodDropDown.ReportingPeriodListener) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) Separator(org.eclipse.jface.action.Separator) ClientFilter(name.abuchen.portfolio.snapshot.filter.ClientFilter) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) Predicate(java.util.function.Predicate) SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) 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) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) DividendInitialTransaction(name.abuchen.portfolio.snapshot.security.DividendInitialTransaction) 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) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ClientFilterMenu(name.abuchen.portfolio.ui.util.ClientFilterMenu) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) 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) MarkDirtyListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.MarkDirtyListener) Taxonomy(name.abuchen.portfolio.model.Taxonomy) DividendTransaction(name.abuchen.portfolio.snapshot.security.DividendTransaction) MoneyColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.MoneyColorLabelProvider) NumberColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.NumberColorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) DividendFinalTransaction(name.abuchen.portfolio.snapshot.security.DividendFinalTransaction) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) CTabItem(org.eclipse.swt.custom.CTabItem) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolTip(org.eclipse.jface.window.ToolTip) SWTHelper(name.abuchen.portfolio.ui.util.SWTHelper) MoneyColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.MoneyColorLabelProvider) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) 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) SecurityPerformanceRecord(name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord)

Aggregations

Column (name.abuchen.portfolio.ui.util.viewers.Column)47 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)43 NoteColumn (name.abuchen.portfolio.ui.views.columns.NoteColumn)38 Image (org.eclipse.swt.graphics.Image)33 Composite (org.eclipse.swt.widgets.Composite)32 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)31 TableViewer (org.eclipse.jface.viewers.TableViewer)31 ShowHideColumnHelper (name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper)30 Security (name.abuchen.portfolio.model.Security)26 Values (name.abuchen.portfolio.money.Values)24 Messages (name.abuchen.portfolio.ui.Messages)24 IMenuManager (org.eclipse.jface.action.IMenuManager)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 SWT (org.eclipse.swt.SWT)24 Images (name.abuchen.portfolio.ui.Images)23 ColumnViewerSorter (name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter)23 Color (org.eclipse.swt.graphics.Color)23 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)21 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)21 NameColumn (name.abuchen.portfolio.ui.views.columns.NameColumn)20