Revision: 1784 http://svn.sourceforge.net/spring-rich-c/?rev=1784&view=rev Author: jhoskens Date: 2007-07-19 04:57:52 -0700 (Thu, 19 Jul 2007)
Log Message: ----------- Added javadoc Modified Paths: -------------- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/ApplicationLifecycleAdvisor.java Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/ApplicationLifecycleAdvisor.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/ApplicationLifecycleAdvisor.java 2007-07-19 07:57:39 UTC (rev 1783) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/config/ApplicationLifecycleAdvisor.java 2007-07-19 11:57:52 UTC (rev 1784) @@ -25,131 +25,261 @@ import org.springframework.richclient.exceptionhandling.DefaultRegisterableExceptionHandler; import org.springframework.richclient.exceptionhandling.RegisterableExceptionHandler; import org.springframework.richclient.progress.StatusBarCommandGroup; -import org.springframework.util.Assert; /** + * <p> + * Advisor for the Application. This class provides the startingPageId, an + * exceptionHandler for uncaught exceptions, application wide window + * structures(menu/toolbar/statusbar) and a number of hook methods that are + * called in the startup/closing process. + * </p> + * + * <p> + * The sequence in which the hooks are called is as follows: + * </p> + * + * <pre> + * Application Creation + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#setApplication(Application)} + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onPreInitialize(Application)} + * + * Application Start + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onPreStartup()} + * + * ApplicationWindow Creation + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#setOpeningWindow(ApplicationWindow)} + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onPreWindowOpen(ApplicationWindowConfigurer)} + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#createWindowCommandManager()} + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#getMenuBarCommandGroup()} + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#getToolBarCommandGroup()} + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#getStatusBarCommandGroup()} + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onCommandsCreated(ApplicationWindow)} + * + * ApplicationWindow Creating the JFrame + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onWindowCreated(ApplicationWindow)} + * ApplicationWindow Shows JFrame (setVisible(true)) + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onWindowOpened(ApplicationWindow)} + * + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onPostStartup()} + * </pre> + * + * <p> + * The remaining hook is called when the ApplicationWindow is closed: + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onPreWindowClose(ApplicationWindow)}. + * </p> + * * @author Keith Donald * @author Jim Moore */ public abstract class ApplicationLifecycleAdvisor implements InitializingBean { - private static final String EXCEPTION_HANDLER_KEY = "sun.awt.exception.handler"; - private Application application; + /** Application to work with. */ + private Application application; - private ApplicationWindow openingWindow; + /** The applicationWindow. */ + private ApplicationWindow openingWindow; - private String startingPageId; + /** Initial page to show. */ + private String startingPageId; - private RegisterableExceptionHandler registerableExceptionHandler; + /** ExceptionHandler to catch all uncaught exceptions. */ + private RegisterableExceptionHandler registerableExceptionHandler; - /** - * This is used to allow the ViewDescriptor to be lazily created when the - * ApplicationWindow is opened. Useful when the ApplicationAdvisor needs to - * do things before ViewDescriptor should be created, such as setting up a - * security context. - * - * @param startingViewDescriptorBeanName the name of the bean to create - * - * @see #getStartingViewDescriptor() - */ - public void setStartingPageId(String pageDescriptorId) { - this.startingPageId = pageDescriptorId; - } + /** + * This is used to allow the ViewDescriptor to be lazily created when the + * ApplicationWindow is opened. Useful when the ApplicationAdvisor needs to + * do things before ViewDescriptor should be created, such as setting up a + * security context. + * + * @param pageDescriptorId id of the pageDescriptor bean to show on startup. + * + * @see #getStartingPageId() + */ + public void setStartingPageId(String pageDescriptorId) { + this.startingPageId = pageDescriptorId; + } - /** - * Sets the exception handler which will be registered upon initialization to handle uncaught throwables. - * - * By default this is a DefaultRegisterableExceptionHandler, - * which is inferior to a well configured DelegatingExceptionHandler (java 1.5 only). - * - * @param registerableExceptionHandler the exception handler which will handle uncaught throwables - */ - public void setRegisterableExceptionHandler(RegisterableExceptionHandler registerableExceptionHandler) { - this.registerableExceptionHandler = registerableExceptionHandler; - } + /** + * Sets the exception handler which will be registered upon initialization + * to handle uncaught throwables. + * + * By default this is a DefaultRegisterableExceptionHandler, which is + * inferior to a well configured DelegatingExceptionHandler (java 1.5 only). + * + * @param registerableExceptionHandler the exception handler which will + * handle uncaught throwables + */ + public void setRegisterableExceptionHandler(RegisterableExceptionHandler registerableExceptionHandler) { + this.registerableExceptionHandler = registerableExceptionHandler; + } - public void afterPropertiesSet() throws Exception { - getRegisterableExceptionHandler().registerExceptionHandler(); + /** + * After properties are set, register the exceptionHandler. + */ + public void afterPropertiesSet() throws Exception { + getRegisterableExceptionHandler().registerExceptionHandler(); Assert.state(startingPageId != null, - "startingPageId must be set: it must point to a page descriptor, or a view descriptor for a single view per page"); - } + "startingPageId must be set: it must point to a page descriptor, or a view descriptor for a single view per page"); + } - public String getStartingPageId() { - return startingPageId; - } + /** + * @return the id of the starting Page. + */ + public String getStartingPageId() { + return startingPageId; + } - protected Application getApplication() { - return application; - } + /** + * @return Application. + */ + protected Application getApplication() { + return application; + } - protected ApplicationServices getApplicationServices() { - return ApplicationServicesLocator.services(); - } + /** + * @return ApplicationServices. + */ + protected ApplicationServices getApplicationServices() { + return ApplicationServicesLocator.services(); + } - public void onPreInitialize(Application application) { + /** + * Hook called right after the application has been created. + * + * @param application the application. + */ + public void onPreInitialize(Application application) { - } + } - public void onPreStartup() { + /** + * Hook called right before the applicationWindow is created. + */ + public void onPreStartup() { - } + } - public void onPostStartup() { + /** + * Hook called right after the applicationWindow is created. + */ + public void onPostStartup() { - } + } - public void setOpeningWindow(ApplicationWindow window) { - this.openingWindow = window; - } + /** + * @param window the openingWindow. + */ + public void setOpeningWindow(ApplicationWindow window) { + this.openingWindow = window; + } - public void onPreWindowOpen(ApplicationWindowConfigurer configurer) { - configurer.setTitle(getApplication().getName()); - configurer.setImage(getApplication().getImage()); - } + /** + * Hook called right before the application opens a window. + * + * @param configurer + */ + public void onPreWindowOpen(ApplicationWindowConfigurer configurer) { + configurer.setTitle(getApplication().getName()); + configurer.setImage(getApplication().getImage()); + } - protected final ApplicationWindow getOpeningWindow() { - return openingWindow; - } + /** + * @return the openingWindow. + */ + protected final ApplicationWindow getOpeningWindow() { + return openingWindow; + } - public ApplicationWindowCommandManager createWindowCommandManager() { - return new ApplicationWindowCommandManager(); - } + /** + * Create a [EMAIL PROTECTED] ApplicationWindowCommandManager} for the application. + * + * @return applicationWindowCommandManager. + */ + public ApplicationWindowCommandManager createWindowCommandManager() { + return new ApplicationWindowCommandManager(); + } - public CommandGroup getMenuBarCommandGroup() { - return new CommandGroup(); - } + /** + * Create the menuBar for the application. + * + * @return a CommandGroup. + */ + public CommandGroup getMenuBarCommandGroup() { + return new CommandGroup(); + } - public CommandGroup getToolBarCommandGroup() { - return new CommandGroup(); - } + /** + * Create the toolBar for the application. + * + * @return a CommandGroup. + */ + public CommandGroup getToolBarCommandGroup() { + return new CommandGroup(); + } - public StatusBarCommandGroup getStatusBarCommandGroup() { - return new StatusBarCommandGroup(); - } + /** + * Create the statusBar for the application. + * + * @return a statusBarCommandGroup. + */ + public StatusBarCommandGroup getStatusBarCommandGroup() { + return new StatusBarCommandGroup(); + } - public void onCommandsCreated(ApplicationWindow window) { + /** + * Hook called right after commands are initialized. Typically the next step + * after the get*CommandGroup() methods are called. + * + * @param window applicationWindow. + */ + public void onCommandsCreated(ApplicationWindow window) { - } + } - public void onWindowCreated(ApplicationWindow window) { + /** + * Hook called right after the window (JFrame) of the application is + * created. + * + * @param window applicationWindow. + */ + public void onWindowCreated(ApplicationWindow window) { - } + } - public void onWindowOpened(ApplicationWindow window) { + /** + * Hook called right after the window (JFrame) of the application is shown + * (setVisible(true)). + * + * @param window applicationWindow. + */ + public void onWindowOpened(ApplicationWindow window) { - } + } - public boolean onPreWindowClose(ApplicationWindow window) { - return true; - } + /** + * Check if the ApplicationWindow can close. + * + * @param window the applicationWindow that should be closed. + * @return <code>true</code> if the window may close. + */ + public boolean onPreWindowClose(ApplicationWindow window) { + return true; + } - public RegisterableExceptionHandler getRegisterableExceptionHandler() { - if (registerableExceptionHandler == null) { - this.registerableExceptionHandler = new DefaultRegisterableExceptionHandler(); - } - return registerableExceptionHandler; - } + /** + * @return the ExceptionHandler to be registered as + * uncaughtExceptionHandler. + */ + public RegisterableExceptionHandler getRegisterableExceptionHandler() { + if (registerableExceptionHandler == null) { + this.registerableExceptionHandler = new DefaultRegisterableExceptionHandler(); + } + return registerableExceptionHandler; + } + /** + * @param application set the current application. + */ public void setApplication(Application application) { this.application = application; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ spring-rich-c-cvs mailing list spring-rich-c-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs