diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java b/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java index f7dbd95d7..2c9939849 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 class ContributionIndexTableModel 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 @@ public class ContributionIndexTableModel } 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 @@ public class ContributionIndexTableModel } return x1.getName().compareToIgnoreCase(y1.getName()); }); + fireTableDataChanged(); } @@ -110,12 +123,12 @@ public class ContributionIndexTableModel 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)); }