cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r895581 - in /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: dialog/db/ pref/
Date Mon, 04 Jan 2010 08:59:11 GMT
Author: oltka
Date: Mon Jan  4 08:59:10 2010
New Revision: 895581

URL: http://svn.apache.org/viewvc?rev=895581&view=rev
Log:
CAY-1327

* DBGeneratorDefaults to API preference

Removed:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/ModelerPreferences.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/_DBGeneratorDefaults.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/_ModelerPreferences.java
Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBGeneratorDefaults.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java?rev=895581&r1=895580&r2=895581&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
Mon Jan  4 08:59:10 2010
@@ -70,9 +70,9 @@
         this.tables = new TableSelectorController(parent);
         this.view = new DBGeneratorOptionsView(tables.getView());
         this.connectionInfo = connectionInfo;
-        this.generatorDefaults = (DBGeneratorDefaults) parent
-                .getPreferenceDomainForProject()
-                .getDetail("DbGenerator", DBGeneratorDefaults.class, true);
+        this.generatorDefaults = new DBGeneratorDefaults(parent
+                .getPreferenceForProject()
+                .node("DbGenerator"));
 
         this.view.setTitle(title);
         initController();

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBGeneratorDefaults.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBGeneratorDefaults.java?rev=895581&r1=895580&r2=895581&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBGeneratorDefaults.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DBGeneratorDefaults.java
Mon Jan  4 08:59:10 2010
@@ -18,27 +18,100 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.pref;
 
+import java.util.prefs.Preferences;
+
 import org.apache.cayenne.access.DbGenerator;
+import org.apache.cayenne.pref.CayennePreferenceForProject;
+
+public class DBGeneratorDefaults extends CayennePreferenceForProject {
+
+    public static final String CREATE_FK_PROPERTY = "createFK";
+    public static final String CREATE_PK_PROPERTY = "createPK";
+    public static final String CREATE_TABLES_PROPERTY = "createTables";
+    public static final String DROP_PK_PROPERTY = "dropPK";
+    public static final String DROP_TABLES_PROPERTY = "dropTables";
+
+    public boolean createFK;
+    public boolean createPK;
+    public boolean createTables;
+    public boolean dropPK;
+    public boolean dropTables;
+
+    public DBGeneratorDefaults(Preferences pref) {
+        super(pref);
+        this.createFK = getCurrentPreference().getBoolean(CREATE_FK_PROPERTY, true);
+        this.createPK = getCurrentPreference().getBoolean(CREATE_PK_PROPERTY, true);
+        this.createTables = getCurrentPreference().getBoolean(
+                CREATE_TABLES_PROPERTY,
+                true);
+        this.dropPK = getCurrentPreference().getBoolean(DROP_PK_PROPERTY, false);
+        this.dropTables = getCurrentPreference().getBoolean(DROP_TABLES_PROPERTY, false);
+    }
+
+    public void setCreateFK(Boolean createFK) {
+        this.createFK = createFK;
+        getCurrentPreference().putBoolean(CREATE_FK_PROPERTY, createFK);
+    }
+
+    public boolean getCreateFK() {
+        return createFK;
+    }
+
+    public void setCreatePK(Boolean createPK) {
+        this.createPK = createPK;
+        getCurrentPreference().putBoolean(CREATE_PK_PROPERTY, createPK);
+    }
+
+    public boolean getCreatePK() {
+        return createPK;
+    }
 
-public class DBGeneratorDefaults extends _DBGeneratorDefaults {
+    public void setCreateTables(Boolean createTables) {
+        this.createTables = createTables;
+        getCurrentPreference().putBoolean(CREATE_TABLES_PROPERTY, createTables);
+    }
+
+    public boolean getCreateTables() {
+        return createTables;
+    }
+
+    public void setDropPK(Boolean dropPK) {
+        this.dropPK = dropPK;
+        getCurrentPreference().putBoolean(DROP_PK_PROPERTY, dropPK);
+    }
+
+    public boolean getDropPK() {
+        return dropPK;
+    }
+
+    public void setDropTables(Boolean dropTables) {
+        this.dropTables = dropTables;
+        getCurrentPreference().putBoolean(DROP_TABLES_PROPERTY, dropTables);
+    }
+
+    public boolean getDropTables() {
+        return dropTables;
+    }
 
     /**
      * Updates DbGenerator settings, consulting its own state.
      */
     public void configureGenerator(DbGenerator generator) {
-        generator
-                .setShouldCreateFKConstraints(booleanForBooleanProperty(CREATE_FK_PROPERTY));
-        generator.setShouldCreatePKSupport(booleanForBooleanProperty(CREATE_PK_PROPERTY));
-        generator
-                .setShouldCreateTables(booleanForBooleanProperty(CREATE_TABLES_PROPERTY));
-        generator.setShouldDropPKSupport(booleanForBooleanProperty(DROP_PK_PROPERTY));
-        generator.setShouldDropTables(booleanForBooleanProperty(DROP_TABLES_PROPERTY));
+        setCreateFK(createFK);
+        setCreatePK(createPK);
+        setCreateTables(createTables);
+        setDropPK(dropPK);
+        setDropTables(dropTables);
+        generator.setShouldCreateFKConstraints(createFK);
+        generator.setShouldCreatePKSupport(createPK);
+        generator.setShouldCreateTables(createTables);
+        generator.setShouldDropPKSupport(dropPK);
+        generator.setShouldDropTables(dropTables);
     }
-    
+
     /**
      * An initialization callback.
      */
-    @Override
     public void prePersist() {
         setCreateFK(Boolean.TRUE);
         setCreatePK(Boolean.TRUE);
@@ -46,9 +119,4 @@
         setDropPK(Boolean.FALSE);
         setDropTables(Boolean.FALSE);
     }
-
-    protected boolean booleanForBooleanProperty(String property) {
-        Boolean b = (Boolean) readProperty(property);
-        return (b != null) ? b.booleanValue() : false;
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java?rev=895581&r1=895580&r2=895581&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/pref/DataNodeDefaults.java
Mon Jan  4 08:59:10 2010
@@ -23,6 +23,8 @@
 import org.apache.cayenne.pref.CayennePreferenceForProject;
 
 public class DataNodeDefaults extends CayennePreferenceForProject {
+    
+    private String localDataSource;
 
     public DataNodeDefaults(Preferences pref) {
         super(pref);
@@ -32,11 +34,15 @@
 
     public void setLocalDataSource(String localDataSource) {
         if (getCurrentPreference() != null) {
+            this.localDataSource = localDataSource;
             getCurrentPreference().put(LOCAL_DATA_SOURCE_PROPERTY, localDataSource);
         }
     }
 
     public String getLocalDataSource() {
-        return getCurrentPreference().get(LOCAL_DATA_SOURCE_PROPERTY, null);
+        if(localDataSource == null){
+            localDataSource = getCurrentPreference().get(LOCAL_DATA_SOURCE_PROPERTY, null);
+        }
+        return localDataSource;
     }
 }



Mime
View raw message