Skip to content

Commit 27a7fde

Browse files
committed
SwingSearchBar: use new PluginService#sort method
1 parent bc65dab commit 27a7fde

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</parent>
1111

1212
<artifactId>scijava-search</artifactId>
13-
<version>0.1.1-SNAPSHOT</version>
13+
<version>0.2.0-SNAPSHOT</version>
1414

1515
<name>SciJava Search</name>
1616
<description>Search framework for SciJava applications.</description>
@@ -90,7 +90,7 @@
9090
<!-- NB: Deploy releases to the ImageJ Maven repository. -->
9191
<releaseProfiles>deploy-to-imagej</releaseProfiles>
9292

93-
<scijava-common.version>2.68.0</scijava-common.version>
93+
<scijava-common.version>2.69.0</scijava-common.version>
9494
</properties>
9595

9696
<repositories>

src/main/java/org/scijava/ui/swing/search/SwingSearchBar.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,23 +228,6 @@ public void addButton(final String label, final String tooltip,
228228
buttons.add(button);
229229
}
230230

231-
// -- Utility methods --
232-
233-
// TODO: Move this method to PluginService.
234-
public <PT extends SciJavaPlugin> void sort(final List<PT> instances,
235-
final Class<PT> type)
236-
{
237-
// Create a mapping from plugin classes to priorities.
238-
final List<PluginInfo<PT>> plugins = pluginService.getPluginsOfType(type);
239-
final Map<Class<?>, PluginInfo<PT>> infos = plugins.stream().collect(//
240-
Collectors.toMap(PluginInfo::getPluginClass, Function.identity()));
241-
242-
// Compare plugin instances by priority via the mapping.
243-
final Comparator<PT> comparator = (o1, o2) -> Priority.compare(//
244-
infos.get(o1.getClass()), infos.get(o2.getClass()));
245-
Collections.sort(instances, comparator);
246-
}
247-
248231
// -- Internal methods --
249232

250233
/** Called on the EDT when the search panel wants to appear. */
@@ -653,7 +636,7 @@ private void rebuild() {
653636
// Gets list of Searchers, sorted by priority.
654637
final List<Searcher> searchers = allResults.values().stream().map(
655638
event -> event.searcher()).collect(Collectors.toList());
656-
sort(searchers, Searcher.class);
639+
pluginService.sort(searchers, Searcher.class);
657640

658641
// Build the new list model.
659642
final DefaultListModel<SearchResult> listModel = new DefaultListModel<>();

0 commit comments

Comments
 (0)