use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class AbstractNodeTreeViewer method addAdditionalColumns.
protected // NOSONAR
void addAdditionalColumns(// NOSONAR
ShowHideColumnHelper support) {
// $NON-NLS-1$
Column column = new Column("exchangeRate", Messages.ColumnExchangeRate, SWT.RIGHT, 80);
column.setGroupLabel(Messages.ColumnForeignCurrencies);
column.setLabelProvider(new // NOSONAR
ColumnLabelProvider() {
@Override
public String getText(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
if (!node.isAssignment())
return null;
String baseCurrency = node.getAssignment().getInvestmentVehicle().getCurrencyCode();
if (baseCurrency == null)
return null;
CurrencyConverter converter = getModel().getCurrencyConverter();
ExchangeRate rate = converter.getRate(LocalDate.now(), baseCurrency);
if (useIndirectQuotation)
rate = rate.inverse();
return Values.ExchangeRate.format(rate.getValue());
}
@Override
public String getToolTipText(Object e) {
String text = getText(e);
if (text == null)
return null;
String term = getModel().getCurrencyConverter().getTermCurrency();
String base = ((TaxonomyNode) e).getAssignment().getInvestmentVehicle().getCurrencyCode();
return text + ' ' + (useIndirectQuotation ? base + '/' + term : term + '/' + base);
}
});
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("actBaseCurrency", Messages.ColumnActualValue + Messages.BaseCurrencyCue, SWT.RIGHT, 100);
column.setDescription(Messages.ColumnActualValueBaseCurrency);
column.setGroupLabel(Messages.ColumnForeignCurrencies);
column.setLabelProvider(new // NOSONAR
ColumnLabelProvider() {
@Override
public String getText(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
if (node.isClassification() || getModel().getCurrencyCode().equals(node.getAssignment().getInvestmentVehicle().getCurrencyCode())) {
return Values.Money.format(node.getActual(), getModel().getCurrencyCode());
} else if (node.getAssignment().getInvestmentVehicle().getCurrencyCode() != null) {
// currency code (e.g. is not an stock market index)
return Values.Money.format(getModel().getCurrencyConverter().with(node.getAssignment().getInvestmentVehicle().getCurrencyCode()).convert(LocalDate.now(), node.getActual()), getModel().getCurrencyCode());
} else {
return null;
}
}
});
column.setVisible(false);
support.addColumn(column);
//
getModel().getClient().getSettings().getAttributeTypes().filter(//
a -> a.supports(Security.class)).forEach(attribute -> {
Column col = new AttributeColumn(attribute);
col.setVisible(false);
col.setSorter(null);
col.getEditingSupport().addListener(this);
support.addColumn(col);
});
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class DefinitionViewer method addColumns.
@Override
protected void addColumns(ShowHideColumnHelper support) {
addDimensionColumn(support);
// $NON-NLS-1$
Column column = new Column("color", Messages.ColumnColor, SWT.LEFT, 60);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return null;
}
@Override
public Color getBackground(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
if (node.isClassification())
return getRenderer().getColorFor((TaxonomyNode) element);
else
return null;
}
});
support.addColumn(column);
addActualColumns(support);
addAdditionalColumns(support);
}
Aggregations