Author: oltka
Date: Wed Feb 17 11:02:10 2010
New Revision: 910914

URL: http://svn.apache.org/viewvc?rev=910914&view=rev
Log:
CAY-1327 Migrate HSQLDB modeler preferences to Java preferences API

* GeneralPreferences migrate to Preferences API

Modified:
    
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java
    
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ConfirmRemoveDialog.java

Modified: 
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java
URL: 
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java?rev=910914&r1=910913&r2=910914&view=diff
==============================================================================
--- 
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java
 (original)
+++ 
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Main.java
 Wed Feb 17 11:02:10 2010
@@ -31,7 +31,7 @@
 import javax.swing.UIManager;
 
 import org.apache.cayenne.conf.Configuration;
-import org.apache.cayenne.pref.PreferenceDetail;
+import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.modeler.dialog.pref.GeneralPreferences;
 import org.apache.cayenne.modeler.util.CayenneUserDir;
 import org.apache.cayenne.modeler.action.OpenProjectAction;
@@ -86,12 +86,11 @@
     protected static File projectFileFromPrefs() {
         // This must be run after the application has already been 
bootstrapped.  Otherwise, the returned
         // app instance will be null.
-        PreferenceDetail autoLoadPref = 
Application.getInstance().getPreferenceDomain().getDetail(GeneralPreferences.AUTO_LOAD_PROJECT_PREFERENCE,
 true);
         
-        if ((autoLoadPref != null) && (true == 
autoLoadPref.getBooleanProperty(GeneralPreferences.AUTO_LOAD_PROJECT_PREFERENCE)))
 {
-            Preferences modelerPreferences = 
ModelerPreferences.getEditorPreferences();
-            
-            Preferences lastProjFilesPref = 
ModelerPreferences.getLastProjFilesPref();
+        Preferences autoLoadPref = 
Application.getInstance().getPreferencesNode(ClassGenerationAction.class, "");
+        
+        if ((autoLoadPref != null) && (true == 
autoLoadPref.getBoolean(GeneralPreferences.AUTO_LOAD_PROJECT_PREFERENCE, 
false))) {
+
             List<String> arr = ModelerPreferences.getLastProjFiles();
             if(arr.size()>0){
                 return new File((String) arr.get(0));

Modified: 
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ConfirmRemoveDialog.java
URL: 
http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ConfirmRemoveDialog.java?rev=910914&r1=910913&r2=910914&view=diff
==============================================================================
--- 
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ConfirmRemoveDialog.java
 (original)
+++ 
cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ConfirmRemoveDialog.java
 Wed Feb 17 11:02:10 2010
@@ -18,13 +18,15 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.dialog;
 
+import java.util.prefs.Preferences;
+
 import javax.swing.JCheckBox;
 import javax.swing.JDialog;
 import javax.swing.JOptionPane;
 
+import org.apache.cayenne.gen.ClassGenerationAction;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.dialog.pref.GeneralPreferences;
-import org.apache.cayenne.pref.PreferenceDetail;
 
 /**
  * Used to confirm deleting items in the model.
@@ -58,8 +60,8 @@
 
         // If the user clicks "no", we'll just ignore whatever's in the 
checkbox because it's non-sensical.
         if (shouldDelete) {
-            PreferenceDetail pref = 
Application.getInstance().getPreferenceDomain().getDetail(GeneralPreferences.DELETE_PROMPT_PREFERENCE,
 true);
-            
pref.setBooleanProperty(GeneralPreferences.DELETE_PROMPT_PREFERENCE, 
neverPromptAgainBox.isSelected());
+            Preferences pref = 
Application.getInstance().getPreferencesNode(ClassGenerationAction.class, "");
+            pref.putBoolean(GeneralPreferences.DELETE_PROMPT_PREFERENCE, 
neverPromptAgainBox.isSelected());
             Application.getInstance().getPreferenceService().savePreferences();
         }
     }
@@ -70,10 +72,11 @@
 
     public boolean shouldDelete(String name) {
         if (allowAsking) {
-            PreferenceDetail pref = 
Application.getInstance().getPreferenceDomain().getDetail(GeneralPreferences.DELETE_PROMPT_PREFERENCE,
 true);
+            
+            Preferences pref = 
Application.getInstance().getPreferencesNode(ClassGenerationAction.class, "");
 
             // See if the user has opted not to showDialog the delete dialog.
-            if ((pref == null) || (false == 
pref.getBooleanProperty(GeneralPreferences.DELETE_PROMPT_PREFERENCE))) {
+            if ((pref == null) || (false == 
pref.getBoolean(GeneralPreferences.DELETE_PROMPT_PREFERENCE, false))) {
                 showDialog(name);
             }
         }


Reply via email to