Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow SearchActions (i.e. buttons) to be present but disabled for certain search results #4

Open
imagejan opened this issue Jan 5, 2018 · 0 comments

Comments

@imagejan
Copy link
Member

imagejan commented Jan 5, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant