Search in sources :

Example 31 with Column

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

the class SecuritiesTable method addColumnLatestPrice.

private // NOSONAR
void addColumnLatestPrice() {
    // $NON-NLS-1$
    Column column = new Column("4", Messages.ColumnLatest, SWT.RIGHT, 60);
    column.setMenuLabel(Messages.ColumnLatest_MenuLabel);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            Security security = (Security) e;
            SecurityPrice latest = security.getSecurityPrice(LocalDate.now());
            if (latest == null)
                return null;
            if (security.getCurrencyCode() == null)
                return Values.Quote.format(latest.getValue());
            else
                return Values.Quote.format(security.getCurrencyCode(), latest.getValue(), getClient().getBaseCurrency());
        }
    });
    column.setSorter(ColumnViewerSorter.create((o1, o2) -> {
        SecurityPrice p1 = ((Security) o1).getSecurityPrice(LocalDate.now());
        SecurityPrice p2 = ((Security) o2).getSecurityPrice(LocalDate.now());
        if (p1 == null)
            return p2 == null ? 0 : -1;
        if (p2 == null)
            return 1;
        long v1 = p1.getValue();
        long v2 = p2.getValue();
        return v1 > v2 ? 1 : v1 == v2 ? 0 : -1;
    }));
    support.addColumn(column);
}
Also used : ReportingPeriodColumnOptions(name.abuchen.portfolio.ui.util.viewers.ReportingPeriodColumnOptions) Client(name.abuchen.portfolio.model.Client) TableViewer(org.eclipse.jface.viewers.TableViewer) BiFunction(java.util.function.BiFunction) DND(org.eclipse.swt.dnd.DND) SecurityDragListener(name.abuchen.portfolio.ui.dnd.SecurityDragListener) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) StockSplitWizard(name.abuchen.portfolio.ui.wizards.splits.StockSplitWizard) Composite(org.eclipse.swt.widgets.Composite) AbstractFinanceView(name.abuchen.portfolio.ui.AbstractFinanceView) KeyEvent(org.eclipse.swt.events.KeyEvent) Factory(name.abuchen.portfolio.online.Factory) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Separator(org.eclipse.jface.action.Separator) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) MenuManager(org.eclipse.jface.action.MenuManager) Security(name.abuchen.portfolio.model.Security) Display(org.eclipse.swt.widgets.Display) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Collectors(java.util.stream.Collectors) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) Transfer(org.eclipse.swt.dnd.Transfer) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) OptionLabelProvider(name.abuchen.portfolio.ui.util.viewers.OptionLabelProvider) List(java.util.List) UpdateQuotesJob(name.abuchen.portfolio.ui.UpdateQuotesJob) TaxonomyColumn(name.abuchen.portfolio.ui.views.columns.TaxonomyColumn) Colors(name.abuchen.portfolio.ui.util.Colors) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) AttributeColumn(name.abuchen.portfolio.ui.views.columns.AttributeColumn) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) Watchlist(name.abuchen.portfolio.model.Watchlist) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) SecurityTransfer(name.abuchen.portfolio.ui.dnd.SecurityTransfer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) BooleanEditingSupport(name.abuchen.portfolio.ui.util.viewers.BooleanEditingSupport) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) BookmarkMenu(name.abuchen.portfolio.ui.util.BookmarkMenu) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) Function(java.util.function.Function) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn) Messages(name.abuchen.portfolio.ui.Messages) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) Taxonomy(name.abuchen.portfolio.model.Taxonomy) NumberColorLabelProvider(name.abuchen.portfolio.ui.util.viewers.NumberColorLabelProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Shell(org.eclipse.swt.widgets.Shell) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) Menu(org.eclipse.swt.widgets.Menu) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) 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) LatestSecurityPrice(name.abuchen.portfolio.model.LatestSecurityPrice) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) Security(name.abuchen.portfolio.model.Security)

Example 32 with Column

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

the class SecurityListView method createEventsTable.

