Package name.abuchen.portfolio.model

Examples of name.abuchen.portfolio.model.SecurityPrice


        column.setLabelProvider(new ColumnLabelProvider()
        {
            @Override
            public String getText(Object element)
            {
                SecurityPrice latest = ((Security) element).getSecurityPrice(Dates.today());
                return latest != null ? Values.Date.format(latest.getTime()) : null;
            }

            @Override
            public Color getForeground(Object element)
            {
                return getColor(element, SWT.COLOR_INFO_FOREGROUND);
            }

            @Override
            public Color getBackground(Object element)
            {
                return getColor(element, SWT.COLOR_INFO_BACKGROUND);
            }

            private Color getColor(Object element, int colorId)
            {
                SecurityPrice latest = ((Security) element).getSecurityPrice(Dates.today());

                Date sevenDaysAgo = new Date(System.currentTimeMillis() - (7 * Dates.DAY_IN_MS));
                if (latest != null && latest.getTime().before(sevenDaysAgo))
                    return Display.getDefault().getSystemColor(colorId);
                else
                    return null;
            }
        });
        column.setSorter(ColumnViewerSorter.create(new Comparator<Object>()
        {
            @Override
            public int compare(Object o1, Object o2)
            {
                SecurityPrice p1 = ((Security) o1).getSecurityPrice(Dates.today());
                SecurityPrice p2 = ((Security) o2).getSecurityPrice(Dates.today());

                if (p1 == null)
                    return p2 == null ? 0 : -1;
                if (p2 == null)
                    return 1;

                return p1.getTime().compareTo(p2.getTime());
            }
        }));
        support.addColumn(column);
    }
View Full Code Here


            {
                List<SecurityPrice> prices = ((Security) element).getPrices();
                if (prices.isEmpty())
                    return null;

                SecurityPrice latest = prices.get(prices.size() - 1);
                return latest != null ? Values.Date.format(latest.getTime()) : null;
            }

            @Override
            public Color getForeground(Object element)
            {
                return getColor(element, SWT.COLOR_INFO_FOREGROUND);
            }

            @Override
            public Color getBackground(Object element)
            {
                return getColor(element, SWT.COLOR_INFO_BACKGROUND);
            }

            private Color getColor(Object element, int colorId)
            {
                List<SecurityPrice> prices = ((Security) element).getPrices();
                if (prices.isEmpty())
                    return null;

                SecurityPrice latest = prices.get(prices.size() - 1);
                if (latest.getTime().before(new Date(System.currentTimeMillis() - (7 * Dates.DAY_IN_MS))))
                    return Display.getDefault().getSystemColor(colorId);
                else
                    return null;
            }
        });
        column.setSorter(ColumnViewerSorter.create(new Comparator<Object>()
        {
            @Override
            public int compare(Object o1, Object o2)
            {
                List<SecurityPrice> prices1 = ((Security) o1).getPrices();
                SecurityPrice p1 = prices1.isEmpty() ? null : prices1.get(prices1.size() - 1);
                List<SecurityPrice> prices2 = ((Security) o2).getPrices();
                SecurityPrice p2 = prices2.isEmpty() ? null : prices2.get(prices2.size() - 1);

                if (p1 == null)
                    return p2 == null ? 0 : -1;
                if (p2 == null)
                    return 1;

                return p1.getTime().compareTo(p2.getTime());
            }
        }));
        support.addColumn(column);
    }
View Full Code Here

        List<LatestSecurityPrice> quotes = getHistoricalQuotes(security, null, errors);

        boolean isUpdated = false;
        for (LatestSecurityPrice quote : quotes)
        {
            boolean isAdded = security.addPrice(new SecurityPrice(quote.getTime(), quote.getValue()));
            isUpdated = isUpdated || isAdded;
        }
       
        return isUpdated;
    }
View Full Code Here

            Long amount = convertAmount(Messages.CSVColumn_Quote, rawValues, field2column);
            if (amount == null)
                throw new ParseException(
                                MessageFormat.format(Messages.CSVImportMissingField, Messages.CSVColumn_Quote), 0);

            security.addPrice(new SecurityPrice(date, Math.abs(amount)));
        }
View Full Code Here

TOP

Related Classes of name.abuchen.portfolio.model.SecurityPrice

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.