Revision: 1247
Author:   peterdb
Date:     2006-07-28 04:11:32 -0700 (Fri, 28 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1247&view=rev

Log Message:
-----------
removed magic bean name from Application. Introduced ApplicationWindowFactory 
as a new service

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/Application.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/form/builder/TableFormBuilder.java

Added Paths:
-----------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationWindowFactory.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationWindowFactory.java
Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/Application.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/Application.java
   2006-07-27 12:06:07 UTC (rev 1246)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/Application.java
   2006-07-28 11:11:32 UTC (rev 1247)
@@ -20,12 +20,10 @@
 import java.util.Observer;
 
 import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.ConfigurableApplicationContext;
 import 
org.springframework.richclient.application.config.ApplicationLifecycleAdvisor;
-import 
org.springframework.richclient.application.support.DefaultApplicationWindow;
 import org.springframework.richclient.image.ImageSource;
 import org.springframework.util.Assert;
 import org.springframework.util.StringUtils;
@@ -42,8 +40,6 @@
 
     private static final String DEFAULT_APPLICATION_IMAGE_KEY = 
"applicationInfo.image";
 
-    private static final String APPLICATION_WINDOW_BEAN_ID = 
"applicationWindowPrototype";
-
     private static Application SOLE_INSTANCE;
 
     private ApplicationContext applicationContext;
@@ -140,7 +136,7 @@
     }
 
     public Image getImage() {
-        if( descriptor != null && descriptor.getImage() != null ) 
+        if( descriptor != null && descriptor.getImage() != null )
             return descriptor.getImage();
 
         ImageSource isrc = (ImageSource) 
services().getService(ImageSource.class);
@@ -158,12 +154,9 @@
     }
 
     protected ApplicationWindow createNewWindow() {
-        try {
-            return (ApplicationWindow) 
getApplicationContext().getBean(APPLICATION_WINDOW_BEAN_ID,
-                    ApplicationWindow.class);
-        } catch( NoSuchBeanDefinitionException e ) {
-            return new DefaultApplicationWindow();
-        }
+        ApplicationWindowFactory windowFactory = (ApplicationWindowFactory) 
services().getService(
+                ApplicationWindowFactory.class);
+        return windowFactory.createApplicationWindow();
     }
 
     public WindowManager getWindowManager() {
@@ -171,8 +164,8 @@
     }
 
     /**
-     * ActiveWindow is tracked by windowManager. When a window gains focus, the
-     * manager will receive this window as the active one.
+     * ActiveWindow is tracked by windowManager. When a window gains focus, 
the manager
+     * will receive this window as the active one.
      * 
      * @return the activeWindow.
      */

Added: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationWindowFactory.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationWindowFactory.java
                              (rev 0)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationWindowFactory.java
      2006-07-28 11:11:32 UTC (rev 1247)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2002-2006 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;
+
+/**
+ * Service interface for creating <code>ApplicationWindow</code>s.
+ * 
+ * @author Peter De Bruycker
+ */
+public interface ApplicationWindowFactory {
+    /**
+     * Create a new <code>ApplicationWindow</code>.
+     * 
+     * @return the window
+     */
+    ApplicationWindow createApplicationWindow();
+}

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
    2006-07-27 12:06:07 UTC (rev 1246)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationServices.java
    2006-07-28 11:11:32 UTC (rev 1247)
@@ -36,6 +36,7 @@
 import org.springframework.core.enums.LabeledEnumResolver;
 import org.springframework.core.enums.StaticLabeledEnumResolver;
 import org.springframework.richclient.application.ApplicationServices;
+import org.springframework.richclient.application.ApplicationWindowFactory;
 import org.springframework.richclient.application.DefaultConversionService;
 import org.springframework.richclient.application.ViewDescriptorRegistry;
 import 
