Search in sources :

Example 6 with NoteColumn

use of name.abuchen.portfolio.ui.views.columns.NoteColumn in project portfolio by buchen.

the class AbstractNodeTreeViewer method addDimensionColumn.

protected void addDimensionColumn(ShowHideColumnHelper support) {
    // $NON-NLS-1$
    Column column = new NameColumn("txname", Messages.ColumnLevels, SWT.NONE, 400);
    column.setLabelProvider(new // NOSONAR
    NameColumnLabelProvider() {

        @Override
        public Image getImage(Object e) {
            if (((TaxonomyNode) e).isUnassignedCategory())
                return Images.UNASSIGNED_CATEGORY.image();
            return super.getImage(e);
        }
    });
    new // $NON-NLS-1$
    StringEditingSupport(// $NON-NLS-1$
    Named.class, // $NON-NLS-1$
    "name") {

        @Override
        public boolean canEdit(Object element) {
            if (((TaxonomyNode) element).isUnassignedCategory())
                return false;
            else
                return super.canEdit(element);
        }
    }.setMandatory(true).addListener(this).attachTo(column);
    column.setRemovable(false);
    // drag & drop sorting does not work well with auto sorting
    column.setSorter(null);
    support.addColumn(column);
    column = new IsinColumn();
    column.getEditingSupport().addListener(this);
    column.setSorter(null);
    column.setVisible(false);
    support.addColumn(column);
    column = new NoteColumn();
    column.getEditingSupport().addListener(this);
    column.setSorter(null);
    column.setVisible(false);
    support.addColumn(column);
    addWeightColumn(support);
}
Also used : Named(name.abuchen.portfolio.model.Named) 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) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Image(org.eclipse.swt.graphics.Image) IsinColumn(name.abuchen.portfolio.ui.views.columns.IsinColumn)

Example 7 with NoteColumn

use of name.abuchen.portfolio.ui.views.columns.NoteColumn in project portfolio by buchen.

the class AccountListView method createTopTable.

