Revision: 1748 http://svn.sourceforge.net/spring-rich-c/?rev=1748&view=rev Author: jhoskens Date: 2007-04-19 06:49:11 -0700 (Thu, 19 Apr 2007)
Log Message: ----------- A page must take it's pageComponents into account when closing (canClose(pageComponent) may return false) And a window must take the return value of page.close() into account to be able to stop the window from closing. Modified Paths: -------------- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractApplicationPage.java trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractApplicationWindow.java Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractApplicationPage.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractApplicationPage.java 2007-04-19 13:46:37 UTC (rev 1747) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractApplicationPage.java 2007-04-19 13:49:11 UTC (rev 1748) @@ -236,18 +236,20 @@ * lost" and "closed"), and will activate another <code>PageComponent</code> * (if there is one). * <p> - * Does nothing if this <code>ApplicationPage</code> doesn't contain the - * given <code>PageComponent</code>. + * Returns <code>false</code> if this <code>ApplicationPage</code> + * doesn't contain the given <code>PageComponent</code>. * * @param pageComponent the <code>PageComponent</code> + * @return boolean <code>true</code> if pageComponent was successfully + * closed. */ - public void close(PageComponent pageComponent) { + public boolean close(PageComponent pageComponent) { if (!pageComponent.canClose()) { - return; + return false; } if (!pageComponents.contains(pageComponent)) { - return; + return false; } if (pageComponent == activeComponent) { @@ -263,6 +265,7 @@ if (activeComponent == null) { setActiveComponent(); } + return true; } /** @@ -275,7 +278,8 @@ public boolean close() { for (Iterator iter = new HashSet(pageComponents).iterator(); iter.hasNext();) { PageComponent component = (PageComponent) iter.next(); - close(component); + if (!close(component)) + return false; } return true; } Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractApplicationWindow.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractApplicationWindow.java 2007-04-19 13:46:37 UTC (rev 1747) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractApplicationWindow.java 2007-04-19 13:49:11 UTC (rev 1748) @@ -333,11 +333,24 @@ this.pageListeners.remove( listener ); } + /** + * Close this window. First checks with the advisor by calling the + * [EMAIL PROTECTED] ApplicationLifecycleAdvisor#onPreWindowClose(ApplicationWindow)} + * method. Then tries to close it's currentPage. If both are successfull, + * the window will be disposed and removed from the [EMAIL PROTECTED] WindowManager}. + * + * @return boolean <code>true</code> if both, the advisor and the + * currentPage allow the closing action. + */ public boolean close() { boolean canClose = getAdvisor().onPreWindowClose( this ); if( canClose ) { + // check if page can be closed if( currentPage != null ) { - currentPage.close(); + canClose = currentPage.close(); + // page cannot be closed, exit method and do not dispose + if (!canClose) + return canClose; } if( control != null ) { 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