Revision: 1722 http://svn.sourceforge.net/spring-rich-c/?rev=1722&view=rev Author: mathiasbr Date: 2007-02-20 02:02:58 -0800 (Tue, 20 Feb 2007)
Log Message: ----------- patch from Rogan Dawes to add PageDescriptorRegistry support see http://opensource.atlassian.com/projects/spring/browse/RCP-458 Modified Paths: -------------- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptor.java trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractPageDescriptor.java trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/MultiViewPageDescriptor.java trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/SingleViewPageDescriptor.java Added Paths: ----------- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptorRegistry.java trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/BeanFactoryPageDescriptorRegistry.java trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageCommand.java trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageMenu.java Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptor.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptor.java 2007-02-15 18:25:39 UTC (rev 1721) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptor.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -1,12 +1,12 @@ /* * Copyright 2002-2004 the original author or authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -15,6 +15,8 @@ */ package org.springframework.richclient.application; +import org.springframework.richclient.command.ActionCommand; +import org.springframework.richclient.command.config.CommandButtonLabelInfo; import org.springframework.richclient.core.DescribedElement; import org.springframework.richclient.core.VisualizedElement; @@ -22,4 +24,19 @@ public String getId(); public void buildInitialLayout(PageLayoutBuilder pageLayout); -} \ No newline at end of file + + /** + * Create a command that when executed, will attempt to show the + * page component described by this descriptor in the provided + * application window. + * + * @param window The window + * + * @return The show page component command. + */ + public ActionCommand createShowPageCommand(ApplicationWindow window); + + public CommandButtonLabelInfo getShowPageCommandLabel(); + + +} Added: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptorRegistry.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptorRegistry.java (rev 0) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptorRegistry.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -0,0 +1,46 @@ +/* + * Copyright 2002-2004 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.springframework.richclient.application; + +/** + * A registry for [EMAIL PROTECTED] PageDescriptor} definitions. + * + * @author Keith Donald + * @author Rogan Dawes + * + */ +public interface PageDescriptorRegistry { + + /** + * Returns an array of all the page descriptors in the registry. + * + * @return An array of all the page descriptors in the registry. The array may be empty but + * will never be null. + */ + public PageDescriptor[] getPageDescriptors(); + + /** + * Returns the page descriptor with the given identifier, or null if no such descriptor + * exists in the registry. + * + * @param pageDescriptorId The id of the page descriptor to be returned. + * @return The page descriptor with the given id, or null. + * + * @throws IllegalArgumentException if [EMAIL PROTECTED] pageDescriptorId} is null. + */ + public PageDescriptor getPageDescriptor(String pageDescriptorId); + +} Property changes on: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/PageDescriptorRegistry.java ___________________________________________________________________ Name: svn:keywords + URL Author Revision Date Name: svn:eol-style + native Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractPageDescriptor.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractPageDescriptor.java 2007-02-15 18:25:39 UTC (rev 1721) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/AbstractPageDescriptor.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -17,7 +17,11 @@ import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; +import org.springframework.richclient.application.ApplicationWindow; import org.springframework.richclient.application.PageDescriptor; +import org.springframework.richclient.command.ActionCommand; +import org.springframework.richclient.command.config.CommandButtonLabelInfo; +import org.springframework.richclient.command.support.ShowPageCommand; import org.springframework.richclient.core.LabeledObjectSupport; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -25,7 +29,7 @@ /** * Abstract base class for [EMAIL PROTECTED] PageDescriptor} implementations. Extends * [EMAIL PROTECTED] LabeledObjectSupport} for gui related configuration. - * + * * @author Peter De Bruycker */ public abstract class AbstractPageDescriptor extends LabeledObjectSupport implements PageDescriptor, BeanNameAware, @@ -46,6 +50,16 @@ } public void afterPropertiesSet() throws Exception { - Assert.state(StringUtils.hasText(id), "id is mandatory"); + Assert.state(StringUtils.hasText(getId()), "id is mandatory"); } + + public CommandButtonLabelInfo getShowPageCommandLabel() { + return getLabel(); + } + + public ActionCommand createShowPageCommand(ApplicationWindow window) { + return new ShowPageCommand(this, window); + } + + } Added: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/BeanFactoryPageDescriptorRegistry.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/BeanFactoryPageDescriptorRegistry.java (rev 0) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/BeanFactoryPageDescriptorRegistry.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -0,0 +1,74 @@ +/* + * Copyright 2002-2004 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.springframework.richclient.application.support; + +import java.util.Map; + +import org.springframework.beans.factory.BeanNotOfRequiredTypeException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.context.support.ApplicationObjectSupport; +import org.springframework.richclient.application.PageDescriptor; +import org.springframework.richclient.application.PageDescriptorRegistry; +import org.springframework.richclient.util.Assert; + + +/** + * A simple [EMAIL PROTECTED] PageDescriptorRegistry} implementation that pulls singleton page definitions out + * of a spring application context. This class is intended to be managed by a Spring IoC container. + * If being created programatically, be sure to call the + * [EMAIL PROTECTED] #setApplicationContext(org.springframework.context.ApplicationContext)} method. + * + * + * @author Keith Donald + * @author Kevin Stembridge + * @author Rogan Dawes + */ +public class BeanFactoryPageDescriptorRegistry extends ApplicationObjectSupport implements PageDescriptorRegistry { + + /** + * [EMAIL PROTECTED] + */ + public PageDescriptor[] getPageDescriptors() { + Map beans = getApplicationContext().getBeansOfType(PageDescriptor.class, false, false); + return (PageDescriptor[])beans.values().toArray(new PageDescriptor[beans.size()]); + } + + /** + * Returns the page descriptor with the given identifier, or null if no such bean definition + * with the given name exists in the current application context. + * + * @param pageName The bean name of the page descriptor that is to be retrieved from the + * underlying application context. Must not be null. + * + * @throws IllegalArgumentException if [EMAIL PROTECTED] pageName} is null. + * @throws BeanNotOfRequiredTypeException if the bean retrieved from the underlying application + * context is not of type [EMAIL PROTECTED] PageDescriptor}. + * + */ + public PageDescriptor getPageDescriptor(String pageName) { + + Assert.required(pageName, "pageName"); + + try { + return (PageDescriptor) getApplicationContext().getBean(pageName, PageDescriptor.class); + } + catch (NoSuchBeanDefinitionException e) { + return null; + } + + } + +} Property changes on: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/BeanFactoryPageDescriptorRegistry.java ___________________________________________________________________ Name: svn:keywords + URL Author Revision Date Name: svn:eol-style + native Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java 2007-02-15 18:25:39 UTC (rev 1721) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -40,6 +40,7 @@ import org.springframework.richclient.application.ApplicationWindowFactory; import org.springframework.richclient.application.DefaultConversionServiceFactoryBean; import org.springframework.richclient.application.PageComponentPaneFactory; +import org.springframework.richclient.application.PageDescriptorRegistry; import org.springframework.richclient.application.ServiceNotFoundException; import org.springframework.richclient.application.ViewDescriptorRegistry; import org.springframework.richclient.application.config.ApplicationObjectConfigurer; @@ -85,7 +86,7 @@ * service implementations will be set <b>BY ID</b>. The use of service bean ids instead of direct bean references is * to avoid numerous problems with cyclic dependencies and other order dependent operations. So, a typical incarnation * might look like this: - * + * * <pre> * <bean id="applicationServices" * class="org.springframework.richclient.application.support.DefaultApplicationServices"> @@ -96,7 +97,7 @@ * <property name="formComponentInterceptorFactoryId"><idref bean="formComponentInterceptorFactory"/></property> * </bean> * </pre> - * + * * Note the use of the <code>idref</code> form instead of just using a string value. This is the preferred syntax in * order to avoid having misspelled bean names go unreported. * <p> @@ -113,7 +114,7 @@ * <li>If the service impl. is not found yet and a default implementation can be provided, it will be constructed at * that time. Default implementations are provided for essentially all services referenced by the platform.</li> * </ol> - * + * * @author Larry Streepy */ public class DefaultApplicationServices implements ApplicationServices, ApplicationContextAware { @@ -140,7 +141,7 @@ /** * Constuct using the given application context. - * + * * @param applicationContext to use for locating named services (beans) */ public DefaultApplicationServices( ApplicationContext applicationContext ) { @@ -167,7 +168,7 @@ * Get a service of the indicated type. If no service definition for the requested * type is found in the application context, then a reasonable default implementation * will be created. - * + * * @param serviceType Type of service being requested * @return Service instance * @throws ServiceNotFoundException if the service is not found and no suitable @@ -210,7 +211,7 @@ * keys that are either class instances (the serviceType) or the String name of the * class and values that are the implementation to use for that service or an idref to * a bean that is the implementation (passed as a String). - * + * * @param entryMap Map of entries */ public void setRegistryEntries( Map entryMap ) { @@ -243,7 +244,7 @@ /** * Set the application object configurer service implementation. - * + * * @param applicationObjectConfigurer */ public void setApplicationObjectConfigurer( ApplicationObjectConfigurer applicationObjectConfigurer ) { @@ -252,7 +253,7 @@ /** * Set the application object configurer service implementation bean id - * + * * @param applicationObjectConfigurerId bean id */ public void setApplicationObjectConfigurerId( String applicationObjectConfigurerId ) { @@ -261,7 +262,7 @@ /** * Set the application security manager service implementation. - * + * * @param applicationSecurityManager instance to use */ public void setApplicationSecurityManager( ApplicationSecurityManager applicationSecurityManager ) { @@ -270,7 +271,7 @@ /** * Set the application security manager service implementation bean id - * + * * @param applicationSecurityManagerId bean id */ public void setApplicationSecurityManagerId( String applicationSecurityManagerId ) { @@ -279,7 +280,7 @@ /** * Set the <code>ApplicationWindow</code> factory service implementation - * + * * @param factory */ public void setApplicationWindowFactory( ApplicationWindowFactory factory ) { @@ -288,7 +289,7 @@ /** * Set the <code>ApplicationWindow</code> factory service implementation bean id - * + * * @param factoryId bean id */ public void setApplicationWindowFactoryId( String factoryId ) { @@ -297,7 +298,7 @@ /** * Set the <code>ApplicationPage</code> factory service implementation - * + * * @param factory */ public void setApplicationPageFactory( ApplicationPageFactory factory ) { @@ -306,7 +307,7 @@ /** * Set the <code>ApplicationPage</code> factory service implementation bean id - * + * * @param factoryId bean id */ public void setApplicationPageFactoryId( String factoryId ) { @@ -315,7 +316,7 @@ /** * Set the <code>PageComponentPane</code> factory service implementation bean - * + * * @param factory bean id */ public void setPageComponentPaneFactory( PageComponentPaneFactory factory ) { @@ -324,7 +325,7 @@ /** * Set the <code>PageComponentPane</code> factory service implementation bean id - * + * * @param factoryId bean id */ public void setPageComponentPaneFactoryId( String factoryId ) { @@ -333,7 +334,7 @@ /** * Set the binder selection strategy service implementation - * + * * @param binderSelectionStrategy */ public void setBinderSelectionStrategy( BinderSelectionStrategy binderSelectionStrategy ) { @@ -342,7 +343,7 @@ /** * Set the binder selection strategy service implementation bean id - * + * * @param binderSelectionStrategyId bean id */ public void setBinderSelectionStrategyId( String binderSelectionStrategyId ) { @@ -351,7 +352,7 @@ /** * Set the binding factory provider service implementation - * + * * @param bindingFactoryProvider */ public void setBindingFactoryProvider( BindingFactoryProvider bindingFactoryProvider ) { @@ -360,7 +361,7 @@ /** * Set the binding factory provider service implementation bean id - * + * * @param bindingFactoryProviderId bean id */ public void setBindingFactoryProviderId( String bindingFactoryProviderId ) { @@ -369,7 +370,7 @@ /** * Set the command services service implementation - * + * * @param commandServices */ public void setCommandServices( CommandServices commandServices ) { @@ -378,7 +379,7 @@ /** * Set the command services service implementation bean id - * + * * @param commandServicesId bean id */ public void setCommandServicesId( String commandServicesId ) { @@ -387,7 +388,7 @@ /** * Set the command configurer service implementation - * + * * @param commandConfigurer */ public void setCommandConfigurer( CommandConfigurer commandConfigurer ) { @@ -396,7 +397,7 @@ /** * Set the command configurer service implementation bean id - * + * * @param commandConfigurerId bean id */ public void setCommandConfigurerId( String commandConfigurerId ) { @@ -405,7 +406,7 @@ /** * Set the button factory service implementation - * + * * @param buttonFactory */ public void setButtonFactory( ButtonFactory buttonFactory ) { @@ -414,7 +415,7 @@ /** * Set the button factory service implementation bean id - * + * * @param buttonFactoryId bean id */ public void setButtonFactoryId( String buttonFactoryId ) { @@ -423,7 +424,7 @@ /** * Set the menu factory service implementation - * + * * @param menuFactory */ public void setMenuFactory( MenuFactory menuFactory ) { @@ -432,7 +433,7 @@ /** * Set the menu factory service implementation bean id - * + * * @param menuFactoryId bean id */ public void setMenuFactoryId( String menuFactoryId ) { @@ -441,7 +442,7 @@ /** * Set the component factory service implementation - * + * * @param componentFactory */ public void setComponentFactory( ComponentFactory componentFactory ) { @@ -450,7 +451,7 @@ /** * Set the component factory service implementation bean id - * + * * @param componentFactoryId bean id */ public void setComponentFactoryId( String componentFactoryId ) { @@ -459,7 +460,7 @@ /** * Set the conversion service service implementation - * + * * @param conversionService */ public void setConversionService( ConversionService conversionService ) { @@ -468,7 +469,7 @@ /** * Set the conversion service service implementation bean id - * + * * @param conversionServiceId bean id */ public void setConversionServiceId( String conversionServiceId ) { @@ -477,7 +478,7 @@ /** * Set the form component interceptor factory service implementation - * + * * @param formComponentInterceptorFactory */ public void setFormComponentInterceptorFactory( FormComponentInterceptorFactory formComponentInterceptorFactory ) { @@ -486,7 +487,7 @@ /** * Set the form component interceptor factory service implementation bean id - * + * * @param formComponentInterceptorFactoryId bean id */ public void setFormComponentInterceptorFactoryId( String formComponentInterceptorFactoryId ) { @@ -495,7 +496,7 @@ /** * Set the field face descriptor source service implementation - * + * * @param fieldFaceSource */ public void setFieldFaceSource( FieldFaceSource fieldFaceSource ) { @@ -504,7 +505,7 @@ /** * Set the field face descriptor source service implementation bean id - * + * * @param fieldFaceSourceId bean id */ public void setFieldFaceSourceId( String fieldFaceSourceId ) { @@ -513,7 +514,7 @@ /** * Set the icon source service implementation - * + * * @param iconSource */ public void setIconSource( IconSource iconSource ) { @@ -522,7 +523,7 @@ /** * Set the icon source service implementation bean id - * + * * @param iconSourceId bean id */ public void setIconSourceId( String iconSourceId ) { @@ -531,7 +532,7 @@ /** * Set the image source service implementation - * + * * @param imageSource */ public void setImageSource( ImageSource imageSource ) { @@ -540,7 +541,7 @@ /** * Set the image source service implementation bean id - * + * * @param imageSourceId bean id */ public void setImageSourceId( String imageSourceId ) { @@ -549,7 +550,7 @@ /** * Set the labeled enum resolver service implementation - * + * * @param labeledEnumResolver */ public void setLabeledEnumResolver( LabeledEnumResolver labeledEnumResolver ) { @@ -558,7 +559,7 @@ /** * Set the labeled enum resolver service implementation bean id - * + * * @param labeledEnumResolverId bean id */ public void setLabeledEnumResolverId( String labeledEnumResolverId ) { @@ -567,7 +568,7 @@ /** * Set the message source service implementation - * + * * @param messageSource */ public void setMessageSource( MessageSource messageSource ) { @@ -576,7 +577,7 @@ /** * Set the message source service implementation bean id - * + * * @param messageSourceId bean id */ public void setMessageSourceId( String messageSourceId ) { @@ -585,7 +586,7 @@ /** * Set the message source accessor service implementation - * + * * @param messageSourceAccessor */ public void setMessageSourceAccesor( MessageSourceAccessor messageSourceAccessor ) { @@ -594,7 +595,7 @@ /** * Set the message source accessor service implementation bean id - * + * * @param messageSourceAccessorId bean id */ public void setMessageSourceAccesorId( String messageSourceAccessorId ) { @@ -603,7 +604,7 @@ /** * Set the rules source service implementation - * + * * @param rulesSource */ public void setRulesSource( RulesSource rulesSource ) { @@ -612,7 +613,7 @@ /** * Set the rules source service implementation bean id - * + * * @param rulesSourceId bean id */ public void setRulesSourceId( String rulesSourceId ) { @@ -621,7 +622,7 @@ /** * Set the security controller manager service implementation - * + * * @param securityControllerManager instance to use */ public void setSecurityControllerManager( SecurityControllerManager securityControllerManager ) { @@ -630,7 +631,7 @@ /** * Set the security controller manager service implementation bean id - * + * * @param securityControllerManagerId bean id */ public void setSecurityControllerManagerId( String securityControllerManagerId ) { @@ -639,7 +640,7 @@ /** * Set the value change detector service imlpementation. - * + * * @param valueChangeDetector instance to use */ public void setValueChangeDetector( ValueChangeDetector valueChangeDetector ) { @@ -648,7 +649,7 @@ /** * Set the value change detector service imlpementation bean id - * + * * @param valueChangeDetectorId bean id */ public void setValueChangeDetectorId( String valueChangeDetectorId ) { @@ -657,7 +658,7 @@ /** * Set the view descriptor registry service implementation - * + * * @param viewDescriptorRegistry */ public void setViewDescriptorRegistry( ViewDescriptorRegistry viewDescriptorRegistry ) { @@ -665,8 +666,17 @@ } /** + * Set the page descriptor registry service implementation + * + * @param pageDescriptorRegistry + */ + public void setPageDescriptorRegistry( PageDescriptorRegistry pageDescriptorRegistry ) { + services.put( PageDescriptorRegistry.class, pageDescriptorRegistry ); + } + + /** * Set the message translator registry service implementation - * + * * @param messageTranslatorFactory */ public void setMessageTranslatorFactory( MessageTranslatorFactory messageTranslatorFactory ) { @@ -675,7 +685,7 @@ /** * Set the message translator registry service implementation bean id - * + * * @param messageTranslatorFactory */ public void setMessageTranslatorFactoryId( String messageTranslatorFactoryId ) { @@ -684,7 +694,7 @@ /** * Set the view descriptor registry service implementation bean id - * + * * @param viewDescriptorRegistryId bean id */ public void setViewDescriptorRegistryId( String viewDescriptorRegistryId ) { @@ -692,8 +702,17 @@ } /** + * Set the page descriptor registry service implementation bean id + * + * @param pageDescriptorRegistryId bean id + */ + public void setPageDescriptorRegistryId( String pageDescriptorRegistryId ) { + services.put( PageDescriptorRegistry.class, pageDescriptorRegistryId ); + } + + /** * Get the implementation of a service by using the decapitalized shortname of the serviceType class name. - * + * * @param serviceType * the service class to lookup the bean definition * @return the found service implementation if a bean definition can be found and it implements the required service @@ -724,7 +743,7 @@ /** * Get the default implementation of a service according to the service type. If no * default implementation is available, then a null is returned. - * + * * @param serviceType Type of service requested * @return Default service implementation, or null if none defined */ @@ -741,7 +760,7 @@ * Tests if the application context contains a bean definition by using the decapitalized shortname of the serviceType class name * @param serviceType the service class to lookup the bean definition * @return true if a bean definition is found in the current application context, otherwise false - * + * * @see ClassUtils#getShortNameAsProperty(Class) */ protected boolean containsServiceForClassType(Class serviceType) { @@ -750,7 +769,7 @@ /** * Tests if a default implementation for the requested service type is available - * + * * @param serviceType the requested service type * @return true if a default implementation is available otherwise false. */ @@ -764,7 +783,7 @@ protected interface ImplBuilder { /** * Build the service implementation. - * + * * @param applicationServices reference to service locator * @return service implementation */ @@ -924,6 +943,15 @@ } }; + protected static final ImplBuilder pageDescriptorRegistryImplBuilder = new ImplBuilder() { + public Object build( DefaultApplicationServices applicationServices ) { + logger.info( "Creating default service impl: PageDescriptorRegistry" ); + BeanFactoryPageDescriptorRegistry impl = new BeanFactoryPageDescriptorRegistry(); + impl.setApplicationContext( applicationServices.getApplicationContext() ); + return impl; + } + }; + protected static final ImplBuilder messageTranslatorFactoryImplBuilder = new ImplBuilder() { public Object build( DefaultApplicationServices applicationServices ) { logger.info( "Creating default service impl: MessageTranslatorFactory" ); @@ -1006,6 +1034,7 @@ serviceImplBuilders.put( SecurityControllerManager.class, SecurityControllerManagerImplBuilder ); serviceImplBuilders.put( ValueChangeDetector.class, valueChangeDetectorImplBuilder ); serviceImplBuilders.put( ViewDescriptorRegistry.class, viewDescriptorRegistryImplBuilder ); + serviceImplBuilders.put( PageDescriptorRegistry.class, pageDescriptorRegistryImplBuilder ); serviceImplBuilders.put( MessageTranslatorFactory.class, messageTranslatorFactoryImplBuilder ); } } Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/MultiViewPageDescriptor.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/MultiViewPageDescriptor.java 2007-02-15 18:25:39 UTC (rev 1721) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/MultiViewPageDescriptor.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -22,32 +22,24 @@ import org.springframework.richclient.application.PageComponent; import org.springframework.richclient.application.PageDescriptor; import org.springframework.richclient.application.PageLayoutBuilder; -import org.springframework.util.Assert; -import org.springframework.util.StringUtils; /** * Base class for [EMAIL PROTECTED] PageDescriptor} implementations that support multiple * [EMAIL PROTECTED] PageComponent}s - * + * * @author Peter De Bruycker */ public class MultiViewPageDescriptor extends AbstractPageDescriptor { private List viewDescriptors = new ArrayList(); - private String id; - - public String getId() { - return id; - } - public void buildInitialLayout(PageLayoutBuilder pageLayout) { for (Iterator iter = viewDescriptors.iterator(); iter.hasNext();) { String viewDescriptorId = (String) iter.next(); pageLayout.addView(viewDescriptorId); } } - + public List getViewDescriptors() { return viewDescriptors; } @@ -56,15 +48,8 @@ this.viewDescriptors = viewDescriptors; } - public void setId(String id) { - this.id = id; - } - public void setBeanName(String name) { setId(name); } - public void afterPropertiesSet() throws Exception { - Assert.state(StringUtils.hasText(id), "id is mandatory"); - } } Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/SingleViewPageDescriptor.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/SingleViewPageDescriptor.java 2007-02-15 18:25:39 UTC (rev 1721) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/SingleViewPageDescriptor.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -1,12 +1,12 @@ /* * Copyright 2002-2004 the original author or authors. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -19,11 +19,10 @@ import javax.swing.Icon; -import org.springframework.richclient.application.PageDescriptor; import org.springframework.richclient.application.PageLayoutBuilder; import org.springframework.richclient.application.ViewDescriptor; -public class SingleViewPageDescriptor implements PageDescriptor { +public class SingleViewPageDescriptor extends AbstractPageDescriptor { private ViewDescriptor viewDescriptor; @@ -60,4 +59,4 @@ layout.addView(viewDescriptor.getId()); } -} \ No newline at end of file +} Added: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageCommand.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageCommand.java (rev 0) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageCommand.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -0,0 +1,92 @@ +/* + * Copyright 2002-2004 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package org.springframework.richclient.command.support; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.richclient.application.ApplicationWindow; +import org.springframework.richclient.application.PropertyNotSetException; +import org.springframework.richclient.application.PageDescriptor; +import org.springframework.richclient.util.Assert; + +/** + * An action command for displaying a [EMAIL PROTECTED] Page} based on a provided [EMAIL PROTECTED] PageDescriptor}. + */ +public class ShowPageCommand extends ApplicationWindowAwareCommand implements InitializingBean { + + private PageDescriptor pageDescriptor; + + /** + * Creates a new uninitialized [EMAIL PROTECTED] ShowPageCommand}. The [EMAIL PROTECTED] applicationWindow} and + * [EMAIL PROTECTED] pageDescriptor} properties must be set before using the new instance. + */ + public ShowPageCommand() { + //do nothing + } + + /** + * Creates a new [EMAIL PROTECTED] ShowPageCommand} with the given page descriptor and associated + * application window. The new instance will have a command identifier equal to the id from + * the page descriptor, the command will be enabled by default. + * + * @param pageDescriptor The object describing the page that this command will be + * responsible for showing. + * @param applicationWindow The application window that the command belongs to. + * + * @throw IllegalArgumentException if [EMAIL PROTECTED] pageDescriptor} or [EMAIL PROTECTED] applicationWindow} are null. + */ + public ShowPageCommand(PageDescriptor pageDescriptor, ApplicationWindow applicationWindow) { + Assert.required(applicationWindow, "applicationWindow"); + setPageDescriptor(pageDescriptor); + setApplicationWindow(applicationWindow); + setEnabled(true); + } + + /** + * [EMAIL PROTECTED] + */ + public void afterPropertiesSet() { + PropertyNotSetException.throwIfNull(getApplicationWindow(), "applicationWindow", getClass()); + PropertyNotSetException.throwIfNull(this.pageDescriptor, "pageDescriptor", getClass()); + } + + /** + * Sets the descriptor for the page that is to be opened by this command object. This + * command object will be assigned the id, label, icon, and caption from the given page + * descriptor. + * + * @param pageDescriptor The page descriptor, cannot be null. + * + * @throws IllegalArgumentException if [EMAIL PROTECTED] pageDescriptor} is null. + */ + public final void setPageDescriptor(PageDescriptor pageDescriptor) { + Assert.required(pageDescriptor, "pageDescriptor"); + setId(pageDescriptor.getId()); + setLabel(pageDescriptor.getShowPageCommandLabel()); + setIcon(pageDescriptor.getIcon()); + setCaption(pageDescriptor.getCaption()); + this.pageDescriptor = pageDescriptor; + } + + /** + * Causes the page described by this instance's page 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. + getApplicationWindow().showPage(this.pageDescriptor); + } + +} Property changes on: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageCommand.java ___________________________________________________________________ Name: svn:keywords + URL Author Revision Date Name: svn:eol-style + native Added: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageMenu.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageMenu.java (rev 0) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageMenu.java 2007-02-20 10:02:58 UTC (rev 1722) @@ -0,0 +1,78 @@ +/* + * Copyright 2002-2004 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.richclient.command.support; + +import org.springframework.richclient.application.ApplicationServices; +import org.springframework.richclient.application.ApplicationServicesLocator; +import org.springframework.richclient.application.ApplicationWindow; +import org.springframework.richclient.application.PageDescriptor; +import org.springframework.richclient.application.PageDescriptorRegistry; +import org.springframework.richclient.application.config.ApplicationWindowAware; +import org.springframework.richclient.command.CommandGroup; + +/** + * A menu containing a collection of sub-menu items that each display a given page. + * + * @author Keith Donald + * @author Rogan Dawes + */ +public class ShowPageMenu extends CommandGroup implements ApplicationWindowAware { + + /** The identifier of this command. */ + public static final String ID = "showPageMenu"; + + private ApplicationWindow window; + + /** + * Creates a new [EMAIL PROTECTED] ShowPageMenu} with an id of [EMAIL PROTECTED] #ID}. + */ + public ShowPageMenu() { + super(ID); + } + + /** + * [EMAIL PROTECTED] + */ + public void setApplicationWindow(ApplicationWindow window) { + this.window = window; + } + + /** + * Called after dependencies have been set, populates this menu with action command objects + * that will each show a given page when executed. The collection of 'show page' commands will + * be determined by querying the [EMAIL PROTECTED] PageDescriptorRegistry} retrieved from + * [EMAIL PROTECTED] ApplicationServices}. + */ + public void afterPropertiesSet() { + super.afterPropertiesSet(); + //TODO should this be confirming that 'this.window' is not null? + populate(); + } + + private void populate() { + PageDescriptorRegistry pageDescriptorRegistry + = (PageDescriptorRegistry) ApplicationServicesLocator + .services() + .getService(PageDescriptorRegistry.class); + + PageDescriptor[] pages = pageDescriptorRegistry.getPageDescriptors(); + for( int i = 0; i < pages.length; i++ ) { + PageDescriptor page = pages[i]; + addInternal(page.createShowPageCommand(window)); + } + } + +} Property changes on: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/command/support/ShowPageMenu.java ___________________________________________________________________ Name: svn:keywords + URL Author Revision Date Name: svn:eol-style + native 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