Search in sources :

Example 1 with Annotated

use of name.abuchen.portfolio.model.Annotated in project portfolio by buchen.

the class ReviewExtractedItemsPage method addColumns.

private void addColumns(TableViewer viewer, TableColumnLayout layout) {
    TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.ColumnStatus);
    column.setLabelProvider(new // NOSONAR
    FormattedLabelProvider() {

        @Override
        public Image getImage(ExtractedEntry element) {
            Images image = null;
            switch(element.getMaxCode()) {
                case WARNING:
                    image = Images.WARNING;
                    break;
                case ERROR:
                    image = Images.ERROR;
                    break;
                case OK:
                default:
            }
            return image != null ? image.image() : null;
        }

        @Override
        public String getText(ExtractedEntry entry) {
            // $NON-NLS-1$
            return "";
        }
    });
    layout.setColumnData(column.getColumn(), new ColumnPixelData(22, true));
    column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.ColumnDate);
    column.setLabelProvider(new // NOSONAR
    FormattedLabelProvider() {

        @Override
        public String getText(ExtractedEntry entry) {
            LocalDateTime date = entry.getItem().getDate();
            return date != null ? Values.DateTime.format(date) : null;
        }
    });
    layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
    column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.ColumnTransactionType);
    column.setLabelProvider(new // NOSONAR
    FormattedLabelProvider() {

        @Override
        public String getText(ExtractedEntry entry) {
            return entry.getItem().getTypeInformation();
        }

        @Override
        public Image getImage(ExtractedEntry entry) {
            Annotated subject = entry.getItem().getSubject();
            if (subject instanceof AccountTransaction)
                return Images.ACCOUNT.image();
            else if (subject instanceof PortfolioTransaction)
                return Images.PORTFOLIO.image();
            else if (subject instanceof Security)
                return Images.SECURITY.image();
            else if (subject instanceof BuySellEntry)
                return Images.PORTFOLIO.image();
            else if (subject instanceof AccountTransferEntry)
                return Images.ACCOUNT.image();
            else if (subject instanceof PortfolioTransferEntry)
                return Images.PORTFOLIO.image();
            else
                return null;
        }
    });
    layout.setColumnData(column.getColumn(), new ColumnPixelData(100, true));
    column = new TableViewerColumn(viewer, SWT.RIGHT);
    column.getColumn().setText(Messages.ColumnAmount);
    column.setLabelProvider(new // NOSONAR
    FormattedLabelProvider() {

        @Override
        public String getText(ExtractedEntry entry) {
            Money amount = entry.getItem().getAmount();
            return amount != null ? Values.Money.format(amount) : null;
        }
    });
    layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
    column = new TableViewerColumn(viewer, SWT.RIGHT);
    column.getColumn().setText(Messages.ColumnShares);
    column.setLabelProvider(new // NOSONAR
    FormattedLabelProvider() {

        @Override
        public String getText(ExtractedEntry entry) {
            return Values.Share.formatNonZero(entry.getItem().getShares());
        }
    });
    layout.setColumnData(column.getColumn(), new ColumnPixelData(80, true));
    column = new TableViewerColumn(viewer, SWT.NONE);
    column.getColumn().setText(Messages.ColumnSecurity);
    column.setLabelProvider(new // NOSONAR
    FormattedLabelProvider() {

        @Override
        public String getText(ExtractedEntry entry) {
            Security security = entry.getItem().getSecurity();
            return security != null ? security.getName() : null;
        }
    });
    layout.setColumnData(column.getColumn(), new ColumnPixelData(250, true));
}
Also used : LocalDateTime(java.time.LocalDateTime) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Images(name.abuchen.portfolio.ui.Images) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) StyledString(org.eclipse.jface.viewers.StyledString) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Image(org.eclipse.swt.graphics.Image) Security(name.abuchen.portfolio.model.Security) Annotated(name.abuchen.portfolio.model.Annotated) Money(name.abuchen.portfolio.money.Money) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) AccountTransferEntry(name.abuchen.portfolio.model.AccountTransferEntry) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn) PortfolioTransferEntry(name.abuchen.portfolio.model.PortfolioTransferEntry)

Aggregations

LocalDateTime (java.time.LocalDateTime)1 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)1 AccountTransferEntry (name.abuchen.portfolio.model.AccountTransferEntry)1 Annotated (name.abuchen.portfolio.model.Annotated)1 BuySellEntry (name.abuchen.portfolio.model.BuySellEntry)1 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)1 PortfolioTransferEntry (name.abuchen.portfolio.model.PortfolioTransferEntry)1 Security (name.abuchen.portfolio.model.Security)1 Money (name.abuchen.portfolio.money.Money)1 Images (name.abuchen.portfolio.ui.Images)1 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)1 StyledString (org.eclipse.jface.viewers.StyledString)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 Image (org.eclipse.swt.graphics.Image)1