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);
}
Aggregations