Search in sources :

Example 46 with Column

use of name.abuchen.portfolio.ui.util.viewers.Column 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);
    });
}
Also used : NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) Arrays(java.util.Arrays) DND(org.eclipse.swt.dnd.DND) Classification(name.abuchen.portfolio.model.Classification) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) UIConstants(name.abuchen.portfolio.ui.UIConstants) Separator(org.eclipse.jface.action.Separator) Predicate(java.util.function.Predicate) MenuManager(org.eclipse.jface.action.MenuManager) Set(java.util.Set) Security(name.abuchen.portfolio.model.Security) UUID(java.util.UUID) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ExchangeRate(name.abuchen.portfolio.money.ExchangeRate) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) Transfer(org.eclipse.swt.dnd.Transfer) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) Colors(name.abuchen.portfolio.ui.util.Colors) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TransferData(org.eclipse.swt.dnd.TransferData) DragSourceAdapter(org.eclipse.swt.dnd.DragSourceAdapter) ContextMenu(name.abuchen.portfolio.ui.util.ContextMenu) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) InvestmentVehicle(name.abuchen.portfolio.model.InvestmentVehicle) BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ViewerDropAdapter(org.eclipse.jface.viewers.ViewerDropAdapter) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Messages(name.abuchen.portfolio.ui.Messages) TreeSelection(org.eclipse.jface.viewers.TreeSelection) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) LinkedList(java.util.LinkedList) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) Viewer(org.eclipse.jface.viewers.Viewer) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) Action(org.eclipse.jface.action.Action) TreeViewerCSVExporter(name.abuchen.portfolio.ui.util.TreeViewerCSVExporter) Preference(org.eclipse.e4.core.di.extensions.Preference) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Named(name.abuchen.portfolio.model.Named) StringJoiner(java.util.StringJoiner) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) ToolTip(org.eclipse.jface.window.ToolTip) Collections(java.util.Collections) Control(org.eclipse.swt.widgets.Control) Assignment(name.abuchen.portfolio.model.Classification.Assignment) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) ExchangeRate(name.abuchen.portfolio.money.ExchangeRate) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter)

Example 47 with Column

use of name.abuchen.portfolio.ui.util.viewers.Column in project portfolio by buchen.

the class DefinitionViewer method addColumns.

@Override
protected void addColumns(ShowHideColumnHelper support) {
    addDimensionColumn(support);
    // $NON-NLS-1$
    Column column = new Column("color", Messages.ColumnColor, SWT.LEFT, 60);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return null;
        }

        @Override
        public Color getBackground(Object element) {
            TaxonomyNode node = (TaxonomyNode) element;
            if (node.isClassification())
                return getRenderer().getColorFor((TaxonomyNode) element);
            else
                return null;
        }
    });
    support.addColumn(column);
    addActualColumns(support);
    addAdditionalColumns(support);
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Column(name.abuchen.portfolio.ui.util.viewers.Column) Color(org.eclipse.swt.graphics.Color)

Aggregations

Column (name.abuchen.portfolio.ui.util.viewers.Column)47 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)43 NoteColumn (name.abuchen.portfolio.ui.views.columns.NoteColumn)38 Image (org.eclipse.swt.graphics.Image)33 Composite (org.eclipse.swt.widgets.Composite)32 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)31 TableViewer (org.eclipse.jface.viewers.TableViewer)31 ShowHideColumnHelper (name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper)30 Security (name.abuchen.portfolio.model.Security)26 Values (name.abuchen.portfolio.money.Values)24 Messages (name.abuchen.portfolio.ui.Messages)24 IMenuManager (org.eclipse.jface.action.IMenuManager)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 SWT (org.eclipse.swt.SWT)24 Images (name.abuchen.portfolio.ui.Images)23 ColumnViewerSorter (name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter)23 Color (org.eclipse.swt.graphics.Color)23 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)21 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)21 NameColumn (name.abuchen.portfolio.ui.views.columns.NameColumn)20