use of name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper in project portfolio by buchen.
the class AttributeListTab method createTab.
@Override
public CTabItem createTab(CTabFolder folder) {
Composite container = new Composite(folder, SWT.NONE);
TableColumnLayout layout = new TableColumnLayout();
container.setLayout(layout);
tableViewer = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI);
ColumnEditingSupport.prepare(tableViewer);
ShowHideColumnHelper support = new ShowHideColumnHelper(AttributeListTab.class.getSimpleName(), preferences, tableViewer, layout);
addColumns(support);
support.createColumns();
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLinesVisible(true);
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setInput(client.getSettings().getAttributeTypes().toArray());
tableViewer.refresh();
new ContextMenu(tableViewer.getTable(), m -> fillContextMenu(m)).hook();
CTabItem item = new CTabItem(folder, SWT.NONE);
item.setText(Messages.AttributeTypeTitle);
item.setControl(container);
return item;
}
use of name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper 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);
});
}
Aggregations