diff --git a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesTable.java b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesTable.java index b702cab274..8eea184858 100644 --- a/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesTable.java +++ b/name.abuchen.portfolio.ui/src/name/abuchen/portfolio/ui/views/SecuritiesTable.java @@ -63,6 +63,7 @@ import name.abuchen.portfolio.snapshot.ReportingPeriod; import name.abuchen.portfolio.ui.Images; import name.abuchen.portfolio.ui.Messages; +import name.abuchen.portfolio.ui.UIConstants; import name.abuchen.portfolio.ui.dialogs.transactions.AccountTransactionDialog; import name.abuchen.portfolio.ui.dialogs.transactions.InvestmentPlanDialog; import name.abuchen.portfolio.ui.dialogs.transactions.OpenDialogAction; @@ -163,6 +164,8 @@ public void run() private TableViewer securities; + private int numberOfTradeDaysAfterQuoteIsStale; + private Map metricsCache = new HashMap() { private static final long serialVersionUID = 1L; @@ -180,6 +183,9 @@ public SecuritiesTable(Composite parent, AbstractFinanceView view) { this.view = view; + this.numberOfTradeDaysAfterQuoteIsStale = view.getPart().getClientInput().getEclipsePreferences() + .getInt(UIConstants.Preferences.QUOTES_STALE_AFTER_DAYS_PATH, 7); + Composite container = new Composite(parent, SWT.NONE); TableColumnLayout layout = new TableColumnLayout(); container.setLayout(layout); @@ -491,6 +497,14 @@ private void addColumnDateOfLatestPrice() // NOSONAR column.setLabelProvider(new DateLabelProvider(dataProvider) { + private int numberOfDaysWithWarning; + + public DateLabelProvider setNumberOfDaysWithWarning(int numberOfDays) + { + this.numberOfDaysWithWarning = numberOfDays; + return this; + } + @Override public Color getBackground(Object element) { @@ -503,10 +517,10 @@ public Color getBackground(Object element) if (QuoteFeed.MANUAL.equals(feed)) return null; - LocalDate sevenDaysAgo = LocalDate.now().minusDays(7); - return latest.getDate().isBefore(sevenDaysAgo) ? Colors.theme().warningBackground() : null; + LocalDate daysAgo = LocalDate.now().minusDays(this.numberOfDaysWithWarning); + return latest.getDate().isBefore(daysAgo) ? Colors.theme().warningBackground() : null; } - }); + }.setNumberOfDaysWithWarning(this.numberOfTradeDaysAfterQuoteIsStale)); column.setSorter(ColumnViewerSorter.create(dataProvider::apply)); support.addColumn(column); } @@ -528,6 +542,14 @@ private void addColumnDateOfLatestHistoricalPrice() // NOSONAR column.setLabelProvider(new DateLabelProvider(dataProvider) { + private int numberOfDaysWithWarning; + + public DateLabelProvider setNumberOfDaysWithWarning(int numberOfDays) + { + this.numberOfDaysWithWarning = numberOfDays; + return this; + } + @Override public Color getBackground(Object element) { @@ -540,12 +562,13 @@ public Color getBackground(Object element) return null; SecurityPrice latest = prices.get(prices.size() - 1); - if (!((Security) element).isRetired() && latest.getDate().isBefore(LocalDate.now().minusDays(7))) + if (!((Security) element).isRetired() && latest.getDate() + .isBefore(LocalDate.now().minusDays(numberOfDaysWithWarning))) return Colors.theme().warningBackground(); else return null; } - }); + }.setNumberOfDaysWithWarning(this.numberOfTradeDaysAfterQuoteIsStale)); column.setSorter(ColumnViewerSorter.create(dataProvider::apply)); support.addColumn(column); }