use of name.abuchen.portfolio.ui.util.viewers.Column 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);
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class AbstractNodeTreeViewer method addActualColumns.
protected void addActualColumns(ShowHideColumnHelper support) {
// $NON-NLS-1$
Column column = new Column("act%", Messages.ColumnActualPercent, SWT.RIGHT, 60);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
// actual %
// --> root is compared to target = total assets
long actual = node.getActual().getAmount();
long base = node.getParent() == null ? node.getActual().getAmount() : node.getParent().getActual().getAmount();
if (base == 0)
return Values.Percent.format(0d);
else
return Values.Percent.format((double) actual / (double) base);
}
});
support.addColumn(column);
// $NON-NLS-1$
column = new Column("act", Messages.ColumnActualValue, SWT.RIGHT, 100);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
return Values.Money.format(node.getActual(), getModel().getCurrencyCode());
}
});
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class StatementOfAssetsViewer method addPerformanceColumns.
private void addPerformanceColumns(List<ReportingPeriod> options) {
ReportingPeriodLabelProvider labelProvider;
// $NON-NLS-1$
Column column = new Column("ttwror", Messages.ColumnTWROR, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getTrueTimeWeightedRateOfReturn);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnTTWROR_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnTWROR_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("irr", Messages.ColumnIRR, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getIrr);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnIRRPerformanceOption, options));
column.setMenuLabel(Messages.ColumnIRR_MenuLabel);
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
Function<Stream<Object>, Object> sum = elements -> elements.map(e -> (Money) e).collect(MoneyCollectors.sum(client.getBaseCurrency()));
// $NON-NLS-1$
column = new Column("capitalgains", Messages.ColumnCapitalGains, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getCapitalGainsOnHoldings, sum, true);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnCapitalGains_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGains_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgains%", Messages.ColumnCapitalGainsPercent, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getCapitalGainsOnHoldingsPercent);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnCapitalGainsPercent_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGainsPercent_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgainsmvavg", Messages.ColumnCapitalGainsMovingAverage, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getCapitalGainsOnHoldingsMovingAverage, sum, true);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnCapitalGainsMovingAverage_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGainsMovingAverage_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("capitalgainsmvavg%", Messages.ColumnCapitalGainsMovingAveragePercent, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getCapitalGainsOnHoldingsMovingAveragePercent);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnCapitalGainsMovingAveragePercent_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnCapitalGainsMovingAveragePercent_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("delta", Messages.ColumnAbsolutePerformance_MenuLabel, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getDelta, sum, true);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnAbsolutePerformance_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnAbsolutePerformance_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
// $NON-NLS-1$
column = new Column("delta%", Messages.ColumnAbsolutePerformancePercent_MenuLabel, SWT.RIGHT, 80);
labelProvider = new ReportingPeriodLabelProvider(SecurityPerformanceRecord::getDeltaPercent);
column.setOptions(new ReportingPeriodColumnOptions(Messages.ColumnAbsolutePerformancePercent_Option, options));
column.setGroupLabel(Messages.GroupLabelPerformance);
column.setDescription(Messages.ColumnAbsolutePerformancePercent_Description);
column.setLabelProvider(labelProvider);
column.setSorter(ColumnViewerSorter.create(new ElementComparator(labelProvider)));
column.setVisible(false);
support.addColumn(column);
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class StatementOfAssetsViewer method addAttributeColumns.
private void addAttributeColumns() {
//
client.getSettings().getAttributeTypes().filter(//
a -> a.supports(Security.class)).forEach(attribute -> {
Column column = new AttributeColumn(attribute);
column.setVisible(false);
if (column.getSorter() != null)
column.getSorter().wrap(ElementComparator::new);
column.getEditingSupport().addListener(new MarkDirtyListener(this.owner));
support.addColumn(column);
});
}
use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.
the class AbstractNodeTreeViewer method addWeightColumn.
private // NOSONAR
void addWeightColumn(// NOSONAR
ShowHideColumnHelper support) {
Column column;
// $NON-NLS-1$
column = new Column("weight", Messages.ColumnWeight, SWT.RIGHT, 70);
column.setDescription(Messages.ColumnWeight_Description);
column.setLabelProvider(new // NOSONAR
ColumnLabelProvider() {
@Override
public String getText(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
return node.isAssignment() ? Values.Weight.format(node.getWeight()) : null;
}
@Override
public Color getForeground(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
return node.isAssignment() && getModel().hasWeightError(node) ? Display.getDefault().getSystemColor(SWT.COLOR_BLACK) : null;
}
@Override
public Color getBackground(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
return node.isAssignment() && getModel().hasWeightError(node) ? Colors.WARNING : null;
}
@Override
public Image getImage(Object element) {
TaxonomyNode node = (TaxonomyNode) element;
return node.isAssignment() && getModel().hasWeightError(node) ? Images.QUICKFIX.image() : null;
}
});
new // $NON-NLS-1$
ValueEditingSupport(// $NON-NLS-1$
TaxonomyNode.class, // $NON-NLS-1$
"weight", // $NON-NLS-1$
Values.Weight) {
@Override
public boolean canEdit(Object element) {
if (((TaxonomyNode) element).isUnassignedCategory())
return false;
if (((TaxonomyNode) element).isClassification())
return false;
return super.canEdit(element);
}
}.addListener(this::onWeightModified).attachTo(column);
support.addColumn(column);
}
Aggregations