Revision: 1606 http://svn.sourceforge.net/spring-rich-c/?rev=1606&view=rev Author: kevinstembridge Date: 2006-12-17 14:03:29 -0800 (Sun, 17 Dec 2006)
Log Message: ----------- Added javadoc Modified Paths: -------------- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowViewCommand.java Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowViewCommand.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowViewCommand.java 2006-12-17 20:36:30 UTC (rev 1605) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowViewCommand.java 2006-12-17 22:03:29 UTC (rev 1606) @@ -18,28 +18,59 @@ import org.springframework.richclient.application.ApplicationWindow; import org.springframework.richclient.application.View; import org.springframework.richclient.application.ViewDescriptor; -import org.springframework.richclient.command.ActionCommand; +import org.springframework.richclient.util.Assert; /** - * [EMAIL PROTECTED] ActionCommand}for displaying a [EMAIL PROTECTED] View} based on the provided - * [EMAIL PROTECTED] ViewDescriptor}. + * An action command for displaying a [EMAIL PROTECTED] View} based on the provided [EMAIL PROTECTED] ViewDescriptor}. */ public class ShowViewCommand extends ApplicationWindowAwareCommand { + + /** The identifier of this command. */ + public static final String ID = "showViewCommand"; + private ViewDescriptor viewDescriptor; + /** + * Creates a new [EMAIL PROTECTED] ShowViewCommand} with an id of [EMAIL PROTECTED] #ID}. + * The newly created command will be enabled by default. + */ + //FIXME does this class need a no-args constructor? The class cannot operate without a + //view descriptor and once set, the view descriptor ID will override the one set in this + //constructor anyway. public ShowViewCommand() { - super("showViewCommand"); + super(ID); setEnabled(true); } + /** + * Creates a new [EMAIL PROTECTED] ShowViewCommand} with the given view descriptor and associated + * application window. The new instance will have a command identifier equal to the id from + * the view descriptor, the command will be enabled by default. + * + * @param viewDescriptor The object describing the view that this command will be + * responsible for showing. + * @param window The application window that the command belongs to. + * + * @throw IllegalArgumentException if [EMAIL PROTECTED] viewDescriptor} is null. + */ public ShowViewCommand(ViewDescriptor viewDescriptor, ApplicationWindow window) { this(); + //FIXME does this really need to call this()? It only provides an ID that will be + //overridden anyway when setViewDescriptor is called on the next line. setViewDescriptor(viewDescriptor); setApplicationWindow(window); setEnabled(true); } + /** + * Sets the object that describes the view that is to be opened by this command object. + * + * @param viewDescriptor The view descriptor, cannot be null. + * + * @throws IllegalArgumentException if [EMAIL PROTECTED] viewDescriptor} is null. + */ public final void setViewDescriptor(ViewDescriptor viewDescriptor) { + Assert.required(viewDescriptor, "viewDescriptor"); setId(viewDescriptor.getId()); setLabel(viewDescriptor.getShowViewCommandLabel()); setIcon(viewDescriptor.getIcon()); @@ -47,8 +78,14 @@ this.viewDescriptor = viewDescriptor; } + /** + * Causes the view described by this instance's view descriptor to be shown. + */ protected void doExecuteCommand() { + //FIXME getApplicationWindow can potentially return null. This should probably be + //made an invariant on the ApplicationWindowAwareCommand that it never returns null. + //Same applies to ApplicationWindow.getPage(), can also return null getApplicationWindow().getPage().showView(viewDescriptor); } -} \ No newline at end of file +} 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