Revision: 1509
          http://svn.sourceforge.net/spring-rich-c/?rev=1509&view=rev
Author:   mathiasbr
Date:     2006-10-15 06:01:42 -0700 (Sun, 15 Oct 2006)

Log Message:
-----------
applied javadoc patch from RCP-419 (RCP-419-2.patch) with slight modifications:

change of pom.xml is not applied.
Introducing MonitoringSplashScreen interface
no exception will be thrown if no splash.title is defined in message source
BeanPostProcessor implementation of ApplicationLauchner moved to inner class

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/AbstractSplashScreen.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/ProgressSplashScreen.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/SimpleSplashScreen.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/SplashScreen.java

Added Paths:
-----------
    
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/MonitoringSplashScreen.java

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
   2006-10-15 09:00:19 UTC (rev 1508)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/ApplicationLauncher.java
   2006-10-15 13:01:42 UTC (rev 1509)
@@ -26,7 +26,9 @@
 import org.springframework.beans.factory.config.BeanPostProcessor;
 import 
org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
+import 
org.springframework.richclient.application.splash.MonitoringSplashScreen;
 import org.springframework.richclient.application.splash.SplashScreen;
 import org.springframework.richclient.progress.ProgressMonitor;
 import org.springframework.util.Assert;
@@ -41,6 +43,7 @@
  * @see Application
  */
 public class ApplicationLauncher {
+
     public static final String SPLASH_SCREEN_BEAN_ID = "splashScreen";
 
     public static final String APPLICATION_BEAN_ID = "application";
@@ -147,48 +150,15 @@
         final ClassPathXmlApplicationContext applicationContext = new 
ClassPathXmlApplicationContext(contextPaths,
                 false);
 
-        if (splashScreen != null)
-        {
-                
-            final ProgressMonitor tracker = splashScreen.getProgressMonitor();
+        if (splashScreen instanceof MonitoringSplashScreen)
+        {                
+            final ProgressMonitor tracker = ((MonitoringSplashScreen) 
splashScreen).getProgressMonitor();
     
             applicationContext.addBeanFactoryPostProcessor(new 
BeanFactoryPostProcessor() {
                 public void 
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws 
BeansException {
-                    beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
-                        private int max = -1;
-    
-                        public Object postProcessBeforeInitialization(Object 
bean, String beanName)
-                                throws BeansException {
-                            if (max == -1) {
-                                max = 0;
-                                ConfigurableListableBeanFactory 
configurableListBeanFactory = applicationContext.getBeanFactory();
-                                String[] beanNames = 
applicationContext.getBeanDefinitionNames();
-                                for (int i = 0; i < beanNames.length; i++) {
-                                    // using beanDefinition to check singleton 
property because when accessing through
-                                    // context 
(applicationContext.isSingleton(beanName)), bean will be created already,
-                                    // possibly bypassing other 
BeanFactoryPostProcessors
-                                    if 
(configurableListBeanFactory.getBeanDefinition(beanNames[i]).isSingleton())
-                                        max++;
-                                }
-                                tracker.taskStarted("Loading Application 
Context ...", max);
-                            }
-    
-                            if 
(applicationContext.containsLocalBean(beanName)) {
-                                tracker.subTaskStarted("Loading " + beanName + 
" ...");
-                                tracker.worked(1);
-                            }
-    
-                            return bean;
-                        }
-    
-                        public Object postProcessAfterInitialization(Object 
bean, String beanName)
-                                throws BeansException {
-                            return bean;
-                        }
-                    });
+                    beanFactory.addBeanPostProcessor(new 
MonitoringPostProcessor(tracker, applicationContext));
                 }
             });
-
         }
         
         applicationContext.refresh();
@@ -252,4 +222,46 @@
             });
         }
     }
