Revision: 1598 http://svn.sourceforge.net/spring-rich-c/?rev=1598&view=rev Author: kevinstembridge Date: 2006-12-16 08:44:53 -0800 (Sat, 16 Dec 2006)
Log Message: ----------- Added Javadoc Modified Paths: -------------- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SwingActionAdapter.java Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SwingActionAdapter.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SwingActionAdapter.java 2006-12-16 16:44:15 UTC (rev 1597) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/SwingActionAdapter.java 2006-12-16 16:44:53 UTC (rev 1598) @@ -23,26 +23,65 @@ import javax.swing.Action; import org.springframework.richclient.command.config.CommandFaceDescriptor; +import org.springframework.richclient.util.Assert; +/** + * An adapter between a Spring Rich Client [EMAIL PROTECTED] ActionCommand} and the Swing + * [EMAIL PROTECTED] Action} interface. + * + * <p> + * This adheres to the standard GoF [EMAIL PROTECTED] Adapter} pattern whereby this class acts as + * a wrapper around an underlying [EMAIL PROTECTED] ActionCommand} to give it the appearance of + * being an [EMAIL PROTECTED] Action}. + * </p> + * + * <p> + * The [EMAIL PROTECTED] PropertyChangeListener} interface is also implemented so that + * instances can be notified of property change events being fired by their underlying command. + * </p> + */ public class SwingActionAdapter extends AbstractAction implements PropertyChangeListener { + private ActionCommand command; + /** + * Creates a new [EMAIL PROTECTED] SwingActionAdapter} with the given underlying action command. The + * newly created instance will add itself as a property change listener of the command. + * + * @param command The underlying action command. + * + * @throws IllegalArgumentException if [EMAIL PROTECTED] command} is null. + */ public SwingActionAdapter(ActionCommand command) { super(); + + Assert.required(command, "command"); this.command = command; command.addPropertyChangeListener(this); command.addEnabledListener(this); update(); + } - public void actionPerformed(ActionEvent e) { - command.actionPerformedHandler.actionPerformed(e); + /** + * Delegates the handling of the given event to the underlying command. + * @param event The action event to be handled. + */ + public void actionPerformed(ActionEvent event) { + command.actionPerformedHandler.actionPerformed(event); } - public void propertyChange(PropertyChangeEvent evt) { + /** + * [EMAIL PROTECTED] + */ + public void propertyChange(PropertyChangeEvent event) { update(); } + /** + * Updates this instance according to the properties provided by the + * underlying command. + */ protected void update() { putValue(Action.ACTION_COMMAND_KEY, command.getActionCommand()); CommandFaceDescriptor face = command.getFaceDescriptor(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ spring-rich-c-cvs mailing list spring-rich-c-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs