use of name.abuchen.portfolio.ui.views.dividends.DividendsViewModel.Line in project portfolio by buchen.
the class DividendsMatrixTab method createMonthColumn.
private void createMonthColumn(TableViewer records, TableColumnLayout layout, LocalDate start, int index) {
TableViewerColumn column = new TableViewerColumn(records, SWT.RIGHT);
column.getColumn().setText(formatter.format(start));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Line line = (DividendsViewModel.Line) element;
return line.getVehicle() != null ? Values.Amount.formatNonZero(line.getValue(index)) : Values.Amount.format(line.getValue(index));
}
@Override
public String getToolTipText(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return TextUtil.tooltip(vehicle != null ? vehicle.getName() : null);
}
@Override
public Font getFont(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return vehicle != null ? null : boldFont;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(50));
}
use of name.abuchen.portfolio.ui.views.dividends.DividendsViewModel.Line in project portfolio by buchen.
the class DividendsMatrixTab method createSumColumn.
protected void createSumColumn(TableViewer records, TableColumnLayout layout) {
TableViewerColumn column;
column = new TableViewerColumn(records, SWT.RIGHT);
column.getColumn().setText(Messages.ColumnSum);
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
DividendsViewModel.Line line = (DividendsViewModel.Line) element;
if (showOnlyOneYear) {
int noOfMonths = Math.min(12, line.getNoOfMonths());
long sum = 0;
for (int ii = 0; ii < noOfMonths; ii++) sum += line.getValue(ii);
return Values.Amount.formatNonZero(sum);
} else {
return Values.Amount.formatNonZero(line.getSum());
}
}
@Override
public Font getFont(Object element) {
return boldFont;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(200));
}
use of name.abuchen.portfolio.ui.views.dividends.DividendsViewModel.Line in project portfolio by buchen.
the class DividendsYearMatrixTab method createYearColumn.
private void createYearColumn(TableViewer records, TableColumnLayout layout, LocalDate start, int index) {
TableViewerColumn column = new TableViewerColumn(records, SWT.RIGHT);
column.getColumn().setText(formatter.format(start));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
Line line = (DividendsViewModel.Line) element;
long value = 0;
for (int ii = index; ii < index + 12 && ii < line.getNoOfMonths(); ii++) value += line.getValue(ii);
return line.getVehicle() != null ? Values.Amount.formatNonZero(value) : Values.Amount.format(value);
}
@Override
public String getToolTipText(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return TextUtil.tooltip(vehicle != null ? vehicle.getName() : null);
}
@Override
public Font getFont(Object element) {
InvestmentVehicle vehicle = ((DividendsViewModel.Line) element).getVehicle();
return vehicle != null ? null : boldFont;
}
});
layout.setColumnData(column.getColumn(), new ColumnPixelData(50));
}
Aggregations