See the ret.setEnabled(uri != null); line in may above suggestion. It should disable the action dynamically (assuming that uri == null if none is found). What you feel is a pity (not being able to declare constructors for different context object) may be deliberate for performance reasons. The actions api uses reflection, and action objects need to be created quite often. Most features of the platform are rather well thought-out in the end, only it's sometimes not really obvious from the start. Good luck! Boris
Am Mo., 3. Sep. 2018 um 17:58 Uhr schrieb Andreas Sewe <s...@cqse.eu>: > 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 | s...@cqse.eu | +49 152 56342856 > CQSE GmbH | Lichtenbergstrasse 8 | 85748 Garching | www.cqse.eu > Amtsgericht Muenchen | HRB 177678 | GF: F. Deissenboeck, M. Feilkas > > -- Boris Heithecker Dr. Boris Heithecker Lüneburger Str. 30 28870 Ottersberg Tel.: 0 42 05/ 31 58 34