// //////////////////////////////////////////////////////////////
// tab item: transactions
// //////////////////////////////////////////////////////////////
protected Composite createEventsTable(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    events = new TableViewer(container, SWT.FULL_SELECTION);
    ShowHideColumnHelper support = new // $NON-NLS-1$
    ShowHideColumnHelper(// $NON-NLS-1$
    SecurityListView.class.getSimpleName() + "@events", getPreferenceStore(), events, layout);
    Column column = new Column(Messages.ColumnDate, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return Values.Date.format(((SecurityEvent) element).getDate());
        }
    });
    column.setSorter(ColumnViewerSorter.create(e -> ((SecurityEvent) e).getDate()), SWT.UP);
    support.addColumn(column);
    column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((SecurityEvent) element).getType().toString();
        }
    });
    support.addColumn(column);
    column = new Column(Messages.ColumnDetails, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((SecurityEvent) element).getDetails();
        }
    });
    support.addColumn(column);
    support.createColumns();
    events.getTable().setHeaderVisible(true);
    events.getTable().setLinesVisible(true);
    events.setContentProvider(ArrayContentProvider.getInstance());
    return container;
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) ToolBar(org.eclipse.swt.widgets.ToolBar) TransactionOwner(name.abuchen.portfolio.model.TransactionOwner) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) KeyEvent(org.eclipse.swt.events.KeyEvent) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SearchYahooWizardDialog(name.abuchen.portfolio.ui.wizards.security.SearchYahooWizardDialog) Separator(org.eclipse.jface.action.Separator) Text(org.eclipse.swt.widgets.Text) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) Account(name.abuchen.portfolio.model.Account) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) Predicate(java.util.function.Predicate) SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Security(name.abuchen.portfolio.model.Security) ToolItem(org.eclipse.swt.widgets.ToolItem) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) Dates(name.abuchen.portfolio.util.Dates) Colors(name.abuchen.portfolio.ui.util.Colors) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) Watchlist(name.abuchen.portfolio.model.Watchlist) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) Pattern(java.util.regex.Pattern) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) SecurityEvent(name.abuchen.portfolio.model.SecurityEvent) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) Quote(name.abuchen.portfolio.money.Quote) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) DateEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateEditingSupport) Images(name.abuchen.portfolio.ui.Images) ConvertBuySellToDeliveryAction(name.abuchen.portfolio.ui.views.actions.ConvertBuySellToDeliveryAction) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Messages(name.abuchen.portfolio.ui.Messages) ConvertDeliveryToBuySellAction(name.abuchen.portfolio.ui.views.actions.ConvertDeliveryToBuySellAction) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Portfolio(name.abuchen.portfolio.model.Portfolio) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) TransactionPair(name.abuchen.portfolio.model.TransactionPair) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) CTabItem(org.eclipse.swt.custom.CTabItem) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) Unit(name.abuchen.portfolio.model.Transaction.Unit) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) ToolTip(org.eclipse.jface.window.ToolTip) SWTHelper(name.abuchen.portfolio.ui.util.SWTHelper) Collections(java.util.Collections) PortfolioTransferEntry(name.abuchen.portfolio.model.PortfolioTransferEntry) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) SecurityEvent(name.abuchen.portfolio.model.SecurityEvent) Composite(org.eclipse.swt.widgets.Composite) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 33 with Column

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

the class SecurityListView method createTransactionTable.

