Search in sources :

Example 1 with DividendInitialTransaction

use of name.abuchen.portfolio.snapshot.security.DividendInitialTransaction 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)

Aggregations

AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)1 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)1 Transaction (name.abuchen.portfolio.model.Transaction)1 CurrencyConverterImpl (name.abuchen.portfolio.money.CurrencyConverterImpl)1 DividendFinalTransaction (name.abuchen.portfolio.snapshot.security.DividendFinalTransaction)1 DividendInitialTransaction (name.abuchen.portfolio.snapshot.security.DividendInitialTransaction)1 DividendTransaction (name.abuchen.portfolio.snapshot.security.DividendTransaction)1 SashLayout (name.abuchen.portfolio.ui.util.swt.SashLayout)1 SashLayoutData (name.abuchen.portfolio.ui.util.swt.SashLayoutData)1 Column (name.abuchen.portfolio.ui.util.viewers.Column)1 ShowHideColumnHelper (name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper)1 AttributeColumn (name.abuchen.portfolio.ui.views.columns.AttributeColumn)1 IsinColumn (name.abuchen.portfolio.ui.views.columns.IsinColumn)1 NameColumn (name.abuchen.portfolio.ui.views.columns.NameColumn)1 NoteColumn (name.abuchen.portfolio.ui.views.columns.NoteColumn)1 TaxonomyColumn (name.abuchen.portfolio.ui.views.columns.TaxonomyColumn)1 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1