cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r951745 - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
Date Sat, 05 Jun 2010 17:26:42 GMT
Author: aadamchik
Date: Sat Jun  5 17:26:41 2010
New Revision: 951745

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

* fixing EntityResolver state switching to prevent broken namespaces for projects when projects
  are opened multiple times

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java?rev=951745&r1=951744&r2=951745&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
Sat Jun  5 17:26:41 2010
@@ -405,12 +405,14 @@ public abstract class Entity implements 
                     return rel;
                 }
             }
+            
+            String entityName = (currentEnt != null) ? currentEnt.getName() : "(?)";
 
             // build error message
             StringBuilder buf = new StringBuilder();
             buf
                     .append("Can't resolve path component: [")
-                    .append(currentEnt.getName())
+                    .append(entityName)
                     .append('.')
                     .append(pathComp)
                     .append("].");

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java?rev=951745&r1=951744&r2=951745&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
Sat Jun  5 17:26:41 2010
@@ -290,16 +290,14 @@ public class ProjectController extends C
     }
 
     public void setProject(Project currentProject) {
-        if (this.project != currentProject) // strange enough, this method is called twice
-        // during project opening. Not to disturb
-        // watchdog extra time, adding this check
-        {
+        if (this.project != currentProject) {
 
             this.project = currentProject;
             this.projectControllerPreferences = null;
 
-            if (project == null) // null project -> no files to watch
-            {
+            if (project == null) {
+                this.entityResolver = null;
+
                 if (watchdog != null) {
                     watchdog.interrupt();
                     watchdog = null;
@@ -313,17 +311,11 @@ public class ProjectController extends C
 
                 watchdog.reconfigure();
 
-                if (entityResolver == null) {
-                    entityResolver = new EntityResolver(
-                            ((DataChannelDescriptor) currentProject.getRootNode())
-                                    .getDataMaps());
-                }
+                entityResolver = new EntityResolver(
+                        ((DataChannelDescriptor) currentProject.getRootNode())
+                                .getDataMaps());
 
-                Iterator<DataMap> it = entityResolver.getDataMaps().iterator();
-                while (it.hasNext()) {
-                    DataMap map = it.next();
-                    map.setNamespace(entityResolver);
-                }
+                updateEntityResolver();
 
                 // addDomainListener(((ModelerProjectConfiguration) project
                 // .getConfiguration()).getGraphRegistry());
@@ -333,14 +325,13 @@ public class ProjectController extends C
 
     public void updateEntityResolver() {
 
-        entityResolver.clearCache();
-        entityResolver.setDataMaps(((DataChannelDescriptor) project.getRootNode())
-                .getDataMaps());
+        Collection<DataMap> dataMaps = ((DataChannelDescriptor) project.getRootNode())
+                .getDataMaps();
 
-        Iterator<DataMap> it = entityResolver.getDataMaps().iterator();
-        while (it.hasNext()) {
-            DataMap map = it.next();
-            map.setNamespace(entityResolver);
+        entityResolver.setDataMaps(dataMaps);
+
+        for (DataMap dataMap : dataMaps) {
+            dataMap.setNamespace(entityResolver);
         }
     }
 



Mime
View raw message