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 to supply SearchAction with custom ActionListener #10

Open
imagejan opened this issue Jan 15, 2018 · 2 comments
Open

Allow to supply SearchAction with custom ActionListener #10

imagejan opened this issue Jan 15, 2018 · 2 comments

Comments

@imagejan
Copy link
Member

Currently, we generate a default ActionListener for every SearchAction in the details pane:

for (final SearchAction action : actions) {
final JButton button = new JButton(action.toString());
button.addActionListener(ae -> {
action.run();
if (action.closesSearch()) {
reset();
}
});

Allowing for SearchActions to provide their own ActionListener would allow more flexibility, e.g. displaying a small popup menu (JPopupMenu) with additional (sub-)choices that wouldn't justify the creation of an own SearchAction for them.

This goes in the same direction as #4 to provide more flexibility to define search actions.

The problem with allowing with allowing ActionListener as a parameter would be that we introduce an awt dependency in a UI-agnostic SearchAction, so this would have to be abstracted somehow...

@ctrueden
Copy link
Member

ctrueden commented Jan 31, 2018

We don't have to use ActionListener... we could have our own UI-agnostic interface, no? But perhaps run() is already good enough. Why not simply have the JPopupMenu appear in the action's run() method directly? Do we need a second method in the action?

Alternately, if you want to have a UI-agnostic "sub-actions" mechanism, we could add that.

@imagejan
Copy link
Member Author

imagejan commented Feb 2, 2018

My idea was to display a popup menu with options at the position of the button when it is clicked, so I'd actually need to have access to the button, e.g. by actionEvent.getSource().

I realize that this might be too UI-centric after all.

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

2 participants