mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-01 23:29:28 +01:00
Merge pull request #11096 from facchinm/loose_filter_on_boards
Board Manager: searching returns also near matches
This commit is contained in:
commit
9b509c06f6
@ -60,8 +60,17 @@ public class ContributionIndexTableModel
|
|||||||
|
|
||||||
private void updateContributions() {
|
private void updateContributions() {
|
||||||
contributions.clear();
|
contributions.clear();
|
||||||
|
|
||||||
|
// Generate ContributedPlatformReleases from all platform releases
|
||||||
for (ContributedPackage pack : BaseNoGui.indexer.getPackages()) {
|
for (ContributedPackage pack : BaseNoGui.indexer.getPackages()) {
|
||||||
for (ContributedPlatform platform : pack.getPlatforms()) {
|
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"
|
String compoundTargetSearchText = platform.getName() + "\n"
|
||||||
+ platform.getBoards().stream()
|
+ platform.getBoards().stream()
|
||||||
.map(ContributedBoard::getName)
|
.map(ContributedBoard::getName)
|
||||||
@ -71,9 +80,12 @@ public class ContributionIndexTableModel
|
|||||||
}
|
}
|
||||||
if (!stringContainsAll(compoundTargetSearchText, filters))
|
if (!stringContainsAll(compoundTargetSearchText, filters))
|
||||||
continue;
|
continue;
|
||||||
addContribution(platform);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Sort ContributedPlatformReleases and put deprecated platforms to the bottom
|
||||||
Collections.sort(contributions, (x,y)-> {
|
Collections.sort(contributions, (x,y)-> {
|
||||||
if (x.isDeprecated() != y.isDeprecated()) {
|
if (x.isDeprecated() != y.isDeprecated()) {
|
||||||
return x.isDeprecated() ? 1 : -1;
|
return x.isDeprecated() ? 1 : -1;
|
||||||
@ -86,6 +98,7 @@ public class ContributionIndexTableModel
|
|||||||
}
|
}
|
||||||
return x1.getName().compareToIgnoreCase(y1.getName());
|
return x1.getName().compareToIgnoreCase(y1.getName());
|
||||||
});
|
});
|
||||||
|
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,12 +123,12 @@ public class ContributionIndexTableModel
|
|||||||
|
|
||||||
private void addContribution(ContributedPlatform platform) {
|
private void addContribution(ContributedPlatform platform) {
|
||||||
for (ContributedPlatformReleases contribution : contributions) {
|
for (ContributedPlatformReleases contribution : contributions) {
|
||||||
if (!contribution.shouldContain(platform))
|
if (!contribution.shouldContain(platform)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
contribution.add(platform);
|
contribution.add(platform);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
contributions.add(new ContributedPlatformReleases(platform));
|
contributions.add(new ContributedPlatformReleases(platform));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user