+
+    protected static class MonitoringPostProcessor implements 
BeanPostProcessor {
+        private final ProgressMonitor tracker;
+
+        private final AbstractApplicationContext context;
+
+        private int max = -1;
+
+        public MonitoringPostProcessor(ProgressMonitor tracker, 
AbstractApplicationContext context) {
+            this.tracker = tracker;
+            this.context = context;
+        }
+
+        public Object postProcessBeforeInitialization(Object bean, String 
beanName)
+                throws BeansException {
+            if (max == -1) {
+                max = 0;
+                ConfigurableListableBeanFactory configurableListBeanFactory = 
context.getBeanFactory();
+                String[] beanNames = context.getBeanDefinitionNames();
+                for (int i = 0; i < beanNames.length; i++) {
+                    // using beanDefinition to check singleton property 
because when accessing through
+                    // context (applicationContext.isSingleton(beanName)), 
bean will be created already,
+                    // possibly bypassing other BeanFactoryPostProcessors
+                    if 
(configurableListBeanFactory.getBeanDefinition(beanNames[i]).isSingleton())
+                        max++;
+                }
+                tracker.taskStarted("Loading Application Context ...", max);
+            }
+        
+            if (context.containsLocalBean(beanName)) {
+                tracker.subTaskStarted("Loading " + beanName + " ...");
+                tracker.worked(1);
+            }
+        
+            return bean;
+        }
+
+        public Object postProcessAfterInitialization(Object bean, String 
beanName)
+                throws BeansException {
+            return bean;
+        }
+    }
 }

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/AbstractSplashScreen.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/AbstractSplashScreen.java
   2006-10-15 09:00:19 UTC (rev 1508)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/AbstractSplashScreen.java
   2006-10-15 13:01:42 UTC (rev 1509)
