Currently, the SearchActionFactory#supports method is used to decide if a SearchAction is to be included in a result's actions:
|
/** |
|
* Gets the suite of available actions for the given search result. |
|
* |
|
* @param result The search result for which available actions are desired. |
|
* @return A list of actions which could possibly be executed for the result. |
|
*/ |
|
default List<SearchAction> actions(final SearchResult result) { |
|
return getInstances().stream().filter(factory -> factory.supports(result)) |
|
.map(factory -> factory.create(result)).collect(Collectors.toList()); |
|
} |
... and a button is added for each supported action:
|
for (final SearchAction action : actions) { |
|
final JButton button = new JButton(action.toString()); |
|
button.addActionListener(ae -> { |
|
action.run(); |
|
if (action.closesSearch()) { |
|
reset(); |
|
} |
|
}); |
|
button.addKeyListener(new SearchBarKeyAdapter()); |
|
if (first) { |
|
detailsButtons.add(button, "grow, spanx"); |
|
final JRootPane rootPane = this.getRootPane(); |
|
if (rootPane != null) { |
|
rootPane.setDefaultButton(button); |
|
} |
|
first = false; |
|
} |
|
else { |
|
detailsButtons.add(button, "growx"); |
|
} |
|
} |
It would be nice to have the possibility to always include a button for a certain result type (e.g. ModuleSearchResult) but to disable it (i.e. show it greyed-out) according to the fulfillment of some additional requirements (e.g. if a specific module doesn't support a given input type).
IMHO, indicating that a certain action is available in principle, but not for the currently highlighted item, would allow for a more consistent user experience.
Currently, the
SearchActionFactory#supportsmethod is used to decide if aSearchActionis to be included in a result's actions:scijava-search/src/main/java/org/scijava/search/SearchService.java
Lines 61 to 70 in 6105bdd
... and a button is added for each supported action:
scijava-search/src/main/java/org/scijava/ui/swing/search/SwingSearchBar.java
Lines 514 to 534 in 6105bdd
It would be nice to have the possibility to always include a button for a certain result type (e.g.
ModuleSearchResult) but to disable it (i.e. show it greyed-out) according to the fulfillment of some additional requirements (e.g. if a specific module doesn't support a given input type).IMHO, indicating that a certain action is available in principle, but not for the currently highlighted item, would allow for a more consistent user experience.