column.setLabelProvider(new TransactionLabelProvider()
{
@Override
public String getText(Object element)
{
PortfolioTransaction t = (PortfolioTransaction) element;
return t.getSecurity() != null ? String.valueOf(t.getSecurity()) : null;
}
});
ColumnViewerSorter.create(PortfolioTransaction.class, "security").attachTo(column); //$NON-NLS-1$
List<Security> securities = new ArrayList<Security>(owner.getClient().getSecurities());
Collections.sort(securities, new Security.ByName());
new ListEditingSupport(PortfolioTransaction.class, "security", securities).addListener(this).attachTo(column); //$NON-NLS-1$
support.addColumn(column);
column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
column.setLabelProvider(new SharesLabelProvider()
{
private TransactionLabelProvider colors = new TransactionLabelProvider();
@Override
public Long getValue(Object element)
{
return ((PortfolioTransaction) element).getShares();
}
@Override
public Color getForeground(Object element)
{
return colors.getForeground(element);
}
@Override
public Color getBackground(Object element)
{
return colors.getBackground(element);
}
});
ColumnViewerSorter.create(PortfolioTransaction.class, "shares").attachTo(column); //$NON-NLS-1$
new ValueEditingSupport(PortfolioTransaction.class, "shares", Values.Share).addListener(this).attachTo(column); //$NON-NLS-1$
support.addColumn(column);
column = new Column(Messages.ColumnQuote, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider()
{
@Override
public String getText(Object element)
{
PortfolioTransaction t = (PortfolioTransaction) element;
return t.getShares() != 0 ? Values.Amount.format(t.getActualPurchasePrice()) : null;
}
});
ColumnViewerSorter.create(PortfolioTransaction.class, "actualPurchasePrice").attachTo(column); //$NON-NLS-1$
support.addColumn(column);
column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider()
{
@Override
public String getText(Object element)
{
return Values.Amount.format(((PortfolioTransaction) element).getLumpSumPrice());
}
});
ColumnViewerSorter.create(PortfolioTransaction.class, "lumpSumPrice").attachTo(column); //$NON-NLS-1$
support.addColumn(column);
column = new Column(Messages.ColumnFees, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider()
{
@Override
public String getText(Object element)
{
return Values.Amount.format(((PortfolioTransaction) element).getFees());
}
});
ColumnViewerSorter.create(PortfolioTransaction.class, "fees").attachTo(column); //$NON-NLS-1$
new ValueEditingSupport(PortfolioTransaction.class, "fees", Values.Amount).addListener(this).attachTo(column); //$NON-NLS-1$
support.addColumn(column);
column = new Column(Messages.ColumnTaxes, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider()
{
@Override
public String getText(Object element)
{
return Values.Amount.format(((PortfolioTransaction) element).getTaxes());
}
});
ColumnViewerSorter.create(PortfolioTransaction.class, "taxes").attachTo(column); //$NON-NLS-1$
new ValueEditingSupport(PortfolioTransaction.class, "taxes", Values.Amount).addListener(this).attachTo(column); //$NON-NLS-1$
support.addColumn(column);
column = new Column(Messages.ColumnLumpSumPrice, SWT.RIGHT, 80);
column.setLabelProvider(new TransactionLabelProvider()
{
@Override
public String getText(Object element)
{
return Values.Amount.format(((PortfolioTransaction) element).getAmount());
}
});
ColumnViewerSorter.create(PortfolioTransaction.class, "amount").attachTo(column); //$NON-NLS-1$
new ValueEditingSupport(PortfolioTransaction.class, "amount", Values.Amount).addListener(this).attachTo(column); //$NON-NLS-1$
support.addColumn(column);
column = new Column(Messages.ColumnOffsetAccount, SWT.None, 120);
column.setLabelProvider(new TransactionLabelProvider()
{
@Override
public String getText(Object e)
{
PortfolioTransaction t = (PortfolioTransaction) e;
return t.getCrossEntry() != null ? t.getCrossEntry().getCrossEntity(t).toString() : null;
}
});
support.addColumn(column);
column = new Column(Messages.ColumnNote, SWT.None, 200);