Revision: 1209
Author:   jhoskens
Date:     2006-06-21 04:16:07 -0700 (Wed, 21 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/spring-rich-c/?rev=1209&view=rev

Log Message:
-----------
fix for RCP-368: made some improvements to allow easier subclassing.

Modified Paths:
--------------
    
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/PreferencePage.java
===================================================================
--- 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/PreferencePage.java
 2006-06-21 09:42:27 UTC (rev 1208)
+++ 
trunk/spring-richclient/sandbox/src/main/java/org/springframework/richclient/preference/PreferencePage.java
 2006-06-21 11:16:07 UTC (rev 1209)
@@ -41,29 +41,65 @@
                super(id);
        }
 
-       private JComponent createButtons() {
-               restoreDefaultsCommand = new 
ActionCommand("restoreDefaultsCommand") {
-                       public void doExecuteCommand() {
-                               onDefaults();
-                       }
-               };
+       /**
+        * @return array containing "Restore defaults" and "Apply" commands
+        */
+       protected ActionCommand[] getCommands() {
+               return new ActionCommand[] { getRestoreDefaultsCommand(), 
getApplyCommand() };
+       }
 
-               applyCommand = new ActionCommand("applyCommand") {
-                       public void doExecuteCommand() {
-                               onApply();
-                       }
-               };
+    /**
+     * Will create "Apply" command if it doesn't exist yet
+     * 
+     * @return apply command.
+     */
+    protected ActionCommand getApplyCommand()
+    {
+        if (applyCommand == null) {
+            applyCommand = new ActionCommand("applyCommand") {
+                       public void doExecuteCommand() {
+                               onApply();
+                       }
+               };
+        }
+        return applyCommand;
+    }
 
+    /**
+     * Will create "Restore Defaults" command if it doesn't exist yet
+     * 
+     * @return restore defaults command.
+     */
+    protected ActionCommand getRestoreDefaultsCommand()
+    {
+        if (restoreDefaultsCommand == null){
+            restoreDefaultsCommand = new 
ActionCommand("restoreDefaultsCommand") {
+                       public void doExecuteCommand() {
+                               onDefaults();
+                       }
+               };
+        }
+        return restoreDefaultsCommand;
+    }
+
+       /**
+        * Creates two commands "Restore defaults" and "Apply" for this page,
+        * layouts them on the panel.
+        * 
+        * @return panel containing "Restore defaults" and "Apply" commands
+        */
+       protected JComponent createButtons() {
                CommandGroup commandGroup = 
CommandGroup.createCommandGroup(null,
-                               new Object[] { restoreDefaultsCommand, 
applyCommand });
+                               getCommands());
                JComponent buttonBar = commandGroup.createButtonBar();
                GuiStandardUtils.attachDialogBorder(buttonBar);
+
                return buttonBar;
        }
 
        protected abstract JComponent createContents();
 
-       protected final JComponent createControl() {
+       protected JComponent createControl() {
                GridBagLayoutBuilder builder = new GridBagLayoutBuilder();
 
                JComponent buttonPanel = null;
@@ -113,6 +149,10 @@
                createApplyAndDefaultButtons = create;
        }
 
+       public boolean getCreateApplyAndDefaultButtons() {
+               return createApplyAndDefaultButtons;
+       }
+
        public void setParent(PreferencePage parent) {
                this.parent = parent;
        }
@@ -123,10 +163,10 @@
        }
 
        public void setPageComplete(boolean pageComplete) {
-               if(applyCommand != null) {
+               if (applyCommand != null) {
                        applyCommand.setEnabled(pageComplete);
                }
-               
+
                super.setPageComplete(pageComplete);
        }
 }
\ No newline at end of file


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



_______________________________________________
spring-rich-c-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to