// //////////////////////////////////////////////////////////////
// tab item: transactions
// //////////////////////////////////////////////////////////////
protected Composite createTransactionTable(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    transactions = new TableViewer(container, SWT.FULL_SELECTION);
    ColumnViewerToolTipSupport.enableFor(transactions, ToolTip.NO_RECREATE);
    ShowHideColumnHelper support = new ShowHideColumnHelper(// $NON-NLS-1$
    SecurityListView.class.getSimpleName() + "@transactions4", // $NON-NLS-1$
    getPreferenceStore(), // $NON-NLS-1$
    transactions, layout);
    Column column = new Column(Messages.ColumnDate, SWT.None, 100);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return Values.DateTime.format(((TransactionPair<?>) element).getTransaction().getDateTime());
        }
    });
    column.setSorter(ColumnViewerSorter.create((o1, o2) -> ((TransactionPair<?>) o1).getTransaction().getDateTime().compareTo(((TransactionPair<?>) o2).getTransaction().getDateTime())), SWT.UP);
    support.addColumn(column);
    column = new Column(Messages.ColumnTransactionType, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Transaction t = ((TransactionPair<?>) element).getTransaction();
            if (t instanceof PortfolioTransaction)
                return ((PortfolioTransaction) t).getType().toString();
            else if (t instanceof AccountTransaction)
                return ((AccountTransaction) t).getType().toString();
            else
                return null;
        }
    });
    support.addColumn(column);
    column = new Column(Messages.ColumnShares, SWT.RIGHT, 80);
    column.setLabelProvider(new SharesLabelProvider() {

        @Override
        public Long getValue(Object element) {
            Transaction t = ((TransactionPair<?>) element).getTransaction();
            if (t instanceof PortfolioTransaction) {
                return ((PortfolioTransaction) t).getShares();
            } else if (t instanceof AccountTransaction) {
                long shares = ((AccountTransaction) t).getShares();
                return shares != 0 ? shares : null;
            }
            return null;
        }
    });
    support.addColumn(column);
    column = new Column(Messages.ColumnAmount, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Transaction t = ((TransactionPair<?>) element).getTransaction();
            return Values.Money.format(t.getMonetaryAmount(), getClient().getBaseCurrency());
        }
    });
    column.setSorter(ColumnViewerSorter.create((o1, o2) -> {
        long a1 = ((TransactionPair<?>) o1).getTransaction().getAmount();
        long a2 = ((TransactionPair<?>) o2).getTransaction().getAmount();
        return a1 > a2 ? 1 : a1 < a2 ? -1 : 0;
    }));
    support.addColumn(column);
    column = new Column(Messages.ColumnPerShare, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnPerShare_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Transaction t = ((TransactionPair<?>) element).getTransaction();
            if (t instanceof PortfolioTransaction) {
                return Values.Quote.format(((PortfolioTransaction) t).getGrossPricePerShare(), getClient().getBaseCurrency());
            } else if (t instanceof AccountTransaction) {
                long shares = ((AccountTransaction) t).getShares();
                if (shares != 0) {
                    long perShare = Math.round(((AccountTransaction) t).getGrossValueAmount() * Values.Share.divider() * Values.Quote.factorToMoney() / shares);
                    return Values.Quote.format(Quote.of(t.getCurrencyCode(), perShare));
                }
            }
            return null;
        }
    });
    support.addColumn(column);
    column = new Column(Messages.ColumnFees, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnFees_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Transaction t = ((TransactionPair<?>) element).getTransaction();
            return Values.Money.format(t.getUnitSum(Unit.Type.FEE), getClient().getBaseCurrency());
        }
    });
    support.addColumn(column);
    column = new Column(Messages.ColumnTaxes, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnTaxes_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Transaction t = ((TransactionPair<?>) element).getTransaction();
            return Values.Money.format(t.getUnitSum(Unit.Type.TAX), getClient().getBaseCurrency());
        }
    });
    support.addColumn(column);
    column = new Column(Messages.ColumnPortfolio, SWT.NONE, 120);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            TransactionOwner<?> owner = ((TransactionPair<?>) element).getOwner();
            if (owner instanceof Portfolio)
                return owner.toString();
            return null;
        }
    });
    support.addColumn(column);
    column = new Column(Messages.ColumnOffsetAccount, SWT.NONE, 120);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            TransactionPair<?> pair = (TransactionPair<?>) element;
            Transaction t = pair.getTransaction();
            if (t instanceof PortfolioTransaction)
                return t.getCrossEntry() != null ? t.getCrossEntry().getCrossOwner(t).toString() : null;
            else
                return pair.getOwner().toString();
        }
    });
    support.addColumn(column);
    column = new NoteColumn();
    column.setEditingSupport(null);
    support.addColumn(column);
    support.createColumns();
    transactions.getTable().setHeaderVisible(true);
    transactions.getTable().setLinesVisible(true);
    transactions.setContentProvider(ArrayContentProvider.getInstance());
    hookContextMenu(transactions.getControl(), this::transactionMenuAboutToShow);
    hookKeyListener();
    return container;
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) ToolBar(org.eclipse.swt.widgets.ToolBar) TransactionOwner(name.abuchen.portfolio.model.TransactionOwner) ModificationListener(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport.ModificationListener) SecurityTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransactionDialog) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) KeyEvent(org.eclipse.swt.events.KeyEvent) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SearchYahooWizardDialog(name.abuchen.portfolio.ui.wizards.security.SearchYahooWizardDialog) Separator(org.eclipse.jface.action.Separator) Text(org.eclipse.swt.widgets.Text) SecurityTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.SecurityTransferDialog) Account(name.abuchen.portfolio.model.Account) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) Predicate(java.util.function.Predicate) SashLayout(name.abuchen.portfolio.ui.util.swt.SashLayout) Security(name.abuchen.portfolio.model.Security) ToolItem(org.eclipse.swt.widgets.ToolItem) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) PortfolioPart(name.abuchen.portfolio.ui.PortfolioPart) ColumnEditingSupport(name.abuchen.portfolio.ui.util.viewers.ColumnEditingSupport) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) List(java.util.List) Dates(name.abuchen.portfolio.util.Dates) Colors(name.abuchen.portfolio.ui.util.Colors) EditSecurityDialog(name.abuchen.portfolio.ui.wizards.security.EditSecurityDialog) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) Watchlist(name.abuchen.portfolio.model.Watchlist) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) Pattern(java.util.regex.Pattern) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) QuoteFeed(name.abuchen.portfolio.online.QuoteFeed) SecurityEvent(name.abuchen.portfolio.model.SecurityEvent) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) Quote(name.abuchen.portfolio.money.Quote) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) DateEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateEditingSupport) Images(name.abuchen.portfolio.ui.Images) ConvertBuySellToDeliveryAction(name.abuchen.portfolio.ui.views.actions.ConvertBuySellToDeliveryAction) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Messages(name.abuchen.portfolio.ui.Messages) ConvertDeliveryToBuySellAction(name.abuchen.portfolio.ui.views.actions.ConvertDeliveryToBuySellAction) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) Portfolio(name.abuchen.portfolio.model.Portfolio) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) SashLayoutData(name.abuchen.portfolio.ui.util.swt.SashLayoutData) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) TransactionPair(name.abuchen.portfolio.model.TransactionPair) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) Action(org.eclipse.jface.action.Action) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) CTabItem(org.eclipse.swt.custom.CTabItem) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) Unit(name.abuchen.portfolio.model.Transaction.Unit) IMenuManager(org.eclipse.jface.action.IMenuManager) Dialog(org.eclipse.jface.dialogs.Dialog) SecurityPrice(name.abuchen.portfolio.model.SecurityPrice) ToolTip(org.eclipse.jface.window.ToolTip) SWTHelper(name.abuchen.portfolio.ui.util.SWTHelper) Collections(java.util.Collections) PortfolioTransferEntry(name.abuchen.portfolio.model.PortfolioTransferEntry) TransactionPair(name.abuchen.portfolio.model.TransactionPair) Composite(org.eclipse.swt.widgets.Composite) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Portfolio(name.abuchen.portfolio.model.Portfolio) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) TransactionOwner(name.abuchen.portfolio.model.TransactionOwner) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) Transaction(name.abuchen.portfolio.model.Transaction) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 34 with Column

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