org.springframework.richclient.application.config.ApplicationObjectConfigurer;
@@ -265,6 +266,25 @@
     }
 
     /**
+     * Set the <code>ApplicationWindow</code> factory service implementation
+     * 
+     * @param factory
+     */
+    public void setApplicationWindowFactory( ApplicationWindowFactory factory 
) {
+        services.put( ApplicationWindowFactory.class, factory );
+    }
+
+    /**
+     * Set the <code>ApplicationWindow</code> factory service implementation 
bean id
+     * 
+     * @param factoryId bean id
+     */
+    public void setApplicationWindowFactoryId( String factoryId ) {
+        services.put( ApplicationWindowFactory.class, factoryId );
+    }
+
+
+    /**
      * Set the binder selection strategy service implementation
      * 
      * @param binderSelectionStrategy
@@ -846,6 +866,13 @@
             return new MessageSourceAccessor((MessageSource) 
applicationServices.getService(MessageSource.class));
         }
     };
+    
+    protected static final ImplBuilder applicationWindowFactoryImplBuilder = 
new ImplBuilder() {
+        public Object build( DefaultApplicationServices applicationServices ) {
+            logger.info( "Creating default service impl: 
ApplicationWindowFactory" );
+            return new DefaultApplicationWindowFactory();
+        }
+    };
 
     /**
      * Static initializer to construct the implementation builder map.
@@ -855,6 +882,7 @@
         serviceImplBuilders.put(ApplicationContext.class, 
applicationContextImplBuilder);        
         serviceImplBuilders.put(ApplicationObjectConfigurer.class, 
applicationObjectConfigurerImplBuilder);
         serviceImplBuilders.put(ApplicationSecurityManager.class, 
applicationSecurityManagerImplBuilder);
+        serviceImplBuilders.put(ApplicationWindowFactory.class, 
applicationWindowFactoryImplBuilder);
         serviceImplBuilders.put(BinderSelectionStrategy.class, 
binderSelectionStrategyImplBuilder);
         serviceImplBuilders.put(BindingFactoryProvider.class, 
bindingFactoryProviderImplBuilder);
         serviceImplBuilders.put(ButtonFactory.class, buttonFactoryImplBuilder);

Added: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationWindowFactory.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationWindowFactory.java
                               (rev 0)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/support/DefaultApplicationWindowFactory.java
       2006-07-28 11:11:32 UTC (rev 1247)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2002-2006 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.richclient.application.ApplicationWindow;
+import org.springframework.richclient.application.ApplicationWindowFactory;
+
+/**
+ * <code>ApplicationWindowFactory</code> implementation for
+ * <code>DefaultApplicationWindow</code>.
+ * 
+ * @author Peter De Bruycker
+ * 
+ */
+public class DefaultApplicationWindowFactory implements 
ApplicationWindowFactory {
+    private static final Log logger = LogFactory.getLog( 
DefaultApplicationWindowFactory.class );
+
+    public ApplicationWindow createApplicationWindow() {
+        logger.info( "Creating new DefaultApplicationWindow" );
+
+        return new DefaultApplicationWindow();
+    }
+}

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/builder/TableFormBuilder.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/builder/TableFormBuilder.java
     2006-07-27 12:06:07 UTC (rev 1246)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/form/builder/TableFormBuilder.java
     2006-07-28 11:11:32 UTC (rev 1247)
@@ -20,6 +20,7 @@
 import javax.swing.JScrollPane;
 
 import org.springframework.core.closure.Constraint;
+import org.springframework.richclient.application.ApplicationServicesLocator;
 import org.springframework.richclient.form.binding.Binding;
 import org.springframework.richclient.form.binding.BindingFactory;
 import org.springframework.richclient.layout.TableLayoutBuilder;
@@ -58,6 +59,8 @@
     public JComponent[] add(Binding binding, String attributes) {
         Assert.isTrue(getFormModel() == binding.getFormModel(),
                 "Binding's form model must match FormBuilder's form model");
+        FormComponentInterceptorFactory factory = 
(FormComponentInterceptorFactory)ApplicationServicesLocator.services().getService(FormComponentInterceptorFactory.class);
+        
factory.getInterceptor(getFormModel()).processComponent(binding.getProperty(), 
binding.getControl());
         return addBinding(binding, attributes, getLabelAttributes());
     }
 


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
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to