// //////////////////////////////////////////////////////////////
// top table: accounts
// //////////////////////////////////////////////////////////////
@Override
protected void createTopTable(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    accounts = new TableViewer(container, SWT.FULL_SELECTION);
    ColumnEditingSupport.prepare(accounts);
    accountColumns = new // $NON-NLS-1$
    ShowHideColumnHelper(// $NON-NLS-1$
    AccountListView.class.getSimpleName() + "@top2", getPreferenceStore(), accounts, layout);
    // $NON-NLS-1$
    Column column = new NameColumn("0", Messages.ColumnAccount, SWT.None, 150);
    column.setLabelProvider(new // NOSONAR
    NameColumnLabelProvider() {

        @Override
        public Color getForeground(Object e) {
            boolean isRetired = ((Account) e).isRetired();
            return isRetired ? Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY) : null;
        }
    });
    column.getEditingSupport().addListener(this);
    accountColumns.addColumn(column);
    column = new Column(Messages.ColumnBalance, SWT.RIGHT, 80);
    column.setDescription(Messages.ColumnBalance_Description);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            return Values.Amount.format(((Account) e).getCurrentAmount(LocalDateTime.now().with(LocalTime.MAX)));
        }
    });
    ColumnViewerSorter.create(o -> ((Account) o).getCurrentAmount(LocalDateTime.now().with(LocalTime.MAX))).attachTo(column);
    accountColumns.addColumn(column);
    column = new CurrencyColumn();
    column.setEditingSupport(new CurrencyEditingSupport() {

        @Override
        public boolean canEdit(Object element) {
            return ((Account) element).getTransactions().isEmpty();
        }
    });
    accountColumns.addColumn(column);
    column = new NoteColumn();
    column.getEditingSupport().addListener(this);
    accountColumns.addColumn(column);
    accountColumns.createColumns();
    accounts.getTable().setHeaderVisible(true);
    accounts.getTable().setLinesVisible(true);
    accounts.setContentProvider(ArrayContentProvider.getInstance());
    resetInput();
    accounts.refresh();
    accounts.addSelectionChangedListener(event -> {
        Account account = (Account) ((IStructuredSelection) event.getSelection()).getFirstElement();
        updateOnAccountSelected(account);
        transactions.setData(Account.class.toString(), account);
        transactions.setInput(account != null ? account.getTransactions() : new ArrayList<AccountTransaction>(0));
        transactions.refresh();
    });
    hookContextMenu(accounts.getTable(), this::fillAccountsContextMenu);
}
Also used : NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) Type(name.abuchen.portfolio.model.AccountTransaction.Type) Transaction(name.abuchen.portfolio.model.Transaction) TableViewer(org.eclipse.jface.viewers.TableViewer) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) AccountSnapshot(name.abuchen.portfolio.snapshot.AccountSnapshot) ToolBar(org.eclipse.swt.widgets.ToolBar) 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) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) KeyEvent(org.eclipse.swt.events.KeyEvent) LocalTime(java.time.LocalTime) ColumnViewerToolTipSupport(org.eclipse.jface.viewers.ColumnViewerToolTipSupport) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Separator(org.eclipse.jface.action.Separator) Account(name.abuchen.portfolio.model.Account) CTabFolder(org.eclipse.swt.custom.CTabFolder) ExchangeRateProviderFactory(name.abuchen.portfolio.money.ExchangeRateProviderFactory) MenuManager(org.eclipse.jface.action.MenuManager) CurrencyEditingSupport(name.abuchen.portfolio.ui.views.columns.CurrencyColumn.CurrencyEditingSupport) Display(org.eclipse.swt.widgets.Display) 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) DateTimeEditingSupport(name.abuchen.portfolio.ui.util.viewers.DateTimeEditingSupport) 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) LocalDate(java.time.LocalDate) SWT(org.eclipse.swt.SWT) AccountTransactionDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PortfolioTransaction(name.abuchen.portfolio.model.PortfolioTransaction) Money(name.abuchen.portfolio.money.Money) Values(name.abuchen.portfolio.money.Values) Quote(name.abuchen.portfolio.money.Quote) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) LocalDateTime(java.time.LocalDateTime) Images(name.abuchen.portfolio.ui.Images) Image(org.eclipse.swt.graphics.Image) HashMap(java.util.HashMap) ISeries(org.swtchart.ISeries) 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) AccountTransferDialog(name.abuchen.portfolio.ui.dialogs.transactions.AccountTransferDialog) StringEditingSupport(name.abuchen.portfolio.ui.util.viewers.StringEditingSupport) BuySellEntry(name.abuchen.portfolio.model.BuySellEntry) AccountTransferEntry(name.abuchen.portfolio.model.AccountTransferEntry) ValueEditingSupport(name.abuchen.portfolio.ui.util.viewers.ValueEditingSupport) AccountTransaction(name.abuchen.portfolio.model.AccountTransaction) 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) MutableMoney(name.abuchen.portfolio.money.MutableMoney) TimelineChart(name.abuchen.portfolio.ui.util.chart.TimelineChart) AbstractDropDown(name.abuchen.portfolio.ui.util.AbstractDropDown) CTabItem(org.eclipse.swt.custom.CTabItem) SharesLabelProvider(name.abuchen.portfolio.ui.util.viewers.SharesLabelProvider) ChronoUnit(java.time.temporal.ChronoUnit) OpenDialogAction(name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction) Color(org.eclipse.swt.graphics.Color) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolTip(org.eclipse.jface.window.ToolTip) Collections(java.util.Collections) Control(org.eclipse.swt.widgets.Control) Account(name.abuchen.portfolio.model.Account) Composite(org.eclipse.swt.widgets.Composite) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Color(org.eclipse.swt.graphics.Color) ArrayList(java.util.ArrayList) CurrencyEditingSupport(name.abuchen.portfolio.ui.views.columns.CurrencyColumn.CurrencyEditingSupport) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) CurrencyColumn(name.abuchen.portfolio.ui.views.columns.CurrencyColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 8 with NoteColumn

use of name.abuchen.portfolio.ui.views.columns.NoteColumn 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 9 with NoteColumn

use of name.abuchen.portfolio.ui.views.columns.NoteColumn in project portfolio by buchen.

the class PortfolioListView method createTopTable.

// //////////////////////////////////////////////////////////////
// top table: accounts
// //////////////////////////////////////////////////////////////
protected void createTopTable(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    TableColumnLayout layout = new TableColumnLayout();
    container.setLayout(layout);
    portfolios = new TableViewer(container, SWT.FULL_SELECTION);
    ColumnEditingSupport.prepare(portfolios);
    portfolioColumns = new // $NON-NLS-1$
    ShowHideColumnHelper(// $NON-NLS-1$
    PortfolioListView.class.getSimpleName() + "@top2", getPreferenceStore(), portfolios, layout);
    // $NON-NLS-1$
    Column column = new NameColumn("0", Messages.ColumnPortfolio, SWT.None, 100);
    column.setLabelProvider(new NameColumnLabelProvider() {

        @Override
        public Color getForeground(Object e) {
            boolean isRetired = ((Portfolio) e).isRetired();
            return isRetired ? Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY) : null;
        }
    });
    column.getEditingSupport().addListener(this);
    portfolioColumns.addColumn(column);
    column = new Column(Messages.ColumnReferenceAccount, SWT.None, 160);
    column.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object e) {
            Portfolio p = (Portfolio) e;
            return p.getReferenceAccount() != null ? p.getReferenceAccount().getName() : null;
        }
    });
    // $NON-NLS-1$
    ColumnViewerSorter.create(Portfolio.class, "referenceAccount").attachTo(column);
    // $NON-NLS-1$
    new ListEditingSupport(Portfolio.class, "referenceAccount", getClient().getAccounts()).addListener(this).attachTo(column);
    portfolioColumns.addColumn(column);
    column = new NoteColumn();
    column.getEditingSupport().addListener(this);
    portfolioColumns.addColumn(column);
    portfolioColumns.createColumns();
    portfolios.getTable().setHeaderVisible(true);
    portfolios.getTable().setLinesVisible(true);
    portfolios.setContentProvider(ArrayContentProvider.getInstance());
    setInput();
    portfolios.addSelectionChangedListener(event -> {
        Portfolio portfolio = (Portfolio) ((IStructuredSelection) event.getSelection()).getFirstElement();
        if (portfolio != null) {
            transactions.setInput(portfolio, portfolio.getTransactions());
            transactions.refresh();
            CurrencyConverter converter = new CurrencyConverterImpl(factory, portfolio.getReferenceAccount().getCurrencyCode());
            statementOfAssets.setInput(PortfolioSnapshot.create(portfolio, converter, LocalDate.now()));
        } else {
            transactions.setInput(null, null);
            transactions.refresh();
            statementOfAssets.setInput((PortfolioSnapshot) null);
        }
    });
    hookContextMenu(portfolios.getTable(), this::fillPortfolioContextMenu);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Color(org.eclipse.swt.graphics.Color) Portfolio(name.abuchen.portfolio.model.Portfolio) CurrencyConverterImpl(name.abuchen.portfolio.money.CurrencyConverterImpl) CurrencyConverter(name.abuchen.portfolio.money.CurrencyConverter) NameColumnLabelProvider(name.abuchen.portfolio.ui.views.columns.NameColumn.NameColumnLabelProvider) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) NameColumn(name.abuchen.portfolio.ui.views.columns.NameColumn) NoteColumn(name.abuchen.portfolio.ui.views.columns.NoteColumn) Column(name.abuchen.portfolio.ui.util.viewers.Column) ListEditingSupport(name.abuchen.portfolio.ui.util.viewers.ListEditingSupport) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

