Search in sources :

Example 6 with SharesLabelProvider

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

the class TransactionsTab method addColumns.

private void addColumns(ShowHideColumnHelper support) {
    Column column = new Column(Messages.ColumnDate, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return Values.DateTime.format(((TransactionPair<?>) element).getTransaction().getDateTime());
        }
    });
    ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getDateTime()).attachTo(column, SWT.UP);
    support.addColumn(column);
    column = new Column(Messages.ColumnSecurity, SWT.None, 250);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((TransactionPair<?>) element).getTransaction().getSecurity().getName();
        }
    });
    ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getSecurity().getName()).attachTo(column);
    support.addColumn(column);
    column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
    column.setLabelProvider(new SharesLabelProvider() {

        @Override
        public Long getValue(Object element) {
            return ((TransactionPair<?>) element).getTransaction().getShares();
        }
    });
    ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getShares()).attachTo(column);
    support.addColumn(column);
    column = new Column(Messages.ColumnGrossValue, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return Values.Money.format(((AccountTransaction) ((TransactionPair<?>) element).getTransaction()).getGrossValue(), client.getBaseCurrency());
        }
    });
    ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getMonetaryAmount()).attachTo(column);
    support.addColumn(column);
    column = new Column(Messages.ColumnTaxes, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return Values.Money.format(((TransactionPair<?>) element).getTransaction().getUnitSum(Unit.Type.TAX), client.getBaseCurrency());
        }
    });
    ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getUnitSum(Unit.Type.TAX)).attachTo(column);
    support.addColumn(column);
    column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return Values.Money.format(((TransactionPair<?>) element).getTransaction().getMonetaryAmount(), client.getBaseCurrency());
        }
    });
    ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getMonetaryAmount()).attachTo(column);
    support.addColumn(column);
    column = new Column(Messages.ColumnOffsetAccount, SWT.None, 120);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((TransactionPair<?>) element).getOwner().toString();
        }
    });
    ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getOwner().toString()).attachTo(column);
    support.addColumn(column);
    column = new Column(Messages.ColumnNote, SWT.None, 200);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((TransactionPair<?>) element).getTransaction().getNote();
        }

        @Override
        public Image getImage(Object element) {
            String note = ((TransactionPair<?>) element).getTransaction().getNote();
            return note != null && note.length() > 0 ? Images.NOTE.image() : null;
        }
    });
    ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getNote()).attachTo(column);
    support.addColumn(column);
}
Also used : Values(name.abuchen.portfolio.money.Values) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) MessageFormat(java.text.MessageFormat) Inject(javax.inject.Inject) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) TransactionPair(name.abuchen.portfolio.model.TransactionPair) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) Unit(name.abuchen.portfolio.model.Transaction.Unit) IMenuManager(org.eclipse.jface.action.IMenuManager) SWT(org.eclipse.swt.SWT) ToolTip(org.eclipse.jface.window.ToolTip) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Control(org.eclipse.swt.widgets.Control) TransactionPair(name.abuchen.portfolio.model.TransactionPair) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Column(name.abuchen.portfolio.ui.util.viewers.Column) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Image(org.eclipse.swt.graphics.Image) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider)

Aggregations

SharesLabelProvider (name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider)6 Column (name.abuchen.portfolio.ui.util.viewers.Column)5 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)4 Color (org.eclipse.swt.graphics.Color)4 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)3 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)3 ValueEditingSupport (name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport)3 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 Image (org.eclipse.swt.graphics.Image)3 Composite (org.eclipse.swt.widgets.Composite)3 Inject (javax.inject.Inject)2 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)2 Unit (name.abuchen.portfolio.model.Transaction.Unit)2 TransactionPair (name.abuchen.portfolio.model.TransactionPair)2 Values (name.abuchen.portfolio.money.Values)2 Images (name.abuchen.portfolio.ui.Images)2 Messages (name.abuchen.portfolio.ui.Messages)2 SecuritySelection (name.abuchen.portfolio.ui.selection.SecuritySelection)2 TableViewerCSVExporter (name.abuchen.portfolio.ui.util.TableViewerCSVExporter)2