Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.Transaction$ByDate


        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;
            }

            @Override
            public String getToolTipText(Object element)
            {
                Long v = getValue(element);
                return v != null ? Values.Share.format(v) : 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.Amount.format(t.getAmount());
            }
        });
        column.setSorter(ColumnViewerSorter.create(new Comparator<Object>()
        {
            @Override
            public int compare(Object o1, Object 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.ColumnQuote, SWT.RIGHT, 80);
        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                Transaction t = ((TransactionPair<?>) element).getTransaction();
                if (t instanceof PortfolioTransaction)
                {
                    return Values.Amount.format(((PortfolioTransaction) t).getActualPurchasePrice());
                }
                else if (t instanceof AccountTransaction)
                {
                    long shares = ((AccountTransaction) t).getShares();
                    if (shares != 0)
                        return Values.Amount.format(Math.round(t.getAmount() * Values.Share.divider() / shares));
                }
                return null;
            }
        });
        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().getCrossEntity(t).toString() : null;
                else
                    return pair.getOwner().toString();
            }
        });
        support.addColumn(column);
View Full Code Here


        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object e)
            {
                Transaction t = (Transaction) e;
                return Values.Date.format(t.getDate());
            }
        });
        column.setSorter(ColumnViewerSorter.create(Transaction.class, "date"), SWT.DOWN); //$NON-NLS-1$
        support.addColumn(column);
View Full Code Here

        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                Transaction transaction = (Transaction) element;
                if (transaction.getSecurity() != null)
                    return transaction.getSecurity().getName();

                for (Account account : getClient().getAccounts())
                {
                    if (account.getTransactions().contains(transaction))
                        return account.getName();
                }

                return null;
            }

            @Override
            public Image getImage(Object element)
            {
                Transaction transaction = (Transaction) element;
                return PortfolioPlugin.image(transaction.getSecurity() != null ? PortfolioPlugin.IMG_SECURITY
                                : PortfolioPlugin.IMG_ACCOUNT);
            }
        });
        column.setSorter(ColumnViewerSorter.create(Transaction.class, "security")); //$NON-NLS-1$
        support.addColumn(column);
View Full Code Here

    {
        public Image getColumnImage(Object element, int columnIndex)
        {
            if (columnIndex == 1)
            {
                Transaction t = ((TransactionPair<?>) element).getTransaction();

                if (t instanceof AccountTransaction)
                    return PortfolioPlugin.image(PortfolioPlugin.IMG_ACCOUNT);
                else if (t instanceof PortfolioTransaction)
                    return PortfolioPlugin.image(PortfolioPlugin.IMG_PORTFOLIO);
View Full Code Here

        }

        public String getColumnText(Object element, int columnIndex)
        {
            TransactionPair<?> pair = (TransactionPair<?>) element;
            Transaction t = pair.getTransaction();

            switch (columnIndex)
            {
                case 0:
                    return Values.Date.format(t.getDate());
                case 1:
                    if (t instanceof AccountTransaction)
                        return ((AccountTransaction) t).getType().toString();
                    else if (t instanceof PortfolioTransaction)
                        return ((PortfolioTransaction) t).getType().toString();
                    return null;
                case 2:
                    return Values.Share.format(t.getShares());
                case 3:
                    if (model.isChangeTransactions() && t.getDate().before(model.getExDate()))
                    {
                        long shares = t.getShares() * model.getNewShares() / model.getOldShares();
                        return Values.Share.format(shares);
                    }
                    return null;
                case 4:
                    return pair.getOwner().toString();
View Full Code Here

                    if (transaction.getCrossEntry() != null)
                    {
                        transaction.getCrossEntry().delete();

                        // possibly remove from investment plan
                        Transaction t = transaction.getCrossEntry().getCrossTransaction(transaction);
                        if (t instanceof PortfolioTransaction)
                        {
                            for (InvestmentPlan plan : getClient().getPlans())
                                plan.removeTransaction((PortfolioTransaction) t);
                        }
View Full Code Here

        if (isChangeTransactions())
        {
            List<TransactionPair<?>> transactions = security.getTransactions(getClient());
            for (TransactionPair<?> pair : transactions)
            {
                Transaction t = pair.getTransaction();
                if (t.getDate().before(exDate))
                    t.setShares(t.getShares() * newShares / oldShares);
            }
        }

        if (isChangeHistoricalQuotes())
        {
View Full Code Here

TOP

Related Classes of name.abuchen.portfolio.model.Transaction$ByDate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.