Column (name.abuchen.portfolio.ui.util.viewers.Column)9 NoteColumn (name.abuchen.portfolio.ui.views.columns.NoteColumn)9 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)8 NameColumn (name.abuchen.portfolio.ui.views.columns.NameColumn)6 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)5 TableViewer (org.eclipse.jface.viewers.TableViewer)5 Image (org.eclipse.swt.graphics.Image)5 Composite (org.eclipse.swt.widgets.Composite)5 ArrayList (java.util.ArrayList)4 Account (name.abuchen.portfolio.model.Account)4 Security (name.abuchen.portfolio.model.Security)4 CurrencyConverterImpl (name.abuchen.portfolio.money.CurrencyConverterImpl)4 ShowHideColumnHelper (name.abuchen.portfolio.ui.util.viewers.ShowHideColumnHelper)4 AttributeColumn (name.abuchen.portfolio.ui.views.columns.AttributeColumn)4 IsinColumn (name.abuchen.portfolio.ui.views.columns.IsinColumn)4 Inject (javax.inject.Inject)3 AccountTransaction (name.abuchen.portfolio.model.AccountTransaction)3 Portfolio (name.abuchen.portfolio.model.Portfolio)3 PortfolioTransaction (name.abuchen.portfolio.model.PortfolioTransaction)3 Transaction (name.abuchen.portfolio.model.Transaction)3