the class ExchangeRatesListView method createTopTable.

@Override
protected void createTopTable(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    TableViewer indeces = new TableViewer(container, SWT.FULL_SELECTION);
    ShowHideColumnHelper support = new // $NON-NLS-1$
    ShowHideColumnHelper(// $NON-NLS-1$
    ExchangeRatesListView.class.getSimpleName() + "@top2", getPreferenceStore(), indeces, layout);
    Column column = new Column(Messages.ColumnBaseCurrency, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((ExchangeRateTimeSeries) element).getBaseCurrency();
        }
    });
    // $NON-NLS-1$ //$NON-NLS-2$
    ColumnViewerSorter.create(ExchangeRateTimeSeries.class, "baseCurrency", "termCurrency").attachTo(column, SWT.DOWN);
    support.addColumn(column);
    column = new Column(Messages.ColumnTermCurrency, SWT.None, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((ExchangeRateTimeSeries) element).getTermCurrency();
        }
    });
    // $NON-NLS-1$ //$NON-NLS-2$
    ColumnViewerSorter.create(ExchangeRateTimeSeries.class, "termCurrency", "baseCurrency").attachTo(column);
    support.addColumn(column);
    column = new Column(Messages.ColumnCurrencyProvider, SWT.None, 150);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            return ((ExchangeRateTimeSeries) element).getProvider().getName();
        }
    });
    // $NON-NLS-1$
    ColumnViewerSorter.create(ExchangeRateTimeSeries.class, "provider").attachTo(column);
    support.addColumn(column);
    column = new Column(Messages.ColumnDateLatestExchangeRate, SWT.None, 150);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            ExchangeRateTimeSeries series = (ExchangeRateTimeSeries) element;
            List<ExchangeRate> rates = series.getRates();
            return rates.isEmpty() ? null : Values.Date.format(rates.get(rates.size() - 1).getTime());
        }
    });
    ColumnViewerSorter.create(element -> {
        ExchangeRateTimeSeries series = (ExchangeRateTimeSeries) element;
        List<ExchangeRate> rates = series.getRates();
        return rates.isEmpty() ? null : rates.get(rates.size() - 1).getTime();
    }).attachTo(column);
    support.addColumn(column);
    support.createColumns();
    indeces.getTable().setHeaderVisible(true);
    indeces.getTable().setLinesVisible(true);
    indeces.setContentProvider(ArrayContentProvider.getInstance());
    indeces.setInput(providerFactory.getAvailableTimeSeries());
    indeces.refresh();
    indeces.addSelectionChangedListener(event -> refreshChart((ExchangeRateTimeSeries) ((IStructuredSelection) event.getSelection()).getFirstElement()));
}
Also used : Values(name.abuchen.portfolio.money.Values) TableViewer(org.eclipse.jface.viewers.TableViewer) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) DecimalFormat(java.text.DecimalFormat) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) ISeries(org.swtchart.ISeries) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ExchangeRate(name.abuchen.portfolio.money.ExchangeRate) TimelineChart(name.abuchen.portfolio.ui.util.chart.TimelineChart) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) MessageFormat(java.text.MessageFormat) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) Inject(javax.inject.Inject) ExchangeRateTimeSeries(name.abuchen.portfolio.money.ExchangeRateTimeSeries) List(java.util.List) Colors(name.abuchen.portfolio.ui.util.Colors) Composite(org.eclipse.swt.widgets.Composite) Messages(name.abuchen.portfolio.ui.Messages) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Composite(org.eclipse.swt.widgets.Composite) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) Column(name.abuchen.portfolio.ui.util.viewers.Column) ExchangeRateTimeSeries(name.abuchen.portfolio.money.ExchangeRateTimeSeries) List(java.util.List) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 35 with Column

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

