Revision: 1102
Author:   peterdb
Date:     2006-04-27 12:49:22 -0700 (Thu, 27 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1102&view=rev

Log Message:
-----------
fix for rcp-317: FormBackedPreferencePage applyButton only enabled if form is 
complete

Modified Paths:
--------------
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/FormBackedPreferencePage.java
    
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/PreferencePage.java
Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/FormBackedPreferencePage.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/FormBackedPreferencePage.java
       2006-04-27 19:38:27 UTC (rev 1101)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/FormBackedPreferencePage.java
       2006-04-27 19:49:22 UTC (rev 1102)
@@ -22,36 +22,41 @@
 
 public abstract class FormBackedPreferencePage extends PreferencePage {
 
-    private Form form;
+       private Form form;
 
-    public FormBackedPreferencePage(String id) {
-        super(id);
-    }
+       public FormBackedPreferencePage(String id) {
+               super(id);
+       }
 
-    protected final JComponent createContents() {
-        form = createForm();
-        Assert.notNull(form, "You must set the form before contents are 
created.");
+       protected final JComponent createContents() {
+               form = createForm();
+               Assert.notNull(form,
+                               "You must set the form before contents are 
created.");
 
-        initPageValidationReporter();
+               initPageValidationReporter();
 
-        return form.getControl();
-    }
+               return form.getControl();
+       }
 
-    protected abstract Form createForm();
+       protected abstract Form createForm();
 
-    public Form getForm() {
-        return form;
-    }
+       public Form getForm() {
+               return form;
+       }
 
-    protected void initPageValidationReporter() {
-        form.newSingleLineResultsReporter(this, this);
-    }
+       protected void initPageValidationReporter() {
+               form.newSingleLineResultsReporter(this, this);
+       }
 
-    public void onAboutToShow() {
-        setEnabled(!form.hasErrors());
-    }
+       public void onAboutToShow() {
+               setEnabled(!form.hasErrors());
+       }
 
-    public void setEnabled(boolean enabled) {
-        setPageComplete(enabled);
-    }
+       public void setEnabled(boolean enabled) {
+               if (getApplyCommand() != null) {
+                       getApplyCommand().setEnabled(enabled);
+               }
+
+               setPageComplete(enabled);
+       }
 }
\ No newline at end of file

Modified: 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/PreferencePage.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/PreferencePage.java
 2006-04-27 19:38:27 UTC (rev 1101)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/PreferencePage.java
 2006-04-27 19:49:22 UTC (rev 1102)
@@ -28,9 +28,13 @@
 public abstract class PreferencePage extends AbstractDialogPage {
 
        private boolean createApplyAndDefaultButtons = true;
+
        private PreferencePage parent;
+
        private PreferenceDialog preferenceDialog;
+
        private ActionCommand restoreDefaultsCommand;
+
        private ActionCommand applyCommand;
 
        public PreferencePage(String id) {
@@ -64,6 +68,11 @@
 
                // JPanel panel = new JPanel(new BorderLayout());
 
+               JComponent buttonPanel = null;
+               if (createApplyAndDefaultButtons) {
+                       buttonPanel = createButtons();
+               }
+
                JComponent contents = createContents();
                Assert.notNull(contents, "Contents cannot be null.");
                // panel.add(contents);
@@ -73,6 +82,7 @@
                        builder.nextLine();
                        builder.append(createButtons());
                        // panel.add(createButtons(), BorderLayout.SOUTH);
+                       builder.append(buttonPanel);
                }
 
                // return panel;
@@ -117,4 +127,8 @@
                Assert.notNull(dialog);
                preferenceDialog = dialog;
        }
+
+       protected ActionCommand getApplyCommand() {
+               return applyCommand;
+       }
 }
\ No newline at end of file


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

Reply via email to