cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r794656 - /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
Date Thu, 16 Jul 2009 12:50:34 GMT
Author: aadamchik
Date: Thu Jul 16 12:50:34 2009
New Revision: 794656

URL: http://svn.apache.org/viewvc?rev=794656&view=rev
Log:
CAY-1227 Modeler support for flattened attributes

patch by Olga Tkachova  errSelectPath.txt , plus my own refactoring/renaming

Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java?rev=794656&r1=794655&r2=794656&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
Thu Jul 16 12:50:34 2009
@@ -207,52 +207,51 @@
         view.dispose();
     }
 
-    public boolean isChange() {
-        StringBuilder attriburePathStr = new StringBuilder();
+    public boolean setPath() {
+        StringBuilder attributePath = new StringBuilder();
         StringBuilder pathStr = new StringBuilder();
         TreePath path = view.getPathBrowser().getSelectionPath();
 
         if (path.getLastPathComponent() instanceof DbAttribute) {
-            Object[] ob = path.getPath();
-            for (int i = 0; i < ob.length; i++) {
+            Object[] pathComponents = path.getPath();
+            for (int i = 0; i < pathComponents.length; i++) {
                 boolean attrOrRel = true;
-                if (ob[i] instanceof DbAttribute) {
-                    pathStr.append(((DbAttribute) ob[i]).getName());
-                    attriburePathStr.append(((DbAttribute) ob[i]).getName());
-                }
-                else if (ob[i] instanceof DbRelationship) {
-                    pathStr.append(((DbRelationship) ob[i]).getName());
-                    attriburePathStr.append(((DbRelationship) ob[i]).getName());
+                if (pathComponents[i] instanceof DbAttribute) {
+                    pathStr.append(((DbAttribute) pathComponents[i]).getName());
+                    attributePath.append(((DbAttribute) pathComponents[i]).getName());
+                }
+                else if (pathComponents[i] instanceof DbRelationship) {
+                    pathStr.append(((DbRelationship) pathComponents[i]).getName());
+                    attributePath.append(((DbRelationship) pathComponents[i]).getName());
                 }
                 else {
                     attrOrRel = false;
                 }
 
-                if (i != ob.length - 1 && attrOrRel) {
+                if (i != pathComponents.length - 1 && attrOrRel) {
                     pathStr.append(" -> ");
-                    attriburePathStr.append(".");
+                    attributePath.append(".");
                 }
             }
         }
         else {
             view.getCurrentPathLabel().setText("");
-            attriburePathStr = null;
         }
 
         view.getCurrentPathLabel().setText(pathStr.toString());
 
         if (attribute.getDbAttributePath() != null) {
-            if (!attribute.getDbAttributePath().equals(attriburePathStr.toString())
+            if (!attribute.getDbAttributePath().equals(attributePath.toString())
                     || !attribute.getName().equals(view.getAttributeName().getText())) {
-                attributeSaved.setDbAttributePath(attriburePathStr.toString());
+                attributeSaved.setDbAttributePath(attributePath.toString());
                 attributeSaved.setName(view.getAttributeName().getText());
                 return true;
             }
         }
-        else if (attribute.getDbAttributePath() == null) {
-            if (attriburePathStr.toString().length() > 0
+        else {
+            if (attributePath.length() > 0
                     || !attribute.getName().equals(view.getAttributeName().getText())) {
-                attributeSaved.setDbAttributePath(attriburePathStr.toString());
+                attributeSaved.setDbAttributePath(attributePath.toString());
                 attributeSaved.setName(view.getAttributeName().getText());
                 return true;
             }
@@ -262,7 +261,7 @@
 
     public void saveMapping() {
 
-        if (isChange()) {
+        if (setPath()) {
             if (JOptionPane.showConfirmDialog(
                     (Component) getView(),
                     "You have changed Db Attribute path. Do you want it to be saved?",



Mime
View raw message