You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by sk...@apache.org on 2015/12/07 16:31:46 UTC

[7/8] cayenne git commit: cleanup

cleanup


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

Branch: refs/heads/master
Commit: b444b1df065004a41edc5f6bd13aab7788b1c7c2
Parents: 1d1bc93
Author: AlexandrShestak <sh...@mail.ru>
Authored: Tue Nov 24 13:03:41 2015 +0300
Committer: Savva Kolbachev <s....@gmail.com>
Committed: Mon Dec 7 18:27:13 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/cayenne/map/Entity.java     |  23 +-
 .../cayenne/modeler/ProjectController.java      |  13 +-
 .../objentity/ObjAttributeInfoDialog.java       |  83 +--
 .../objentity/ObjAttributeInfoDialogView.java   |  51 +-
 .../dialog/objentity/ObjRelationshipInfo.java   |  59 +-
 .../modeler/editor/ObjAttributeTableModel.java  | 400 ++++++-------
 .../modeler/editor/ObjEntityAttributePanel.java | 399 ++-----------
 .../editor/ObjEntityRelationshipPanel.java      | 568 +------------------
 .../editor/ObjRelationshipTableModel.java       | 186 +++---
 .../util/DbAttributePathComboBoxEditor.java     | 208 +++++++
 .../util/DbRelationshipPathComboBoxEditor.java  | 150 +++++
 .../EntityTreeAttributeRelationshipFilter.java  |  47 ++
 .../cayenne/modeler/util/EntityTreeFilter.java  |   4 +-
 .../util/EntityTreeRelationshipFilter.java      |  45 ++
 .../JTableCollectionTypeComboBoxEditor.java     |  84 +++
 .../JTableCollectionTypeComboBoxRenderer.java   |  55 ++
 .../util/JTableMapKeyComboBoxEditor.java        |  99 ++++
 .../util/JTableMapKeyComboBoxRenderer.java      |  58 ++
 .../util/PathChooserComboBoxCellEditor.java     | 192 +++++++
 .../cayenne/modeler/util/ProjectUtil.java       |  85 ++-
 .../modeler/util/SortButtonRenderer.java        |  82 ++-
 .../modeler/util/TableHeaderListener.java       |   2 -
 .../modeler/util/combo/AutoCompletion.java      | 182 ++++--
 23 files changed, 1546 insertions(+), 1529 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/b444b1df/cayenne-server/src/main/java/org/apache/cayenne/map/Entity.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/Entity.java b/cayenne-server/src/main/java/org/apache/cayenne/map/Entity.java
index 97613e7..e687964 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/Entity.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/Entity.java
@@ -19,6 +19,13 @@
 
 package org.apache.cayenne.map;
 
+import org.apache.cayenne.CayenneRuntimeException;
+import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.exp.ExpressionException;
+import org.apache.cayenne.util.CayenneMapEntry;
+import org.apache.cayenne.util.ToStringBuilder;
+import org.apache.cayenne.util.XMLSerializable;
+
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.Collections;
@@ -28,13 +35,6 @@ import java.util.SortedMap;
 import java.util.StringTokenizer;
 import java.util.TreeMap;
 
