Skip to content

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

Open
@imagejan

Description

@imagejan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions