Search in sources :

Example 41 with Column

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);
}
Also used : Values(name.abuchen.portfolio.money.Values) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) MessageFormat(java.text.MessageFormat) Inject(javax.inject.Inject) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) TransactionPair(name.abuchen.portfolio.model.TransactionPair) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) Unit(name.abuchen.portfolio.model.Transaction.Unit) IMenuManager(org.eclipse.jface.action.IMenuManager) SWT(org.eclipse.swt.SWT) ToolTip(org.eclipse.jface.window.ToolTip) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Control(org.eclipse.swt.widgets.Control) TransactionPair(name.abuchen.portfolio.model.TransactionPair) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Column(name.abuchen.portfolio.ui.util.viewers.Column) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Image(org.eclipse.swt.graphics.Image) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider)

Example 42 with 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);
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) 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)

Example 43 with 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);
}
Also used : ReportingPeriodColumnOptions(name.abuchen.portfolio.ui.util.viewers.ReportingPeriodColumnOptions) Adaptable(name.abuchen.portfolio.model.Adaptable) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) Arrays(java.util.Arrays) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) DND(org.eclipse.swt.dnd.DND) SecurityPosition(name.abuchen.portfolio.snapshot.SecurityPosition) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) Classification(name.abuchen.portfolio.model.Classification) AttributeComparator(name.abuchen.portfolio.ui.util.AttributeComparator) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) MoneyCollectors(name.abuchen.portfolio.money.MoneyCollectors) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) Map(java.util.Map) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) UIConstants(name.abuchen.portfolio.ui.UIConstants) GroupByTaxonomy(name.abuchen.portfolio.snapshot.GroupByTaxonomy) Separator(org.eclipse.jface.action.Separator) Account(name.abuchen.portfolio.model.Account) ClientFilter(name.abuchen.portfolio.snapshot.filter.ClientFilter) MenuManager(org.eclipse.jface.action.MenuManager) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ExchangeRate(name.abuchen.portfolio.money.ExchangeRate) SecurityPerformanceRecord(name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord) Collectors(java.util.stream.Collectors) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) PortfolioSnapshot(name.abuchen.portfolio.snapshot.PortfolioSnapshot) Transfer(org.eclipse.swt.dnd.Transfer) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) Objects(java.util.Objects) OptionLabelProvider(name.abuchen.portfolio.ui.util.viewers.OptionLabelProvider) List(java.util.List) Stream(java.util.stream.Stream) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) PostConstruct(javax.annotation.PostConstruct) Attributable(name.abuchen.portfolio.model.Attributable) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ClientSnapshot(name.abuchen.portfolio.snapshot.ClientSnapshot) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) InvestmentVehicle(name.abuchen.portfolio.model.InvestmentVehicle) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) AssetPosition(name.abuchen.portfolio.snapshot.AssetPosition) HashMap(java.util.HashMap) JFaceResources(org.eclipse.jface.resource.JFaceResources) Function(java.util.function.Function) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) SecurityPerformanceSnapshot(name.abuchen.portfolio.snapshot.security.SecurityPerformanceSnapshot) Annotated(name.abuchen.portfolio.model.Annotated) Messages(name.abuchen.portfolio.ui.Messages) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Font(org.eclipse.swt.graphics.Font) MarkDirtyListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.MarkDirtyListener) Taxonomy(name.abuchen.portfolio.model.Taxonomy) Portfolio(name.abuchen.portfolio.model.Portfolio) FontDescriptor(org.eclipse.jface.resource.FontDescriptor) Shell(org.eclipse.swt.widgets.Shell) Viewer(org.eclipse.jface.viewers.Viewer) AssetCategory(name.abuchen.portfolio.snapshot.AssetCategory) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) Preference(org.eclipse.e4.core.di.extensions.Preference) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Named(name.abuchen.portfolio.model.Named) ToolTip(org.eclipse.jface.window.ToolTip) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) Menu(org.eclipse.swt.widgets.Menu) Comparator(java.util.Comparator) Control(org.eclipse.swt.widgets.Control) Money(name.abuchen.portfolio.money.Money) ReportingPeriodColumnOptions(name.abuchen.portfolio.ui.util.viewers.ReportingPeriodColumnOptions) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) 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) Stream(java.util.stream.Stream)