@@ -25,46 +25,101 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.context.MessageSource;
+import org.springframework.context.NoSuchMessageException;
 import org.springframework.richclient.progress.NullProgressMonitor;
 import org.springframework.richclient.progress.ProgressMonitor;
 import org.springframework.util.Assert;
 
 /**
- * Abstract helper implementation for <code>SplashScreen</code>. The only 
method that needs to be
- * implemented is <code>[EMAIL PROTECTED] #createSplashContentPane()}</code>.
+ * An abstract helper implementation of the [EMAIL PROTECTED] SplashScreen} 
interface.
+ * 
  * <p>
- * This class returns a <code>[EMAIL PROTECTED] NullProgressMonitor}</code> 
instance by default. 
+ * The splash screen produced by this class will be an undecorated, centered
+ * frame containing the component provided by [EMAIL PROTECTED] 
#createSplashContentPane()},
+ * which is the only method that subclasses need to implement.
+ * </p>
  * 
  * @author Peter De Bruycker
  */
 public abstract class AbstractSplashScreen implements SplashScreen {
+    
+    /**
+     * The message resource key used to look up the splash screen's frame 
title.
+     */
+    public static final String SPLASH_TITLE_KEY = "splash.title";
+    
     private JFrame frame;
     private MessageSource messageSource;
     private String iconResourcePath;
-    private ProgressMonitor progressMonitor;
     private static final Log logger = 
LogFactory.getLog(AbstractSplashScreen.class);
 
+    /**
+     * Returns the location of the image to be used as the icon for the splash
+     * screen's frame. The splash screen produced by this class is 
undecorated, 
+     * so the icon will only be visible in the frame's taskbar icon. If the 
given 
+     * path starts with a '/', it is interpreted to be relative to the root of 
the 
+     * runtime classpath. Otherwise it is interpreted to be relative to the 
+     * subdirectory of the classpath root that corresponds to the package of 
this 
+     * class. 
+     *
+     * @return The location of the icon resource.
+     */
     public String getIconResourcePath() {
         return iconResourcePath;
     }
 
-    public void setIconResourcePath(String iconSourcePath) {
-        this.iconResourcePath = iconSourcePath;
+    /**
+     * Sets the location of the image to be used as the icon for the splash
+     * screen's frame. The splash screen produced by this class is 
undecorated, 
+     * so the icon will only be visible in the frame's taskbar icon. If the 
given 
+     * path starts with a '/', it is interpreted to be relative to the root of 
the 
+     * runtime classpath. Otherwise it is interpreted to be relative to the 
+     * subdirectory of the classpath root that corresponds to the package of 
this 
+     * class. 
+     *
+     * @param iconResourcePath The location of the icon resource.
+     */
+    public void setIconResourcePath(String iconResourcePath) {
+        this.iconResourcePath = iconResourcePath;
     }
 
+    /**
+     * Returns the message source used to resolve localized messages.
+     *
+     * @return The message source, or null.
+     */
     public MessageSource getMessageSource() {
         return messageSource;
     }
 
+    /**
+     * Sets the message source used to resolve localized messages.
+     * 
+     * @param messageSource The message source.
+     */
     public void setMessageSource(MessageSource messageSource) {
         this.messageSource = messageSource;
     }
 
     public final void dispose() {
-        frame.dispose();
-        frame = null;
+        
+        if (frame != null) {
+            frame.dispose();
+            frame = null;
+        }
+        
     }
 
+    /**
+     * Creates and displays an undecorated, centered splash screen containing 
the 
+     * component provided by [EMAIL PROTECTED] #createSplashContentPane()}. If 
this instance
+     * has been provided with a [EMAIL PROTECTED] MessageSource}, it will be 
used to retrieve 
+     * the splash screen's frame title under the key [EMAIL PROTECTED] 
#SPLASH_TITLE_KEY}. 
+     * 
+     * @throws NoSuchMessageException if a [EMAIL PROTECTED] MessageSource} 
has been set
+     * on this instance and it is unable to find a message under the key
+     * [EMAIL PROTECTED] #SPLASH_TITLE_KEY}. 
+     */
     public final void splash() {
         frame = new JFrame();
         frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
@@ -82,8 +137,19 @@
         frame.setVisible(true);
     }
 
+    /**
+     * Loads the message under the key [EMAIL PROTECTED] #SPLASH_TITLE_KEY} if 
+     * a [EMAIL PROTECTED] MessageSource} has been set on this instance.
+     * 
+     * @return The message resource stored under the key [EMAIL PROTECTED] 
#SPLASH_TITLE_KEY},
+     * or null if no message source has been set.
+     */
     private String loadFrameTitle() {
-        return messageSource == null ? "" : 
messageSource.getMessage("splash.title", null, null);
+        try {
+            return messageSource == null ? null : 
messageSource.getMessage(SPLASH_TITLE_KEY, null, null);
+        } catch (NoSuchMessageException e) {
+            return null;
+        }
     }
 
     private Image loadFrameIcon() {
@@ -99,16 +165,10 @@
         return Toolkit.getDefaultToolkit().createImage(url);
     }
 
+    /**
+     * Returns the component to be displayed in the splash screen's main frame.
+     *
+     * @return The content pane component, never null.
+     */
     protected abstract JComponent createSplashContentPane();
-
-    public ProgressMonitor getProgressMonitor() {
-        if (progressMonitor == null) {
-            progressMonitor = new NullProgressMonitor();
-        }
-        return progressMonitor;
-    }
-    
-    public void setProgressMonitor(ProgressMonitor progressMonitor) {
-        this.progressMonitor = progressMonitor;
-    }
 }

Added: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/MonitoringSplashScreen.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/MonitoringSplashScreen.java
                         (rev 0)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/MonitoringSplashScreen.java
 2006-10-15 13:01:42 UTC (rev 1509)
@@ -0,0 +1,35 @@
+/*
+ * 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.splash;
+
+import org.springframework.richclient.progress.ProgressMonitor;
+
+/**
+ * A <code>MonitoringSplashScreen</code> can be used to provide feedback of 
the application startup phase
+ * 
+ * @author Mathias Broekelmann
+ * @since 0.3
+ */
+public interface MonitoringSplashScreen extends SplashScreen {
+
+    /**
+     * Returns this <code>SplashScreen</code>'s <code>ProgressMonitor</code>. 
Implementors wishing to show the
+     * progress to the user should return a <code>ProgressMonitor</code> that 
updates the user interface.
+     * 
+     * @return the <code>ProgressMonitor</code>, not null.
+     */
+    ProgressMonitor getProgressMonitor();
+}
\ No newline at end of file


Property changes on: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/MonitoringSplashScreen.java
___________________________________________________________________
Name: svn:keywords
   + Revision Author Date Id
Name: svn:eol-style
   + native

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/ProgressSplashScreen.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/ProgressSplashScreen.java
   2006-10-15 09:00:19 UTC (rev 1508)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/ProgressSplashScreen.java
   2006-10-15 13:01:42 UTC (rev 1509)
@@ -22,38 +22,114 @@
 import javax.swing.JProgressBar;
 
 import org.springframework.richclient.progress.ProgressBarProgressMonitor;
+import org.springframework.richclient.progress.ProgressMonitor;
 
 /**
- * Splash screen implementation that shows the progress of the application 
startup.
+ * A lightweight splash-screen for displaying the progress of a GUI 
application startup process.
  * 
+ * <p>
+ * The splash screen produced by this class will be an undecorated, centered 
frame containing an image above a progress
+ * bar. It minimizes class loading so it is displayed immediately once the 
application is started.
+ * </p>
+ * 
+ * 
  * @author Peter De Bruycker
  */
-public class ProgressSplashScreen extends SimpleSplashScreen {
+public class ProgressSplashScreen extends SimpleSplashScreen implements 
MonitoringSplashScreen {
     private JProgressBar progressBar;
+
     private boolean showProgressLabel;
 
+    private ProgressMonitor progressMonitor;
+
+    private boolean indeterminate = true;
+
+    /**
+     * Creates a new [EMAIL PROTECTED] ProgressSplashScreen} that uses an 
underlying [EMAIL PROTECTED] ProgressBarProgressMonitor}.
+     */
     public ProgressSplashScreen() {
-        progressBar = new JProgressBar();
-        setProgressMonitor(new ProgressBarProgressMonitor(progressBar));
     }
 
+    /**
+     * Returns the flag that determines whether or not the progress bar will 
display updated textual info as it is
+     * provided by the progress monitor.
+     * 
+     * @return The showProgressLabel flag.
+     */
     public boolean getShowProgressLabel() {
         return showProgressLabel;
     }
 
+    /**
+     * Sets the flag that determines whether or not the progress bar will 
display updated textual info as it is provided
+     * by the progress monitor.
+     * 
+     * @param showProgressLabel
+     */
     public void setShowProgressLabel(boolean showProgressLabel) {
         this.showProgressLabel = showProgressLabel;
     }
 
+    /**
+     * Returns a component that displays an image above a progress bar.
+     * 
+     * @return A splash screen containing an image and a progress bar, never 
null.
+     */
     protected JComponent createSplashContentPane() {
         JPanel content = new JPanel(new BorderLayout());
         content.add(super.createSplashContentPane());
 
-        progressBar.setIndeterminate(true);
-        progressBar.setStringPainted(showProgressLabel);
+        JProgressBar progressBar = getProgressBar();
+        progressBar.setIndeterminate(isIndeterminate());
+        progressBar.setStringPainted(getShowProgressLabel());
 
         content.add(progressBar, BorderLayout.SOUTH);
 
         return content;
     }
+
+    public ProgressMonitor getProgressMonitor() {
+        if (progressMonitor == null) {
+            progressMonitor = new ProgressBarProgressMonitor(getProgressBar());
+        }
+        return progressMonitor;
+    }
+
+    /**
+     * Sets the progress monitor used by this splash screen.
+     * 
+     * @param progressMonitor
+     *            The progress monitor.
+     */
+    public void setProgressMonitor(ProgressMonitor progressMonitor) {
+        this.progressMonitor = progressMonitor;
+    }
+
+    /**
+     * Returns the progress bar.
+     * 
+     * @return not null
+     */
+    protected JProgressBar getProgressBar() {
+        if (progressBar == null) {
+            progressBar = new JProgressBar();
+        }
+        return progressBar;
+    }
+
+    public boolean isIndeterminate() {
+        return indeterminate;
+    }
+
+    /**
+     * Determines whether the progress bar is in determinate or indeterminate 
mode. Default is true
+     * 
+     * @param indeterminate
+     *            <code>true</code> if the progress bar should change to 
indeterminate mode; <code>false</code> if
+     *            it should revert to normal.
+     * @see JProgressBar#setIndeterminate(boolean)
+     */
+    public void setIndeterminate(boolean indeterminate) {
+        this.indeterminate = indeterminate;
+    }
 }

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/SimpleSplashScreen.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/SimpleSplashScreen.java
     2006-10-15 09:00:19 UTC (rev 1508)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/SimpleSplashScreen.java
     2006-10-15 13:01:42 UTC (rev 1509)
@@ -32,7 +32,7 @@
 /**
  * A lightweight splash-screen for display when a GUI application is being 
initialized.
  * <p>
- * The splash screen renders a image in a Frame. It minimizes class loading so 
it is
+ * The splash screen renders an image in a Frame. It minimizes class loading 
so it is
  * displayed immediately once the application is started.
  * 
  * @author Keith Donald
@@ -45,28 +45,47 @@
 
     private static final Log logger = 
LogFactory.getLog(SimpleSplashScreen.class);
 
+    /**
+     * Creates a new uninitialized [EMAIL PROTECTED] SimpleSplashScreen}.
+     */
     public SimpleSplashScreen() {
+        //do nothing
     }
 
     /**
-     * Initialize and show a splash screen of the image at the specified URL.
+     * Creates a new [EMAIL PROTECTED] SimpleSplashScreen} that will display 
the image at
+     * the specified location. 
      * 
-     * @param imageURL the URL of the image to splash.
+     * @param imageResourcePath The location of the image file to be displayed
+     * by this splash screen. 
+     * 
+     * @see #setImageResourcePath(String)
      */
     public SimpleSplashScreen(String imageResourcePath) {
         setImageResourcePath(imageResourcePath);
     }
 
     /**
-     * Initialize and show a splash screen of the specified image.
+     * Creates a new [EMAIL PROTECTED] SimpleSplashScreen} that will display 
the given image. 
      * 
      * @param image the image to splash.
+     * 
+     * @throws IllegalArgumentException if [EMAIL PROTECTED] image} is null.
      */
     public SimpleSplashScreen(Image image) {
         Assert.notNull(image, "The splash screen image is required");
         this.image = image;
     }
 
+    /**
+     * Sets the location of the image to be displayed by this splash screen.
+     * If the given path starts with a '/', it is interpreted to be relative 
to 
+     * the root of the runtime classpath. Otherwise it is interpreted to be 
+     * relative to the subdirectory of the classpath root that corresponds to 
the
+     * package of this class. 
+     *
+     * @param path The path to the splash screen image.
+     */
     public void setImageResourcePath(String path) {
         Assert.hasText(path, "The splash screen image resource path is 
required");
         this.imageResourcePath = path;
@@ -77,6 +96,8 @@
      * 
      * @param path Path to image.
      * @return Image
+     * 
+     * @throws NullPointerException if [EMAIL PROTECTED] path} is null.
      */
     private Image loadImage(String path) {
         URL url = this.getClass().getResource(path);
@@ -94,6 +115,14 @@
         private static final long serialVersionUID = -5096223464173393949L;
         private Image image;
 
+        /**
+         * Creates a new [EMAIL PROTECTED] ImageCanvas} with the specified 
image. The size
+         * of the canvas will be set to the size of the image.
+         *
+         * @param image The image to be displayed by the canvas.
+         * 
+         * @throws NullPointerException if [EMAIL PROTECTED] image} is null.
+         */
         public ImageCanvas(Image image) {
             this.image = image;
 
@@ -123,6 +152,9 @@
         }
     }
 
+    /**
+     * Returns a component that displays an image in a canvas.
+     */
     protected JComponent createSplashContentPane() {
         if (image == null) {
             image = loadImage(imageResourcePath);

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/SplashScreen.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/SplashScreen.java
   2006-10-15 09:00:19 UTC (rev 1508)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/richclient/application/splash/SplashScreen.java
   2006-10-15 13:01:42 UTC (rev 1509)
@@ -15,12 +15,9 @@
  */
 package org.springframework.richclient.application.splash;
 
-import org.springframework.richclient.progress.ProgressMonitor;
 
 /**
  * A <code>SplashScreen</code> is shown to the user during application startup.
- * Optionally implementations can provide visual feedback of startup progress 
to the user
- * using the <code>ProgressMonitor</code>.
  * 
  * @author Peter De Bruycker
  */
@@ -31,16 +28,8 @@
     void splash();
 
     /**
-     * Disposes this <code>SplashScreen</code>.
+     * Disposes this <code>SplashScreen</code>, freeing any system resources 
+     * that it may be using.
      */
     void dispose();
-
-    /**
-     * Gets this <code>SplashScreen</code>s <code>ProgressMonitor</code>.
-     * Implementors wishing to show the progress to the user should return a
-     * <code>ProgressMonitor</code> that updates the ui.
-     * 
-     * @return the <code>ProgressMonitor</code>
-     */
-    ProgressMonitor getProgressMonitor();
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to