diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java b/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java index f7dbd95d75..2c9939849b 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java @@ -60,8 +60,17 @@ public void updateIndexFilter(String[] filters, private void updateContributions() { contributions.clear(); + + // Generate ContributedPlatformReleases from all platform releases for (ContributedPackage pack : BaseNoGui.indexer.getPackages()) { for (ContributedPlatform platform : pack.getPlatforms()) { + addContribution(platform); + } + } + + // Filter ContributedPlatformReleases based on search terms + contributions.removeIf(releases -> { + for (ContributedPlatform platform : releases.releases) { String compoundTargetSearchText = platform.getName() + "\n" + platform.getBoards().stream() .map(ContributedBoard::getName) @@ -71,9 +80,12 @@ private void updateContributions() { } if (!stringContainsAll(compoundTargetSearchText, filters)) continue; - addContribution(platform); + return false; } - } + return true; + }); + + // Sort ContributedPlatformReleases and put deprecated platforms to the bottom Collections.sort(contributions, (x,y)-> { if (x.isDeprecated() != y.isDeprecated()) { return x.isDeprecated() ? 1 : -1; @@ -86,6 +98,7 @@ private void updateContributions() { } return x1.getName().compareToIgnoreCase(y1.getName()); }); + fireTableDataChanged(); } @@ -110,12 +123,12 @@ private boolean stringContainsAll(String string, String set[]) { private void addContribution(ContributedPlatform platform) { for (ContributedPlatformReleases contribution : contributions) { - if (!contribution.shouldContain(platform)) + if (!contribution.shouldContain(platform)) { continue; + } contribution.add(platform); return; } - contributions.add(new ContributedPlatformReleases(platform)); }