cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r734394 - in /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: editor/SelectQueryMainTab.java util/CellRenderers.java
Date Wed, 14 Jan 2009 13:46:56 GMT
Author: andrey
Date: Wed Jan 14 05:46:39 2009
New Revision: 734394

URL: http://svn.apache.org/viewvc?rev=734394&view=rev
Log:
CAY-1166 Type checking in the modeler

Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java?rev=734394&r1=734393&r2=734394&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryMainTab.java
Wed Jan 14 05:46:39 2009
@@ -244,7 +244,7 @@
                 /**
                  * Advanced checking. See CAY-888 #1
                  */
-                if(query.getRoot() != null) {
+                if (query.getRoot() instanceof Entity) {
                     checkExpression((Entity) query.getRoot(), exp);
                 }
                 
@@ -345,25 +345,27 @@
         public void actionPerformed(ActionEvent ae) {
             SelectQuery query = getQuery();
             if (query != null) {
-                query.setRoot(queryRoot.getModel().getSelectedItem());
-                
-                if (needChangeName) { //not changed by user
-                    /**
-                     * Doing auto name change, following CAY-888 #2
-                     */
-                    Entity e = (Entity)queryRoot.getModel().getSelectedItem();
-                    
-                    String newPrefix = e.getName() + "Query";
-                    newName = newPrefix;
-                    
-                    DataMap map = mediator.getCurrentDataMap();
-                    long postfix = 1;
+                Entity root = (Entity) queryRoot.getModel().getSelectedItem();
+
+                if (root != null) {
+                    query.setRoot(root);
                     
-                    while (map.getQuery(newName) != null) {
-                        newName = newPrefix + (postfix++);
+                    if (needChangeName) { //not changed by user
+                        /**
+                         * Doing auto name change, following CAY-888 #2
+                         */
+                        String newPrefix = root.getName() + "Query";
+                        newName = newPrefix;
+                        
+                        DataMap map = mediator.getCurrentDataMap();
+                        long postfix = 1;
+                        
+                        while (map.getQuery(newName) != null) {
+                            newName = newPrefix + (postfix++);
+                        }
+                        
+                        name.setText(newName);
                     }
-                    
-                    name.setText(newName);
                 }
             }
         }
@@ -398,7 +400,7 @@
          */
         boolean hasDefaultName(SelectQuery query) {
             String prefix = query.getRoot() == null ? "UntitledQuery" :
-                ((Entity)query.getRoot()).getName() + "Query";
+                CellRenderers.asString(query.getRoot()) + "Query";
             
             return name.getComponent().getText().startsWith(prefix);
         }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java?rev=734394&r1=734393&r2=734394&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CellRenderers.java
Wed Jan 14 05:46:39 2009
@@ -185,7 +185,10 @@
                 }
             }
             
-            obj = label;
+            return label;
+        }
+        else if (obj instanceof DataMap) {
+            return ((DataMap) obj).getName();
         }
         
         return obj == null ? null : String.valueOf(obj);



Mime
View raw message