Search in sources :

Example 1 with Line

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));
}
Also used : Line(name.abuchen.portfolio.ui.views.dividends.DividendsViewModel.Line) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) InvestmentVehicle(name.abuchen.portfolio.model.InvestmentVehicle) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Font(org.eclipse.swt.graphics.Font)

Example 2 with Line

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));
}
Also used : Line(name.abuchen.portfolio.ui.views.dividends.DividendsViewModel.Line) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Font(org.eclipse.swt.graphics.Font)

Example 3 with Line

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));
}
Also used : Line(name.abuchen.portfolio.ui.views.dividends.DividendsViewModel.Line) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) InvestmentVehicle(name.abuchen.portfolio.model.InvestmentVehicle) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) Font(org.eclipse.swt.graphics.Font)

Aggregations

Line (name.abuchen.portfolio.ui.views.dividends.DividendsViewModel.Line)3 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)3 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)3 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)3 Font (org.eclipse.swt.graphics.Font)3 InvestmentVehicle (name.abuchen.portfolio.model.InvestmentVehicle)2