cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [3/7] cayenne git commit: CAY-2385 CAY-2386 Refactored 1 duplicated method by moving it to their correspondent superclass
Date Thu, 07 Dec 2017 13:07:09 GMT
CAY-2385 CAY-2386 Refactored 1 duplicated method by moving it to their correspondent superclass


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/a941ea7b
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/a941ea7b
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/a941ea7b

Branch: refs/heads/master
Commit: a941ea7b0d6518ea6e90bee4b57c2f142633b790
Parents: f181099
Author: Emerson Castaneda <emecas@users.noreply.github.com>
Authored: Fri Dec 1 23:15:26 2017 -0500
Committer: Emerson Castaneda <emecas@users.noreply.github.com>
Committed: Tue Dec 5 22:42:25 2017 -0500

----------------------------------------------------------------------
 .../action/DbEntityCounterpartAction.java       | 33 +-----------------
 .../action/ObjEntityCounterpartAction.java      | 31 -----------------
 .../cayenne/modeler/util/CayenneAction.java     | 35 ++++++++++++++++++++
 3 files changed, 36 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/a941ea7b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DbEntityCounterpartAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DbEntityCounterpartAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DbEntityCounterpartAction.java
index 7e43e2f..adb586b 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DbEntityCounterpartAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DbEntityCounterpartAction.java
@@ -26,11 +26,9 @@ import javax.swing.tree.TreePath;
 
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
-import org.apache.cayenne.modeler.ProjectTreeModel;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
 import org.apache.cayenne.modeler.util.CayenneAction;
 
@@ -85,34 +83,5 @@ public class DbEntityCounterpartAction extends CayenneAction {
         getProjectController().fireObjEntityDisplayEvent(event);
     }
     
-    /**
-     * Builds a tree path for a given entity. Urgent for later selection.
-     * 
-     * @param entity to build path for
-     * @return tree path
-     */
-    public static TreePath buildTreePath(Entity entity) {
-        DataChannelDescriptor domain = (DataChannelDescriptor) Application
-                .getInstance()
-                .getProject()
-                .getRootNode();
-        
-        Object[] path = new Object[] {domain, entity.getDataMap(), entity};
-
-        Object[] mutableTreeNodes = new Object[path.length];
-        mutableTreeNodes[0] = ((ProjectTreeModel) editor().getProjectTreeView().getModel())
-                .getRootNode();
-
-        Object[] helper;
-        for (int i = 1; i < path.length; i++) {
-            helper = new Object[i];
-            for (int j = 0; j < i;) {
-                helper[j] = path[++j];
-            }
-            mutableTreeNodes[i] = ((ProjectTreeModel) editor()
-                    .getProjectTreeView()
-                    .getModel()).getNodeForObjectPath(helper);
-        }
-        return new TreePath(mutableTreeNodes);
-    }
+    
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a941ea7b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ObjEntityCounterpartAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ObjEntityCounterpartAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ObjEntityCounterpartAction.java
index 8920802..ec04a22 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ObjEntityCounterpartAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ObjEntityCounterpartAction.java
@@ -25,7 +25,6 @@ import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.ProjectTreeModel;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
 
 public class ObjEntityCounterpartAction extends BaseViewEntityAction {
@@ -59,34 +58,4 @@ public class ObjEntityCounterpartAction extends BaseViewEntityAction {
         getProjectController().fireDbEntityDisplayEvent(event);
     }
 
-    /**
-     * Builds a tree path for a given entity. Urgent for later selection.
-     *
-     * @param entity to build path for
-     * @return tree path
-     */
-    public static TreePath buildTreePath(Entity entity) {
-        DataChannelDescriptor domain = (DataChannelDescriptor) Application
-                .getInstance()
-                .getProject()
-                .getRootNode();
-
-        Object[] path = new Object[] {domain, entity.getDataMap(), entity};
-
-        Object[] mutableTreeNodes = new Object[path.length];
-        mutableTreeNodes[0] = ((ProjectTreeModel) editor().getProjectTreeView().getModel())
-                .getRootNode();
-
-        Object[] helper;
-        for (int i = 1; i < path.length; i++) {
-            helper = new Object[i];
-            for (int j = 0; j < i;) {
-                helper[j] = path[++j];
-            }
-            mutableTreeNodes[i] = ((ProjectTreeModel) editor()
-                    .getProjectTreeView()
-                    .getModel()).getNodeForObjectPath(helper);
-        }
-        return new TreePath(mutableTreeNodes);
-    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a941ea7b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
index 00fabd1..213b5f6 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneAction.java
@@ -31,11 +31,15 @@ import javax.swing.JButton;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JMenuItem;
 import javax.swing.KeyStroke;
+import javax.swing.tree.TreePath;
 
 import org.apache.cayenne.configuration.ConfigurationNode;
+import org.apache.cayenne.configuration.DataChannelDescriptor;
+import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.CayenneModelerFrame;
 import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.ProjectTreeModel;
 import org.apache.cayenne.modeler.dialog.ErrorDebugDialog;
 import org.apache.cayenne.modeler.editor.EditorView;
 import org.apache.cayenne.project.Project;
@@ -331,4 +335,35 @@ public abstract class CayenneAction extends AbstractAction {
                 .getFrameController()
                 .getView()).getView();
     }
+    
+    /**
+     * Builds a tree path for a given entity. Urgent for later selection.
+     * 
+     * @param entity to build path for
+     * @return tree path
+     */
+    protected static TreePath buildTreePath(Entity entity) {
+        DataChannelDescriptor domain = (DataChannelDescriptor) Application
+                .getInstance()
+                .getProject()
+                .getRootNode();
+        
+        Object[] path = new Object[] {domain, entity.getDataMap(), entity};
+
+        Object[] mutableTreeNodes = new Object[path.length];
+        mutableTreeNodes[0] = ((ProjectTreeModel) editor().getProjectTreeView().getModel())
+                .getRootNode();
+
+        Object[] helper;
+        for (int i = 1; i < path.length; i++) {
+            helper = new Object[i];
+            for (int j = 0; j < i;) {
+                helper[j] = path[++j];
+            }
+            mutableTreeNodes[i] = ((ProjectTreeModel) editor()
+                    .getProjectTreeView()
+                    .getModel()).getNodeForObjectPath(helper);
+        }
+        return new TreePath(mutableTreeNodes);
+    }
 }


Mime
View raw message