diff --git a/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java b/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java index 40bd655ad..3b9fde47e 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java +++ b/app/src/cc/arduino/contributions/libraries/ui/LibrariesIndexTableModel.java @@ -38,7 +38,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Stream; @SuppressWarnings("serial") public class LibrariesIndexTableModel @@ -54,8 +53,8 @@ public class LibrariesIndexTableModel String selectedFilters[] = null; public void updateIndexFilter(String filters[], - Stream> additionalFilters) { - selectedCategoryFilter = additionalFilters.reduce(Predicate::and).get(); + Predicate additionalFilter) { + selectedCategoryFilter = additionalFilter; selectedFilters = filters; update(); } diff --git a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java index d86cb6c81..aa8f8505f 100644 --- a/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java +++ b/app/src/cc/arduino/contributions/libraries/ui/LibraryManagerUI.java @@ -118,24 +118,16 @@ public class LibraryManagerUI extends InstallerJDialog { public void actionPerformed(ActionEvent event) { DropdownItem selected = (DropdownItem) typeChooser.getSelectedItem(); previousRowAtPoint = -1; - if (typeFilter == null || typeFilter != selected.getFilterPredicate()) { + if (selected != null && typeFilter != selected.getFilterPredicate()) { typeFilter = selected.getFilterPredicate(); if (contribTable.getCellEditor() != null) { contribTable.getCellEditor().stopCellEditing(); } - updateIndexFilter(filters, categoryFilter, typeFilter); + updateIndexFilter(filters, categoryFilter.and(typeFilter)); } } }; - @Override - public void updateIndexFilter(String[] filters, Predicate... additionalFilters) { - if (additionalFilters.length == 1) { - additionalFilters = new Predicate[]{additionalFilters[0], typeFilter}; - } - super.updateIndexFilter(filters, additionalFilters); - } - public void updateUI() { DropdownItem previouslySelectedCategory = (DropdownItem) categoryChooser.getSelectedItem(); DropdownItem previouslySelectedType = (DropdownItem) typeChooser.getSelectedItem(); diff --git a/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java b/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java index 283df1067..f143e3317 100644 --- a/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java +++ b/app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java @@ -39,7 +39,6 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; import java.util.stream.Collectors; -import java.util.stream.Stream; @SuppressWarnings("serial") public class ContributionIndexTableModel @@ -50,10 +49,8 @@ public class ContributionIndexTableModel private final Class[] columnTypes = { ContributedPlatform.class }; public void updateIndexFilter(String[] filters, - Stream> additionalFilters) { + Predicate filter) { contributions.clear(); - Predicate filter = additionalFilters - .reduce(Predicate::and).get(); for (ContributedPackage pack : BaseNoGui.indexer.getPackages()) { for (ContributedPlatform platform : pack.getPlatforms()) { String compoundTargetSearchText = platform.getName() + "\n" diff --git a/app/src/cc/arduino/contributions/ui/FilteredAbstractTableModel.java b/app/src/cc/arduino/contributions/ui/FilteredAbstractTableModel.java index 2e423a47e..348561c31 100644 --- a/app/src/cc/arduino/contributions/ui/FilteredAbstractTableModel.java +++ b/app/src/cc/arduino/contributions/ui/FilteredAbstractTableModel.java @@ -37,11 +37,10 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Stream; public abstract class FilteredAbstractTableModel extends AbstractTableModel { - abstract public void updateIndexFilter(String[] filters, Stream> additionalFilters); + abstract public void updateIndexFilter(String[] filters, Predicate additionalFilter); public static T getLatestOf(List contribs) { contribs = new LinkedList<>(contribs); diff --git a/app/src/cc/arduino/contributions/ui/InstallerJDialog.java b/app/src/cc/arduino/contributions/ui/InstallerJDialog.java index 9c9c4d11e..bb6bf0280 100644 --- a/app/src/cc/arduino/contributions/ui/InstallerJDialog.java +++ b/app/src/cc/arduino/contributions/ui/InstallerJDialog.java @@ -46,7 +46,6 @@ import java.awt.event.WindowEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.util.function.Predicate; -import java.util.stream.Stream; import javax.swing.Box; import javax.swing.BoxLayout; @@ -265,9 +264,8 @@ public abstract class InstallerJDialog extends JDialog { SwingUtilities.invokeLater(InstallerJDialog.this::onUpdatePressed); } - public void updateIndexFilter(String[] filters, Predicate... additionalFilters) { - Stream> notNullAdditionalFilters = Stream.of(additionalFilters).filter(filter -> filter != null); - contribModel.updateIndexFilter(filters, notNullAdditionalFilters); + public void updateIndexFilter(String[] filters, Predicate additionalFilter) { + contribModel.updateIndexFilter(filters, additionalFilter); } public void setErrorMessage(String message) { @@ -311,7 +309,7 @@ public abstract class InstallerJDialog extends JDialog { public void actionPerformed(ActionEvent event) { DropdownItem selected = (DropdownItem) categoryChooser.getSelectedItem(); previousRowAtPoint = -1; - if (categoryFilter == null || categoryFilter != selected.getFilterPredicate()) { + if (selected != null && categoryFilter != selected.getFilterPredicate()) { categoryFilter = selected.getFilterPredicate(); if (contribTable.getCellEditor() != null) { contribTable.getCellEditor().stopCellEditing();