Example 44 with 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);
    });
}
Also used : ReportingPeriodColumnOptions(name.abuchen.portfolio.ui.util.viewers.ReportingPeriodColumnOptions) Adaptable(name.abuchen.portfolio.model.Adaptable) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) Arrays(java.util.Arrays) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) DND(org.eclipse.swt.dnd.DND) SecurityPosition(name.abuchen.portfolio.snapshot.SecurityPosition) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) Classification(name.abuchen.portfolio.model.Classification) AttributeComparator(name.abuchen.portfolio.ui.util.AttributeComparator) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) MoneyCollectors(name.abuchen.portfolio.money.MoneyCollectors) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) Map(java.util.Map) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) UIConstants(name.abuchen.portfolio.ui.UIConstants) GroupByTaxonomy(name.abuchen.portfolio.snapshot.GroupByTaxonomy) Separator(org.eclipse.jface.action.Separator) Account(name.abuchen.portfolio.model.Account) ClientFilter(name.abuchen.portfolio.snapshot.filter.ClientFilter) MenuManager(org.eclipse.jface.action.MenuManager) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ExchangeRate(name.abuchen.portfolio.money.ExchangeRate) SecurityPerformanceRecord(name.abuchen.portfolio.snapshot.security.SecurityPerformanceRecord) Collectors(java.util.stream.Collectors) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) PortfolioSnapshot(name.abuchen.portfolio.snapshot.PortfolioSnapshot) Transfer(org.eclipse.swt.dnd.Transfer) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) Objects(java.util.Objects) OptionLabelProvider(name.abuchen.portfolio.ui.util.viewers.OptionLabelProvider) List(java.util.List) Stream(java.util.stream.Stream) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) PostConstruct(javax.annotation.PostConstruct) Attributable(name.abuchen.portfolio.model.Attributable) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) LabelOnly(name.abuchen.portfolio.ui.util.LabelOnly) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ClientSnapshot(name.abuchen.portfolio.snapshot.ClientSnapshot) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) InvestmentVehicle(name.abuchen.portfolio.model.InvestmentVehicle) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) AssetPosition(name.abuchen.portfolio.snapshot.AssetPosition) HashMap(java.util.HashMap) JFaceResources(org.eclipse.jface.resource.JFaceResources) Function(java.util.function.Function) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) SecurityPerformanceSnapshot(name.abuchen.portfolio.snapshot.security.SecurityPerformanceSnapshot) Annotated(name.abuchen.portfolio.model.Annotated) Messages(name.abuchen.portfolio.ui.Messages) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Font(org.eclipse.swt.graphics.Font) MarkDirtyListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.MarkDirtyListener) Taxonomy(name.abuchen.portfolio.model.Taxonomy) Portfolio(name.abuchen.portfolio.model.Portfolio) FontDescriptor(org.eclipse.jface.resource.FontDescriptor) Shell(org.eclipse.swt.widgets.Shell) Viewer(org.eclipse.jface.viewers.Viewer) AssetCategory(name.abuchen.portfolio.snapshot.AssetCategory) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) Preference(org.eclipse.e4.core.di.extensions.Preference) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Named(name.abuchen.portfolio.model.Named) ToolTip(org.eclipse.jface.window.ToolTip) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) Menu(org.eclipse.swt.widgets.Menu) Comparator(java.util.Comparator) Control(org.eclipse.swt.widgets.Control) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) 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) MarkDirtyListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.MarkDirtyListener)

Example 45 with 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);
}
Also used : 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) Color(org.eclipse.swt.graphics.Color) Image(org.eclipse.swt.graphics.Image) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport)

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