use of name.abuchen.portfolio.model.Annotated in project portfolio by buchen.
the class ReviewExtractedItemsPage method addColumns.
private void addColumns(TableViewer viewer, TableColumnLayout layout) {
TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnStatus);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public Image getImage(ExtractedEntry element) {
Images image = null;
switch(element.getMaxCode()) {
case WARNING:
image = Images.WARNING;
break;
case ERROR:
image = Images.ERROR;
break;
case OK:
default:
}
return image != null ? image.image() : null;
}
@Override
public String getText(ExtractedEntry entry) {
// $NON-NLS-1$
return "";
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(22, true));
column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnDate);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
LocalDateTime date = entry.getItem().getDate();
return date != null ? Values.DateTime.format(date) : null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnTransactionType);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
return entry.getItem().getTypeInformation();
}
@Override
public Image getImage(ExtractedEntry entry) {
Annotated subject = entry.getItem().getSubject();
if (subject instanceof AccountTransaction)
return Images.ACCOUNT.image();
else if (subject instanceof PortfolioTransaction)
return Images.PORTFOLIO.image();
else if (subject instanceof Security)
return Images.SECURITY.image();
else if (subject instanceof BuySellEntry)
return Images.PORTFOLIO.image();
else if (subject instanceof AccountTransferEntry)
return Images.ACCOUNT.image();
else if (subject instanceof PortfolioTransferEntry)
return Images.PORTFOLIO.image();
else
return null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(100, true));
column = new TableViewerColumn(viewer, SWT.RIGHT);
column.getColumn().setText(Messages.ColumnAmount);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
Money amount = entry.getItem().getAmount();
return amount != null ? Values.Money.format(amount) : null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
column = new TableViewerColumn(viewer, SWT.RIGHT);
column.getColumn().setText(Messages.ColumnShares);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
return Values.Share.formatNonZero(entry.getItem().getShares());
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
column = new TableViewerColumn(viewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnSecurity);
column.setLabelProvider(new // NOSONAR
FormattedLabelProvider() {
@Override
public String getText(ExtractedEntry entry) {
Security security = entry.getItem().getSecurity();
return security != null ? security.getName() : null;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(250, true));
}
Aggregations