the class PerformanceView method addFeesColumn.

private void addFeesColumn(ShowHideColumnHelper support) {
    Column column = new Column(Messages.ColumnFees, SWT.RIGHT, 80);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            Transaction t = ((TransactionPair<?>) element).getTransaction();
            if (t instanceof AccountTransaction) {
                AccountTransaction at = (AccountTransaction) t;
                switch(at.getType()) {
                    case FEES:
                        return Values.Money.format(t.getMonetaryAmount(), getClient().getBaseCurrency());
                    case FEES_REFUND:
                        return Values.Money.format(t.getMonetaryAmount().multiply(-1), getClient().getBaseCurrency());
                    default:
                }
            }
            return Values.Money.format(t.getUnitSum(Unit.Type.FEE), getClient().getBaseCurrency());
        }
    });
    column.setSorter(ColumnViewerSorter.create(e -> ((TransactionPair<?>) e).getTransaction().getUnitSum(Unit.Type.FEE)));
    support.addColumn(column);
}
Also used : Client(name.abuchen.portfolio.model.Client) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ToolBar(org.eclipse.swt.widgets.ToolBar) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) TransactionOwner(name.abuchen.portfolio.model.TransactionOwner) ESelectionService(org.eclipse.e4.ui.workbench.modeling.ESelectionService) Composite(org.eclipse.swt.widgets.Composite) ReportingPeriod(name.abuchen.portfolio.snapshot.ReportingPeriod) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) Account(name.abuchen.portfolio.model.Account) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) ClientPerformanceSnapshot(name.abuchen.portfolio.snapshot.ClientPerformanceSnapshot) Security(name.abuchen.portfolio.model.Security) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ShowHideColumnHelper(name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) SWT(org.eclipse.swt.SWT) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SecuritySelection(name.abuchen.portfolio.ui.selection.SecuritySelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GroupEarningsByAccount(name.abuchen.portfolio.snapshot.GroupEarningsByAccount) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Values(name.abuchen.portfolio.money.Values) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) CrossEntry(name.abuchen.portfolio.model.CrossEntry) JFaceResources(org.eclipse.jface.resource.JFaceResources) Function(java.util.function.Function) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) MessageFormat(java.text.MessageFormat) Inject(javax.inject.Inject) Messages(name.abuchen.portfolio.ui.Messages) Font(org.eclipse.swt.graphics.Font) Portfolio(name.abuchen.portfolio.model.Portfolio) ClientFilterDropDown(name.abuchen.portfolio.ui.util.ClientFilterDropDown) Viewer(org.eclipse.jface.viewers.Viewer) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) TransactionPair(name.abuchen.portfolio.model.TransactionPair) SimpleAction(name.abuchen.portfolio.ui.util.SimpleAction) Column(name.abuchen.portfolio.ui.util.viewers.Column) ColumnViewerSorter(name.abuchen.portfolio.ui.util.viewers.ColumnViewerSorter) TreeViewerCSVExporter(name.abuchen.portfolio.ui.util.TreeViewerCSVExporter) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) TableViewerCSVExporter(name.abuchen.portfolio.ui.util.TableViewerCSVExporter) CTabItem(org.eclipse.swt.custom.CTabItem) Unit(name.abuchen.portfolio.model.Transaction.Unit) IMenuManager(org.eclipse.jface.action.IMenuManager) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) Control(org.eclipse.swt.widgets.Control) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) Transaction(name.abuchen.portfolio.model.Transaction) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction)

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