Boris Heithecker wrote:
> In your ContextAwareAction, you could use a delegate to your
> ActionListener. Something like:
>
> //Create an instance of your ActionListener, pass the URI
> MyActionListenerImpl al = new MyActionListenerImpl(uri);
> //Return a simple delegate
> AbstractAction ret = new AbstractAction() {
> @Override
> public void actionPerformed(ActionEvent e) {
> al.actionPerformed(e);
> }
>
> };
> ret.setEnabled(uri != null);That's more or less what I ended up doing, only that I don't bother with ContextAwareAction at all. One ActionListener-based action simply delegates to another in its actionPerformed method. This seems simpler than using AbstractAction + ContextAwareAction, although it does mean that I cannot selectively disable if the "outer" ActionListener's injected input is present in the context but cannot be converted to an URI. Or am I missing some benefit of ContextAwareAction that I don't know about? At any rate, it's just a pity that I can't have additional static create(SomeContextObject) methods in MyActionListenerImpl, annotated with @ActionRegistration. That would keep all the different entrypoints into MyActionListenerImpl in one file. Thank you for your help. Best wishes, Andreas -- Dr. Andreas Sewe | [email protected] | +49 152 56342856 CQSE GmbH | Lichtenbergstrasse 8 | 85748 Garching | www.cqse.eu Amtsgericht Muenchen | HRB 177678 | GF: F. Deissenboeck, M. Feilkas
signature.asc
Description: OpenPGP digital signature