-import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.exp.Expression;
-import org.apache.cayenne.exp.ExpressionException;
-import org.apache.cayenne.util.CayenneMapEntry;
-import org.apache.cayenne.util.ToStringBuilder;
-import org.apache.cayenne.util.XMLSerializable;
-
 /**
  * An Entity is an abstract descriptor for an entity mapping concept. Entity can represent
  * either a descriptor of database table or a persistent object.
@@ -164,6 +164,15 @@ public abstract class Entity implements CayenneMapEntry, XMLSerializable, Serial
         attributes.remove(attrName);
     }
 
+    /**
+     *
+     * @since 4.0
+     */
+    public void updateAttribute(Attribute attribute) {
+        removeAttribute(attribute.getName());
+        addAttribute(attribute);
+    }
+
     public void clearAttributes() {
         attributes.clear();
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b444b1df/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
index 4d75685..fc805c8 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
@@ -121,8 +121,10 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.EventListener;
 import java.util.EventObject;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 import java.util.Vector;
 import java.util.prefs.Preferences;
 
@@ -1779,7 +1781,7 @@ public class ProjectController extends CayenneController {
     	
     }
 
-    public ArrayList<Embeddable> getEmbeddableNamesInCurRentDataDomain() {
+    public ArrayList<Embeddable> getEmbeddablesInCurrentDataDomain() {
         DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) getProject().getRootNode();
         Collection<DataMap> maps = dataChannelDescriptor.getDataMaps();
         Iterator<DataMap> it = maps.iterator();
@@ -1790,6 +1792,15 @@ public class ProjectController extends CayenneController {
         return embs;
     }
 
+    public Set<String> getEmbeddableNamesInCurrentDataDomain() {
+        ArrayList<Embeddable> embs = getEmbeddablesInCurrentDataDomain();
+        Set<String> embNames = new HashSet<>(embs.size());
+        for (Embeddable emb : embs) {
+            embNames.add(emb.getClassName());
+        }
+        return embNames;
+    }
+
     public void updateProjectControllerPreferences() {
         String key = getProject().getConfigurationResource() == null ? new String(IDUtil.pseudoUniqueByteSequence16())
                 : project.getConfigurationResource().getURL().getPath();

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b444b1df/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
index eceaa4f..11b4a68 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
@@ -18,31 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.dialog.objentity;
 
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JOptionPane;
-import javax.swing.JTable;
-import javax.swing.WindowConstants;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.tree.TreePath;
-
 import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
@@ -52,7 +28,6 @@ import org.apache.cayenne.map.EmbeddedAttribute;
 import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.map.event.AttributeEvent;
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.map.event.MapEvent;
@@ -61,12 +36,34 @@ import org.apache.cayenne.modeler.editor.ObjAttributeTableModel;
 import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
 import org.apache.cayenne.modeler.util.CayenneController;
-import org.apache.cayenne.modeler.util.EntityTreeFilter;
+import org.apache.cayenne.modeler.util.EntityTreeAttributeRelationshipFilter;
 import org.apache.cayenne.modeler.util.EntityTreeModel;
 import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.swing.BindingBuilder;
 import org.apache.cayenne.util.CayenneMapEntry;
 
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JOptionPane;
+import javax.swing.JTable;
+import javax.swing.WindowConstants;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.tree.TreePath;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 public class ObjAttributeInfoDialog extends CayenneController implements TreeSelectionListener {
 
 	private ObjAttributeTableModel model;
@@ -95,9 +92,9 @@ public class ObjAttributeInfoDialog extends CayenneController implements TreeSel
 		this.stringToEmbeddables = new HashMap<>();
 		this.embeddableNames = new ArrayList<String>();
 
-		Iterator<Embeddable> embs = mediator.getEmbeddableNamesInCurRentDataDomain().iterator();
+		Iterator<Embeddable> embs = mediator.getEmbeddablesInCurrentDataDomain().iterator();
 		while (embs.hasNext()) {
-			Embeddable emb = (Embeddable) embs.next();
+			Embeddable emb = embs.next();
 			stringToEmbeddables.put(emb.getClassName(), emb);
 			embeddableNames.add(emb.getClassName());
 		}
@@ -194,28 +191,7 @@ public class ObjAttributeInfoDialog extends CayenneController implements TreeSel
 
 			if (firstEntity != null) {
 				EntityTreeModel treeModel = new EntityTreeModel(firstEntity);
-				treeModel.setFilter(new EntityTreeFilter() {
-
-					public boolean attributeMatch(Object node, Attribute attr) {
-						if (!(node instanceof Attribute)) {
-							return true;
-						}
-						return false;
-					}
-
-					public boolean relationshipMatch(Object node, Relationship rel) {
-						if (!(node instanceof Relationship)) {
-							return true;
-						}
-
-						/**
-						 * We do not allow A->B->A chains, where relationships
-						 * are to-one
-						 */
-						DbRelationship prev = (DbRelationship) node;
-						return !(!rel.isToMany() && prev.getReverseRelationship() == rel);
-					}
-				});
+				treeModel.setFilter(new EntityTreeAttributeRelationshipFilter());
 				view.getPathBrowser().setModel(treeModel);
 			}
 		}
@@ -342,12 +318,11 @@ public class ObjAttributeInfoDialog extends CayenneController implements TreeSel
 		}
 		if (embeddableNames.contains(typeName)) {
 
-			Collection<EmbeddableAttribute> embAttrTemp = ((Embeddable) stringToEmbeddables.get(typeName))
-					.getAttributes();
+			Collection<EmbeddableAttribute> embAttrTemp = stringToEmbeddables.get(typeName).getAttributes();
 			Iterator<EmbeddableAttribute> it = embAttrTemp.iterator();
 
 			while (it.hasNext()) {
-				EmbeddableAttribute temp = (EmbeddableAttribute) it.next();
+				EmbeddableAttribute temp = it.next();
 				EmbeddableAttribute at = new EmbeddableAttribute();
 				at.setDbAttributeName(temp.getDbAttributeName());
 				at.setName(temp.getName());
@@ -387,7 +362,7 @@ public class ObjAttributeInfoDialog extends CayenneController implements TreeSel
 
 			StringBuilder attributePath = new StringBuilder();
 			StringBuilder pathStr = new StringBuilder();
-			if (((ObjEntity) attribute.getEntity()).getDbEntity() != null) {
+			if (attribute.getEntity().getDbEntity() != null) {
 				TreePath path = view.getPathBrowser().getSelectionPath();
 
 				if (path.getLastPathComponent() instanceof DbAttribute) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b444b1df/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java
index 3a7641e..e826f79 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java
@@ -18,26 +18,10 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.dialog.objentity;
 
-import java.awt.BorderLayout;
-import java.awt.CardLayout;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-
-import org.apache.cayenne.map.Embeddable;
+import com.jgoodies.forms.builder.PanelBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.forms.layout.RowSpec;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.pref.TableColumnPreferences;
@@ -47,10 +31,21 @@ import org.apache.cayenne.modeler.util.MultiColumnBrowser;
 import org.apache.cayenne.modeler.util.PanelFactory;
 import org.apache.cayenne.modeler.util.combo.AutoCompletion;
 
-import com.jgoodies.forms.builder.PanelBuilder;
-import com.jgoodies.forms.layout.CellConstraints;
-import com.jgoodies.forms.layout.FormLayout;
-import com.jgoodies.forms.layout.RowSpec;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import java.awt.BorderLayout;
+import java.awt.CardLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
 
 public class ObjAttributeInfoDialogView extends JDialog {
 
@@ -209,13 +204,7 @@ public class ObjAttributeInfoDialogView extends JDialog {
                     }
                 }
 
-                Iterator<Embeddable> embs = mediator.getEmbeddableNamesInCurRentDataDomain().iterator();
-                ArrayList<String> embNames = new ArrayList<String>();
-                while (embs.hasNext()) {
-                    embNames.add(embs.next().getClassName());
-                }
-
-                if (isType || !embNames.contains(typeComboBox.getSelectedItem())) {
+                if (isType || !mediator.getEmbeddableNamesInCurrentDataDomain().contains(typeComboBox.getSelectedItem())) {
                     ((CardLayout) typeManagerPane.getLayout()).show(typeManagerPane, FLATTENED_PANEL);
                 } else {
                     ((CardLayout) typeManagerPane.getLayout()).show(typeManagerPane, EMBEDDABLE_PANEL);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b444b1df/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
index caf6ed5..d7b0317 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfo.java
@@ -18,23 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.dialog.objentity;
 
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Vector;
-
-import javax.swing.JOptionPane;
-import javax.swing.WindowConstants;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.TreePath;
-
 import org.apache.cayenne.CayenneRuntimeException;
-import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.Entity;
@@ -49,10 +33,29 @@ import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ClassLoadingService;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ResolveDbRelationshipDialog;
-import org.apache.cayenne.modeler.util.*;
+import org.apache.cayenne.modeler.util.CayenneController;
+import org.apache.cayenne.modeler.util.Comparators;
+import org.apache.cayenne.modeler.util.EntityTreeModel;
+import org.apache.cayenne.modeler.util.EntityTreeRelationshipFilter;
+import org.apache.cayenne.modeler.util.MultiColumnBrowser;
+import org.apache.cayenne.modeler.util.NameGeneratorPreferences;
 import org.apache.cayenne.util.DeleteRuleUpdater;
 import org.apache.cayenne.util.Util;
 
+import javax.swing.JOptionPane;
+import javax.swing.WindowConstants;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.TreePath;
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
 public class ObjRelationshipInfo extends CayenneController implements TreeSelectionListener {
 
     static final String COLLECTION_TYPE_MAP = "java.util.Map";
@@ -182,27 +185,7 @@ public class ObjRelationshipInfo extends CayenneController implements TreeSelect
 
         if (view.pathBrowser.getModel() == null) {
             EntityTreeModel treeModel = new EntityTreeModel(getStartEntity());
-            treeModel.setFilter(new EntityTreeFilter() {
-
-                public boolean attributeMatch(Object node, Attribute attr) {
-                    // attrs not allowed here
-                    return false;
-                }
-
-                public boolean relationshipMatch(Object node, Relationship rel) {
-                    if (!(node instanceof Relationship)) {
-                        return true;
-                    }
-
-                    /**
-                     * We do not allow A->B->A chains, where relationships are
-                     * to-one
-                     */
-                    DbRelationship prev = (DbRelationship) node;
-                    return !(!rel.isToMany() && prev.getReverseRelationship() == rel);
-                }
-
-            });
+            treeModel.setFilter(new EntityTreeRelationshipFilter());
 
             view.pathBrowser.setModel(treeModel);
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b444b1df/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java
index 0cee45a..8ea39c1 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java
@@ -19,27 +19,13 @@
 
 package org.apache.cayenne.modeler.editor;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.DefaultCellEditor;
-import javax.swing.JComboBox;
-
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
-import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.EmbeddedAttribute;
-import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.event.AttributeEvent;
@@ -54,8 +40,16 @@ import org.apache.cayenne.modeler.util.CayenneTable;
 import org.apache.cayenne.modeler.util.CayenneTableModel;
 import org.apache.cayenne.modeler.util.CellEditorForAttributeTable;
 import org.apache.cayenne.modeler.util.ModelerUtil;
+import org.apache.cayenne.modeler.util.ProjectUtil;
 import org.apache.cayenne.util.Util;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
 /**
  * Model for the Object Entity attributes and for Obj to DB Attribute Mapping tables.
  * Allows adding/removing attributes, modifying the types and the names.
@@ -71,21 +65,12 @@ public class ObjAttributeTableModel extends CayenneTableModel<ObjAttributeWrappe
     public static final int DB_ATTRIBUTE_TYPE = 4;
     public static final int LOCKING = 5;
 
-    protected ObjEntity entity;
-    protected DbEntity dbEntity;
+    private ObjEntity entity;
+    private DbEntity dbEntity;
     private CellEditorForAttributeTable cellEditor;
     private CayenneTable table;
 
-    private static List<ObjAttributeWrapper> wrapObjAttributes(Collection<ObjAttribute> attributes) {
-        List<ObjAttributeWrapper>  wrappedAttributes = new ArrayList<ObjAttributeWrapper>();
-        for(ObjAttribute attr : attributes) {
-            wrappedAttributes.add(new ObjAttributeWrapper(attr));
-        }
-        return wrappedAttributes;
-    }
-
-    public ObjAttributeTableModel(ObjEntity entity, ProjectController mediator,
-            Object eventSource) {
+    public ObjAttributeTableModel(ObjEntity entity, ProjectController mediator, Object eventSource) {
         super(mediator, eventSource, wrapObjAttributes(entity.getAttributes()));
         // take a copy
         this.entity = entity;
@@ -94,6 +79,14 @@ public class ObjAttributeTableModel extends CayenneTableModel<ObjAttributeWrappe
         // order using local comparator
         Collections.sort(objectList, new AttributeComparator());
     }
+
+    private static List<ObjAttributeWrapper> wrapObjAttributes(Collection<ObjAttribute> attributes) {
+        List<ObjAttributeWrapper>  wrappedAttributes = new ArrayList<ObjAttributeWrapper>();
+        for(ObjAttribute attr : attributes) {
+            wrappedAttributes.add(new ObjAttributeWrapper(attr));
+        }
+        return wrappedAttributes;
+    }
     
     protected void orderList() {
         // NOOP
@@ -204,16 +197,14 @@ public class ObjAttributeTableModel extends CayenneTableModel<ObjAttributeWrappe
 
     private String getDBAttribute(ObjAttributeWrapper attribute, DbAttribute dbAttribute) {
         if (dbAttribute == null) {
-            if (!attribute.isInherited()
-                    && ((ObjEntity) attribute.getEntity()).isAbstract()) {
+            if (!attribute.isInherited() && attribute.getEntity().isAbstract()) {
                 return attribute.getDbAttributePath();
             }
             else {
                 return null;
             }
         }
-        else if (attribute.getDbAttributePath() != null
-                && attribute.getDbAttributePath().contains(".")) {
+        else if (attribute.getDbAttributePath() != null && attribute.getDbAttributePath().contains(".")) {
             return attribute.getDbAttributePath();
         }
         return dbAttribute.getName();
@@ -282,186 +273,115 @@ public class ObjAttributeTableModel extends CayenneTableModel<ObjAttributeWrappe
         return true;
     }
 
-    @Override
-    public void setUpdatedValueAt(Object value, int row, int column) {
-        ObjAttributeWrapper attribute = getAttribute(row);
-        attribute.resetEdits();
-        AttributeEvent event = new AttributeEvent(eventSource, attribute.getValue(), entity);
-        String path = null;
-        Collection<String> nameAttr = null;
+    private void setObjAttribute(ObjAttributeWrapper attribute, Object value) {
+        attribute.setName(value != null ? value.toString().trim() : null);
+        if (attribute.isValid()) {
+            attribute.commitEdits();
+        }
+    }
 
-        if (column == OBJ_ATTRIBUTE) {
-            event.setOldName(attribute.getName());
+    private void setObjAttributeType(ObjAttributeWrapper attribute, Object value) {
+        String oldType = attribute.getType();
+        String newType = value != null ? value.toString() : null;
 
-            attribute.setName(value != null ? value.toString().trim() : null);
+        attribute.setType(newType);
+        if (oldType == null || newType == null) {
+            return;
+        }
 
-            if (attribute.isValid()) {
-                attribute.commitEdits();
-            }
-            fireTableCellUpdated(row, column);
+        String[] registeredTypes = ModelerUtil.getRegisteredTypeNames();
+        Collection<String> registeredTypesList = Arrays.asList(registeredTypes);
+        if (registeredTypesList.contains(oldType) == registeredTypesList.contains(newType)) {
+            return;
         }
-        else if (column == OBJ_ATTRIBUTE_TYPE) {
-            String oldType = attribute.getType();
-            attribute.setType(value != null ? value.toString() : null);
-            String newType = attribute.getType();
-            String[] registeredTypes = ModelerUtil.getRegisteredTypeNames();
-            Collection<String> registeredTypesList = Arrays.asList(registeredTypes);
-
-            if (oldType != null
-                    && newType != null
-                    && !(registeredTypesList.contains(oldType) == registeredTypesList
-                            .contains(newType))) {
-                ObjAttribute attributeNew;
-
-                ArrayList<Embeddable> embs = mediator
-                        .getEmbeddableNamesInCurRentDataDomain();
-                ArrayList<String> embNames = new ArrayList<String>();
-                Iterator<Embeddable> it = embs.iterator();
-                while (it.hasNext()) {
-                    embNames.add(it.next().getClassName());
-                }
 
-                if (registeredTypesList.contains(newType) || !embNames.contains(newType)) {
-                    attributeNew = new ObjAttribute();
-                }
-                else {
-                    attributeNew = new EmbeddedAttribute();
-                    attribute.setDbAttributePath(null);
-                }
+        ObjEntity entity = attribute.getEntity();
 
-                attributeNew.setDbAttributePath(attribute.getDbAttributePath());
-                attributeNew.setName(attribute.getName());
-                attributeNew.setEntity(attribute.getEntity());
-                attributeNew.setParent(attribute.getParent());
-                attributeNew.setType(attribute.getType());
-                attributeNew.setUsedForLocking(attribute.isUsedForLocking());
-                Entity ent = attribute.getEntity();
-                ent.removeAttribute(attribute.getName());
-                ent.addAttribute(attributeNew);
-
-                mediator.fireObjEntityEvent(new EntityEvent(this, ent, MapEvent.CHANGE));
-
-                EntityDisplayEvent ev = new EntityDisplayEvent(
-                        this,
-                        mediator.getCurrentObjEntity(),
-                        mediator.getCurrentDataMap(),
-                        (DataChannelDescriptor) mediator.getProject().getRootNode());
-
-                mediator.fireObjEntityDisplayEvent(ev);
-
-                mediator.fireObjAttributeEvent(new AttributeEvent(
-                        this,
-                        attributeNew,
-                        ent,
-                        MapEvent.CHANGE));
-
-                AttributeDisplayEvent eventAttr = new AttributeDisplayEvent(
-                        this,
-                        attributeNew,
-                        mediator.getCurrentObjEntity(),
-                        mediator.getCurrentDataMap(),
-                        (DataChannelDescriptor) mediator.getProject().getRootNode());
-
-                mediator.fireObjAttributeDisplayEvent(eventAttr);
-            }
-
-            fireTableCellUpdated(row, column);
+        ObjAttribute attributeNew;
+        if (registeredTypesList.contains(newType) ||
+                !mediator.getEmbeddableNamesInCurrentDataDomain().contains(newType)) {
+            attributeNew = new ObjAttribute();
+            attributeNew.setDbAttributePath(attribute.getDbAttributePath());
+        } else {
+            attributeNew = new EmbeddedAttribute();
+            attributeNew.setDbAttributePath(null);
         }
-        else if (column == LOCKING) {
-            attribute.setUsedForLocking((value instanceof Boolean)
-                    && ((Boolean) value).booleanValue());
-            fireTableCellUpdated(row, column);
-        }
-        else {
-            if (column == DB_ATTRIBUTE) {
 
-                // If db attrib exist, associate it with obj attribute
-                if (value != null) {
-                    path = value.toString();
-
-                    String[] pathSplit = path.split("\\.");
-
-                    // If flattened attribute
-                    if (pathSplit.length > 1) {
-
-                        DbEntity currentEnt = dbEntity;
-                        StringBuilder pathBuf = new StringBuilder();
-                        boolean isTruePath = true;
-
-                        if (dbEntity != null) {
-
-                            nameAttr = ModelerUtil
-                                    .getDbAttributeNames(mediator, dbEntity);
-
-                            for (int j = 0; j < pathSplit.length; j++) {
-
-                                if (j == pathSplit.length - 1 && isTruePath) {
-                                    DbAttribute dbAttribute = (DbAttribute) currentEnt
-                                            .getAttribute(pathSplit[j]);
-                                    if (dbAttribute != null) {
-                                        pathBuf.append(dbAttribute.getName());
-                                    }
-                                    else {
-                                        isTruePath = false;
-                                    }
-                                }
-                                else if (isTruePath) {
-                                    DbRelationship dbRelationship = (DbRelationship) currentEnt
-                                            .getRelationship(pathSplit[j]);
-                                    if (dbRelationship != null) {
-                                        currentEnt = (DbEntity) dbRelationship
-                                                .getTargetEntity();
-                                        pathBuf.append(dbRelationship.getName());
-                                        pathBuf.append(".");
-                                    }
-                                    else {
-                                        isTruePath = false;
-                                    }
-                                }
-                            }
-                        }
-                        path = isTruePath ? pathBuf.toString() : null;
-
-                    }
-                    else {
-
-                        if (dbEntity != null) {
-                            DbAttribute dbAttribute = (DbAttribute) dbEntity
-                                    .getAttribute(value.toString());
-                            path = dbAttribute != null ? dbAttribute.getName() : null;
-                        }
-                    }
-                    attribute.setDbAttributePath(path);
+        attributeNew.setName(attribute.getName());
+        attributeNew.setEntity(entity);
+        attributeNew.setParent(attribute.getParent());
+        attributeNew.setType(attribute.getType());
+        attributeNew.setUsedForLocking(attribute.isUsedForLocking());
+
+        entity.updateAttribute(attributeNew);
+
+        mediator.fireObjEntityEvent(new EntityEvent(this, entity, MapEvent.CHANGE));
+
+        mediator.fireObjEntityDisplayEvent(new EntityDisplayEvent(
+                this,
+                mediator.getCurrentObjEntity(),
+                mediator.getCurrentDataMap(),
+                (DataChannelDescriptor) mediator.getProject().getRootNode()));
+
+        mediator.fireObjAttributeEvent(new AttributeEvent(
+                this,
+                attributeNew,
+                entity,
+                MapEvent.CHANGE));
+
+        mediator.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(
+                this,
+                attributeNew,
+                mediator.getCurrentObjEntity(),
+                mediator.getCurrentDataMap(),
+                (DataChannelDescriptor) mediator.getProject().getRootNode()));
+    }
 
-                }
-                // If name is erased, remove db attribute from obj attribute.
-                else if (attribute.getDbAttribute() != null) {
-                    attribute.setDbAttributePath(null);
-                }
+    private void setColumnLocking(ObjAttributeWrapper attribute, Object value) {
+        attribute.setUsedForLocking((value instanceof Boolean)
+                && ((Boolean) value).booleanValue());
+    }
+
+    private void setDbAttribute(ObjAttributeWrapper attribute, Object value) {
+
+        // If db attribute exist, associate it with obj attribute
+        if (value != null) {
+
+            if (ProjectUtil.isDbAttributePathCorrect(dbEntity,value.toString())) {
+                attribute.setDbAttributePath(value.toString());
+            } else {
+                attribute.setDbAttributePath(null);
             }
-            fireTableRowsUpdated(row, row);
         }
-        mediator.fireObjAttributeEvent(event);
+        // If name is erased, remove db attribute from obj attribute.
+        else if (attribute.getDbAttribute() != null) {
+            attribute.setDbAttributePath(null);
+        }
     }
 
-    public void setComboBoxes(Collection<String> nameAttr, int column) {
-        int count = getRowCount();
-        for (int i = 0; i < count; i++) {
-            if (getAttribute(i).getDbAttributePath() != null
-                    && getAttribute(i).getDbAttributePath().contains(".")) {
-                Collection<String> attributeComboForRow = new ArrayList<String>();
-                attributeComboForRow.addAll(nameAttr);
-                attributeComboForRow.add(getAttribute(i).getDbAttributePath());
-                JComboBox comboBoxForRow = Application.getWidgetFactory().createComboBox(
-                        attributeComboForRow,
-                        true);
-
-                cellEditor.setEditorAt(new Integer(i), new DefaultCellEditor(
-                        comboBoxForRow));
+    @Override
+    public void setUpdatedValueAt(Object value, int row, int column) {
+        ObjAttributeWrapper attribute = getAttribute(row);
+        attribute.resetEdits();
+        AttributeEvent event = new AttributeEvent(eventSource, attribute.getValue(), entity);
 
+        if (column == OBJ_ATTRIBUTE) {
+            event.setOldName(attribute.getName());
+            setObjAttribute(attribute, value);
+            fireTableCellUpdated(row, column);
+        } else if (column == OBJ_ATTRIBUTE_TYPE) {
+            setObjAttributeType(attribute, value);
+            fireTableCellUpdated(row, column);
+        } else if (column == LOCKING) {
+            setColumnLocking(attribute, value);
+            fireTableCellUpdated(row, column);
+        } else {
+            if (column == DB_ATTRIBUTE) {
+                setDbAttribute(attribute, value);
             }
+            fireTableRowsUpdated(row, row);
         }
-        table.getColumnModel().getColumn(column).setCellEditor(cellEditor);
+        mediator.fireObjAttributeEvent(event);
     }
 
     public boolean isCellEditable(int row, int col) {
@@ -511,57 +431,69 @@ public class ObjAttributeTableModel extends CayenneTableModel<ObjAttributeWrappe
                 break;
             case DB_ATTRIBUTE:
             case DB_ATTRIBUTE_TYPE:
-                Collections.sort(objectList, new Comparator<ObjAttributeWrapper>() {
-
-                    public int compare(ObjAttributeWrapper o1, ObjAttributeWrapper o2) {
-                        Integer compareObjAttributesVal = compareObjAttributes(o1, o2);
-                        if (compareObjAttributesVal != null) {
-                            return compareObjAttributesVal;
-                        }
-
-                        String valToCompare1 = getDBAttribute(o1, o1.getDbAttribute());
-                        String valToCompare2 = getDBAttribute(o2, o2.getDbAttribute());
-                        switch (sortCol) {
-                            case DB_ATTRIBUTE:
-                                valToCompare1 = getDBAttribute(o1, o1.getDbAttribute());
-                                valToCompare2 = getDBAttribute(o2, o2.getDbAttribute());
-                                break;
-                            case DB_ATTRIBUTE_TYPE:
-                                valToCompare1 = getDBAttributeType(o1, o1
-                                        .getDbAttribute());
-                                valToCompare2 = getDBAttributeType(o2, o2
-                                        .getDbAttribute());
-                                break;
-                        }
-                        return (valToCompare1 == null) ? -1 : (valToCompare2 == null)
-                                ? 1
-                                : valToCompare1.compareTo(valToCompare2);
-                    }
-
-                });
+                Collections.sort(objectList, new ObjAttributeTableComparator(sortCol));
                 if (!isAscent) {
                     Collections.reverse(objectList);
                 }
                 break;
+            default:
+                return;
+        }
+    }
+
+    private class ObjAttributeTableComparator implements Comparator<ObjAttributeWrapper>{
+
+        private int sortCol;
+
+        public ObjAttributeTableComparator(int sortCol) {
+            this.sortCol = sortCol;
+        }
 
+        @Override
+        public int compare(ObjAttributeWrapper o1, ObjAttributeWrapper o2) {
+            Integer compareObjAttributesVal = compareObjAttributes(o1, o2);
+            if (compareObjAttributesVal != null) {
+                return compareObjAttributesVal;
+            }
+            String valToCompare1 = getDBAttribute(o1, o1.getDbAttribute());
+            String valToCompare2 = getDBAttribute(o2, o2.getDbAttribute());
+            switch (sortCol) {
+                case DB_ATTRIBUTE:
+                    valToCompare1 = getDBAttribute(o1, o1.getDbAttribute());
+                    valToCompare2 = getDBAttribute(o2, o2.getDbAttribute());
+                    break;
+                case DB_ATTRIBUTE_TYPE:
+                    valToCompare1 = getDBAttributeType(o1, o1
+                            .getDbAttribute());
+                    valToCompare2 = getDBAttributeType(o2, o2
+                            .getDbAttribute());
+                    break;
+                default:
+                    break;
+            }
+            return (valToCompare1 == null) ? -1 : (valToCompare2 == null)
+                    ? 1
+                    : valToCompare1.compareTo(valToCompare2);
+        }
+
+        private Integer compareObjAttributes(ObjAttributeWrapper o1, ObjAttributeWrapper o2) {
+            if ((o1 == null && o2 == null) || o1 == o2) {
+                return 0;
+            }
+            else if (o1 == null && o2 != null) {
+                return -1;
+            }
+            else if (o1 != null && o2 == null) {
+                return 1;
+            }
+            return null;
         }
     }
 
+
     @Override
     public boolean isColumnSortable(int sortCol) {
         return true;
     }
 
-    private Integer compareObjAttributes(ObjAttributeWrapper o1, ObjAttributeWrapper o2) {
-        if ((o1 == null && o2 == null) || o1 == o2) {
-            return 0;
-        }
-        else if (o1 == null && o2 != null) {
-            return -1;
-        }
-        else if (o1 != null && o2 == null) {
-            return 1;
-        }
-        return null;
-    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/b444b1df/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
index d3496e8..46c4215 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
@@ -19,16 +19,11 @@
 package org.apache.cayenne.modeler.editor;
 
 import org.apache.cayenne.configuration.DataChannelDescriptor;
-import org.apache.cayenne.map.Attribute;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.Embeddable;
-import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.map.event.AttributeEvent;
 import org.apache.cayenne.map.event.EntityEvent;
 import org.apache.cayenne.map.event.ObjAttributeListener;
@@ -50,50 +45,38 @@ import org.apache.cayenne.modeler.event.TablePopupHandler;
 import org.apache.cayenne.modeler.pref.TableColumnPreferences;
 import org.apache.cayenne.modeler.util.CayenneTable;
 import org.apache.cayenne.modeler.util.CayenneTableModel;
-import org.apache.cayenne.modeler.util.EntityTreeFilter;
-import org.apache.cayenne.modeler.util.EntityTreeModel;
+import org.apache.cayenne.modeler.util.DbAttributePathComboBoxEditor;
 import org.apache.cayenne.modeler.util.ModelerUtil;
 import org.apache.cayenne.modeler.util.PanelFactory;
 import org.apache.cayenne.modeler.util.UIUtil;
 import org.apache.cayenne.modeler.util.combo.AutoCompletion;
-import org.apache.cayenne.util.CayenneMapEntry;
-import org.apache.commons.lang.StringUtils;
 
-import javax.swing.AbstractCellEditor;
-import javax.swing.DefaultComboBoxModel;
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
 import javax.swing.JComboBox;
 import javax.swing.JLabel;
-import javax.swing.JList;
 import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JTable;
-import javax.swing.ListCellRenderer;
 import javax.swing.ListSelectionModel;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
 import javax.swing.table.TableColumn;
-import javax.swing.text.JTextComponent;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
 import java.util.ArrayList;
-import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Pattern;
 
 /**
  * Detail view of the ObjEntity attributes.
@@ -101,8 +84,8 @@ import java.util.regex.Pattern;
 public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayListener,
         ObjEntityListener, ObjAttributeListener, ProjectOnSaveListener {
 
-    protected ProjectController mediator;
-    protected CayenneTable table;
+    private ProjectController mediator;
+    private CayenneTable table;
     private TableColumnPreferences tablePreferences;
     private ObjEntityAttributeRelationshipTab parentPanel;
     private boolean enabledResolve;//for JBottom "resolve" in ObjEntityAttrRelationshipTab
@@ -113,7 +96,7 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
      * By now popup menu item is made similar to toolbar button. (i.e. all functionality
      * is here) This should be probably refactored as Action.
      */
-    protected JMenuItem resolveMenu;
+    private JMenuItem resolveMenu;
 
     public ObjEntityAttributePanel(ProjectController mediator, ObjEntityAttributeRelationshipTab parentPanel) {
         this.mediator = mediator;
@@ -123,21 +106,20 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
         initController();
     }
 
+    public CayenneTable getTable() {
+        return table;
+    }
+
+    public void setTable(CayenneTable table) {
+        this.table = table;
+    }
+
     private void initView() {
         this.setLayout(new BorderLayout());
 
         ActionManager actionManager = Application.getInstance().getActionManager();
 
-        table = new CayenneTable(){
-            @Override
-            public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
-                Component component = super.prepareRenderer(renderer, row, column);
-                int rendererWidth = component.getPreferredSize().width;
-                TableColumn tableColumn = getColumnModel().getColumn(column);
-                tableColumn.setPreferredWidth(Math.max(rendererWidth + getIntercellSpacing().width, tableColumn.getPreferredWidth()));
-                return component;
-            }
-        };
+        table = new CayenneTable();
         table.setDefaultRenderer(String.class, new CellRenderer());
         tablePreferences = new TableColumnPreferences(
                 ObjAttributeTableModel.class,
@@ -203,7 +185,7 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
                 CopyAttributeRelationshipAction.class);
     }
 
-    public void initComboBoxes(ObjAttributeTableModel model) {
+    public void initComboBoxes() {
         List<String> embeddableNames = new ArrayList<String>();
         List<String> typeNames = new ArrayList<String>();
 
@@ -212,17 +194,13 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
                 .iterator();
         while (it.hasNext()) {
             DataMap dataMap = (DataMap) it.next();
-            Iterator<Embeddable> embs = dataMap.getEmbeddables().iterator();
-            while (embs.hasNext()) {
-                Embeddable emb = embs.next();
+            for (Embeddable emb : dataMap.getEmbeddables()) {
                 embeddableNames.add(emb.getClassName());
             }
         }
 
         String[] registeredTypes = ModelerUtil.getRegisteredTypeNames();
-        for (int i = 0; i < registeredTypes.length; i++) {
-            typeNames.add(registeredTypes[i]);
-        }
+        Collections.addAll(typeNames, registeredTypes);
         typeNames.addAll(embeddableNames);
 
         TableColumn typeColumn = table.getColumnModel().getColumn(
@@ -352,10 +330,10 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
         table.setModel(model);
         table.setRowHeight(25);
         table.setRowMargin(3);
-        setUpTableStructure(model);
+        setUpTableStructure();
     }
 
-    protected void setUpTableStructure(ObjAttributeTableModel model) {
+    protected void setUpTableStructure() {
         int inheritanceColumnWidth = 30;
 
         Map<Integer, Integer> minSizes = new HashMap<Integer, Integer>();
@@ -364,10 +342,10 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
         minSizes.put(ObjAttributeTableModel.INHERITED, inheritanceColumnWidth);
         maxSizes.put(ObjAttributeTableModel.INHERITED, inheritanceColumnWidth);
 
-        initComboBoxes(model);
+        initComboBoxes();
 
         table.getColumnModel().getColumn(3).setCellRenderer(new JTableDbAttributeComboBoxRenderer());
-        table.getColumnModel().getColumn(3).setCellEditor(new JTableDbAttributeComboBoxEditor());
+        table.getColumnModel().getColumn(3).setCellEditor(new DbAttributePathComboBoxEditor());
 
         tablePreferences.bind(
                 table,
@@ -394,7 +372,7 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
         ObjAttributeTableModel model = (ObjAttributeTableModel) table.getModel();
         if (model.getDbEntity() != ((ObjEntity) e.getEntity()).getDbEntity()) {
             model.resetDbEntity();
-            setUpTableStructure(model);
+            setUpTableStructure();
         }
     }
 
@@ -479,9 +457,10 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
 
             if (!e.getValueIsAdjusting() && !((ListSelectionModel) e.getSource()).isSelectionEmpty()) {
 
-                parentPanel.getRelationshipPanel().table.getSelectionModel().clearSelection();
-                if (parentPanel.getRelationshipPanel().table.getCellEditor() != null)
-                    parentPanel.getRelationshipPanel().table.getCellEditor().stopCellEditing();
+                parentPanel.getRelationshipPanel().getTable().getSelectionModel().clearSelection();
+                if (parentPanel.getRelationshipPanel().getTable().getCellEditor() != null) {
+                    parentPanel.getRelationshipPanel().getTable().getCellEditor().stopCellEditing();
+                }
                 Application.getInstance().getActionManager().getAction(RemoveAttributeRelationshipAction.class).setCurrentSelectedPanel(parentPanel.getAttributePanel());
                 Application.getInstance().getActionManager().getAction(CutAttributeRelationshipAction.class).setCurrentSelectedPanel(parentPanel.getAttributePanel());
                 Application.getInstance().getActionManager().getAction(CopyAttributeRelationshipAction.class).setCurrentSelectedPanel(parentPanel.getAttributePanel());
@@ -534,326 +513,16 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
         @Override
         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                                                        boolean hasFocus, int row, int column) {
-            if (value instanceof DbAttribute){
-                JLabel jLabel = new  JLabel(ModelerUtil.getObjectName(value));
-                jLabel.setFont(new Font("Verdana", Font.PLAIN , 12));
-                return jLabel;
-            }
-            if (value !=null){
-                JLabel jLabel = new JLabel(value.toString());
-                jLabel.setFont(new Font("Verdana", Font.PLAIN , 12));
-                return jLabel;
-            }
-            return new JLabel("");
-        }
-    }
-
-    private final static class JTableDbAttributeComboBoxEditor extends AbstractCellEditor implements TableCellEditor {
-
-        private int row;
-        private int column;
-        private JComboBox dbAttributePathCombo;
-        private EntityTreeModel treeModel;
-        private int previousEmbededLevel = 0;
-        private ObjAttributeTableModel model;
-
-        private JTableDbAttributeComboBoxEditor() {
-        }
-
-        @Override
-        public Object getCellEditorValue() {
-             return model.getValueAt(row,column);
-        }
+            JLabel jLabel = new JLabel("");
+            jLabel.setFont(new Font("Verdana", Font.PLAIN , 12));
 
-        @Override
-        public Component getTableCellEditorComponent(final JTable table, Object o, boolean b, int i, int i1) {
-            this.model = (ObjAttributeTableModel) table.getModel();
-            row = i;
-            column = i1;
-            treeModel = createTreeModelForComboBoxBrowser(row);
-            if (treeModel == null)
-                return new JLabel("You need select table to this ObjectEntity");
-            initializeCombo(model , row);
-
-            String dbAttributePath = ((JTextComponent) (dbAttributePathCombo).
-                    getEditor().getEditorComponent()).getText();
-            previousEmbededLevel =  StringUtils.countMatches(dbAttributePath,".");
-
-            dbAttributePathCombo.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
-                private void enterPressed(){
-                    String dbAttributePath = ((JTextComponent) (dbAttributePathCombo).
-                            getEditor().getEditorComponent()).getText();
-                    Object currentNode = getCurrentNode(dbAttributePath);
-                    if (currentNode instanceof DbAttribute) {
-                        // in this case choose is made.. we save data
-
-                        if (table.getCellEditor() != null) {
-                            table.getCellEditor().stopCellEditing();
-                            model.getAttribute(row).setDbAttributePath(dbAttributePath);
-                            model.setUpdatedValueAt(dbAttributePath, row, column);
-                        }
-                    }else if (currentNode instanceof DbRelationship) {
-                        // in this case we add dot  to pathString (if it is missing) and show variants for currentNode
-
-                        if (dbAttributePath.charAt(dbAttributePath.length()-1) != '.') {
-                            dbAttributePath = dbAttributePath + ".";
-                            previousEmbededLevel =  StringUtils.countMatches(dbAttributePath,".");
-                            ((JTextComponent) (dbAttributePathCombo).
-                                    getEditor().getEditorComponent()).setText(dbAttributePath);
-                        }
-                        List<String> currentNodeChildren = new ArrayList<>();
-                        currentNodeChildren.add(dbAttributePath + "");
-                        currentNodeChildren.addAll(getChildren(getCurrentNode(dbAttributePath), dbAttributePath));
-                        dbAttributePathCombo.setModel(new DefaultComboBoxModel(currentNodeChildren.toArray()));
-                        dbAttributePathCombo.showPopup();
-                        dbAttributePathCombo.setPopupVisible(true);
-                    }
-                }
-
-                @Override
-                public void keyReleased(KeyEvent event) {
-                    if(event.getKeyCode() == KeyEvent.VK_ENTER){
-                        enterPressed();
-                        return;
-                    }
-                    parseDbAttributeString(event.getKeyChar());
-                }
-            });
-            return dbAttributePathCombo;
-        }
-
-        private void initializeCombo(ObjAttributeTableModel model , int row){
-            String dbAttributePath = model.getAttribute(row).getValue().getDbAttributePath();
-            Object currentNode;
-            if (dbAttributePath == null){
-                //case if it is new attribute or for some reason dbAttributePath is null
-                currentNode = getCurrentNode(dbAttributePath);
-                dbAttributePath = "";
-
-            }else{
-                //case if  dbAttributePath isn't null and we must change it to find auto completion list
-                String[] pathStrings = dbAttributePath.split(Pattern.quote("."));
-                String lastStringInPath = pathStrings[pathStrings.length - 1];
-                dbAttributePath = dbAttributePath.replaceAll(lastStringInPath + "$", "");
-                currentNode = getCurrentNode(dbAttributePath);
-            }
-            List<String> nodeChildren = getChildren(currentNode , dbAttributePath);
-            dbAttributePathCombo = Application.getWidgetFactory().createComboBox(
-                    nodeChildren,
-                    false);
-            AutoCompletion.enable(dbAttributePathCombo, false, true);
-            ((JTextComponent) (dbAttributePathCombo).
-                    getEditor().getEditorComponent()).setText(model.getAttribute(row).getValue().getDbAttributePath());
-            return;
-        }
-
-        private void parseDbAttributeString(char lastEnteredCharacter){
-            String dbAttributePath = ((JTextComponent) (dbAttributePathCombo).
-                    getEditor().getEditorComponent()).getText();
-
-            if (dbAttributePath.equals("")){
-                List<String> currentNodeChildren = new ArrayList<>();
-                currentNodeChildren.add("");
-                currentNodeChildren.addAll(getChildren(getCurrentNode(dbAttributePath),""));
-                dbAttributePathCombo.setModel(new DefaultComboBoxModel(currentNodeChildren.toArray()));
-                dbAttributePathCombo.showPopup();
-                dbAttributePathCombo.setPopupVisible(true);
-                return;
+            if (value instanceof DbAttribute) {
+                jLabel.setText(ModelerUtil.getObjectName(value));
+            } else if (value != null) {
+                jLabel.setText(value.toString());
             }
 
-            if (lastEnteredCharacter == '.') {
-                processDotEntered();
-                return;
-            }
-            int currentEmbededLevel =  StringUtils.countMatches(dbAttributePath,".");
-            if (previousEmbededLevel != currentEmbededLevel){
-                previousEmbededLevel = currentEmbededLevel;
-                List<String> currentNodeChildren = new ArrayList<>();
-                String[] pathStrings = dbAttributePath.split(Pattern.quote("."));
-                String lastStringInPath = pathStrings[pathStrings.length - 1];
-                String saveDbAttributePath = dbAttributePath;
-                dbAttributePath = dbAttributePath.replaceAll(lastStringInPath + "$", "");
-                currentNodeChildren.addAll(getChildren(getCurrentNode(dbAttributePath), dbAttributePath));
-
-                dbAttributePathCombo.setModel(new DefaultComboBoxModel(currentNodeChildren.toArray()));
-                ((JTextComponent) (dbAttributePathCombo).
-                        getEditor().getEditorComponent()).setText(saveDbAttributePath);
-                dbAttributePathCombo.showPopup();
-                dbAttributePathCombo.setPopupVisible(true);
-                return;
-            }
-        }
-
-            private void processDotEntered(){
-            String dbAttributePath = ((JTextComponent) (dbAttributePathCombo).
-                    getEditor().getEditorComponent()).getText();
-            if (dbAttributePath.equals(".")){
-                List<String> currentNodeChildren = new ArrayList<>();
-                currentNodeChildren.add("");
-                currentNodeChildren.addAll(getChildren(getCurrentNode(""),""));
-                dbAttributePathCombo.setModel(new DefaultComboBoxModel(currentNodeChildren.toArray()));
-                dbAttributePathCombo.showPopup();
-                dbAttributePathCombo.setPopupVisible(true);
-                return;
-            }else {
-                char secondFromEndCharacter = dbAttributePath.charAt(dbAttributePath.length()-2);
-                if(secondFromEndCharacter == '.') {
-                    // two dots entered one by one , we replace it by one dot
-                    ((JTextComponent) (dbAttributePathCombo).
-                            getEditor().getEditorComponent()).setText(dbAttributePath.substring(0,dbAttributePath.length()-1));
-                    return;
-                }else{
-                    String[] pathStrings = dbAttributePath.split(Pattern.quote("."));
-                    String lastStringInPath = pathStrings[pathStrings.length - 1];
-
-                    //we will check if lastStringInPath is correct name of DbAttribute or DbRelationship
-                    //for appropriate previous node in path. if it is not we won't add entered dot to dbAttributePath
-                    String dbAttributePathForPreviousNode;
-                    if (pathStrings.length == 1){
-                        //previous root is treeModel.getRoot()
-                        dbAttributePathForPreviousNode = null;
-                    }else {
-                        dbAttributePathForPreviousNode = dbAttributePath.replace("."+lastStringInPath,"");
-                    }
-                    List<String> potentialVariantsToChoose = getChildren(getCurrentNode(dbAttributePathForPreviousNode),"");
-                    if (potentialVariantsToChoose.contains(lastStringInPath)){
-                        List<String> currentNodeChildren = new ArrayList<>();
-                        currentNodeChildren.add(dbAttributePath + "");
-                        currentNodeChildren.addAll(getChildren(getCurrentNode(dbAttributePath), dbAttributePath));
-                        dbAttributePathCombo.setModel(new DefaultComboBoxModel(currentNodeChildren.toArray()));
-                        dbAttributePathCombo.showPopup();
-                        dbAttributePathCombo.setPopupVisible(true);
-                    }else{
-                        ((JTextComponent) (dbAttributePathCombo).
-                                getEditor().getEditorComponent()).setText(dbAttributePath.substring(0,dbAttributePath.length()-1));
-                    }
-                }
-            }
-            previousEmbededLevel =  StringUtils.countMatches(dbAttributePath,".");
-            return;
-        }
-
-        /**
-         * find current node by dbAttributePath
-         * @param dbAttributePath
-         * @return last node in dbAttributePath which matches DbRelationship or DbAttribute
-         */
-        private final Object getCurrentNode(String dbAttributePath) {
-            try {
-                //case for new attribute
-                if(dbAttributePath == null){
-                    return treeModel.getRoot();
-                }
-                String[] pathStrings = dbAttributePath.split(Pattern.quote("."));
-                Object root = treeModel.getRoot();
-                for (int  i = 0 ; i < pathStrings.length ; i ++) {
-                    String rootChildText = pathStrings[i];
-                    for (int j = 0; j < treeModel.getChildCount(root); j++) {
-                        Object child = treeModel.getChild(root, j);
-                        String objectName = ModelerUtil.getObjectName(child);
-                        if (objectName.equals(rootChildText)) {
-                            root = child;
-                            break;
-                        }
-                    }
-                }
-                return root;
-            }catch (Exception e){
-                return treeModel.getRoot();
-            }
-        }
-
-        /**
-         * @param node for which we will find children
-         * @param dbAttributePath string which will be added to each child to make right autocomplete
-         * @return list with children , which will be used to autocomplete
-         */
-        private final List<String> getChildren(Object node , String dbAttributePath){
-            List<String> currentNodeChildren = new ArrayList<>();
-            for(int j = 0 ; j <  treeModel.getChildCount(node) ; j++){
-                Object child = treeModel.getChild(node, j);
-                String objectName = ModelerUtil.getObjectName(child);
-                currentNodeChildren.add(dbAttributePath+objectName);
-            }
-            return currentNodeChildren;
-        }
-
-        /**
-         * @param attributeIndexInTable index of attribute for which now we will create cell editor
-         * @return treeModel for nessesary for us attribute
-         */
-        private EntityTreeModel createTreeModelForComboBoxBrowser(int attributeIndexInTable){
-            ObjAttribute attribute = model.getAttribute(attributeIndexInTable).getValue();
-            Entity firstEntity = null;
-            if (attribute.getDbAttribute() == null) {
-
-                if (attribute.getParent() instanceof ObjEntity) {
-                    DbEntity dbEnt = ((ObjEntity) attribute.getParent()).getDbEntity();
-
-                    if (dbEnt != null) {
-                        Collection<DbAttribute> attributes = dbEnt.getAttributes();
-                        Collection<DbRelationship> rel = dbEnt.getRelationships();
-
-                        if (attributes.size() > 0) {
-                            Iterator<DbAttribute> iterator = attributes.iterator();
-                            firstEntity = iterator.next().getEntity();
-                        } else if (rel.size() > 0) {
-                            Iterator<DbRelationship> iterator = rel.iterator();
-                            firstEntity = iterator.next().getSourceEntity();
-                        }
-                    }
-                }
-            } else {
-                firstEntity = getFirstEntity(attribute);
-            }
-
-            if (firstEntity != null) {
-                EntityTreeModel treeModel = new EntityTreeModel(firstEntity);
-                treeModel.setFilter(new EntityTreeFilter() {
-
-                    public boolean attributeMatch(Object node, Attribute attr) {
-                        if (!(node instanceof Attribute)) {
-                            return true;
-                        }
-                        return false;
-                    }
-
-                    public boolean relationshipMatch(Object node, Relationship rel) {
-                        if (!(node instanceof Relationship)) {
-                            return true;
-                        }
-
-                        /**
-                         * We do not allow A->B->A chains, where relationships
-                         * are to-one
-                         */
-                        DbRelationship prev = (DbRelationship) node;
-                        return !(!rel.isToMany() && prev.getReverseRelationship() == rel);
-                    }
-                });
-                return treeModel;
-            }
-            return null;
-        }
-        private Entity getFirstEntity(ObjAttribute attribute) {
-            Iterator<CayenneMapEntry> it = attribute.getDbPathIterator();
-            Entity firstEnt = attribute.getDbAttribute().getEntity();
-            boolean setEnt = false;
-
-            while (it.hasNext()) {
-                Object ob = it.next();
-                if (ob instanceof DbRelationship) {
-                    if (!setEnt) {
-                        firstEnt = ((DbRelationship) ob).getSourceEntity();
-                        setEnt = true;
-                    }
-                } else if (ob instanceof DbAttribute) {
-                    if (!setEnt) {
-                        firstEnt = ((DbAttribute) ob).getEntity();
-                    }
-                }
-            }
-            return firstEnt;
+            return jLabel;
         }
     }
-}
+}
\ No newline at end of file