Re: Action and ActionConvertors
[email protected] Wed, 02 Mar 2005 09:49:21 +0100
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Organization | http://freemail.web.de/ |
| Message-ID | <[email protected]> |
List for Users of Carlsbad Cubes' Technologies and Products <[email protected]> schrieb am 01.03.05 23:10:22: > > >Sorry if this is clumsy but why don't implement the actions in your > >wizard base (the usual, public action-way)? Just call a function > >(abstract or default implementation) which is the overiden by your > >wizared-enabled classes? You may then have/use your getters just through > >some kind of delegation to these public actions... > > > > > >Frank > > hey that's what i ended up doing, and it's quite clean.. > > public Action aContinue = new AbstractAction() { > public void actionPerformed(java.awt.event.ActionEvent e) { > showNextCard(); > } > }; > > public Action aBack = new AbstractAction() { > public void actionPerformed(java.awt.event.ActionEvent e) { > showPreviousCard(); > } > }; > > and > > public void setBack (Action act){ > aBack = act; > } > > public void setContinueAction (Action act) > { > aContinue = act; > } > > all in the WizardBase.. the subclasses that want to override just call these setters with > the actions they want.. > > The only problem is, this must be done in the constructor of the subclasses, otherwise SwiX > will pick up the default implementations from the base class using Reflection. Hm, the interesting part is missing: your showPreviousCard() and showNextCard() functions. In the descending classes you have all access you need to the actions, eg enable/disable them and the like. The setXxxxAction(Action) methods are not really needed... > > Is this what you meant? > Not quite, honestly ;) The whole idea was to get rid of re-implementing actions in your descendent classes. Use delegation, if you have to -- it solves the dependencies of real actions -- just implement the methods provided through delegation by other ones if you do not use actions anymore... Frank > > -- > Nandan Bagchee > > Excuse me, but what the hell? > > -- Slava Pestov, on seeing: > FunctorParser parser = new FunctorParser(); > BinaryFunctor toggleOther = parser.parseBinary("x.setEnabled(!x.isEnabled())", > JButton.class, ActionEvent.class); > > > > _______________________________________________ > Forum mailing list > [email protected] > http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com