cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r793490 [1/2] - in /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: ./ action/ dialog/objentity/ editor/ util/
Date Mon, 13 Jul 2009 08:41:51 GMT
Author: aadamchik
Date: Mon Jul 13 08:41:50 2009
New Revision: 793490

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

FlattenedAttribute.txt patch by Olga Tkachova. Still some rough edges, but shows the idea

Added:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributePathBrowser.java
      - copied, changed from r793489, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipPathBrowser.java
Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipPathBrowser.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjAttributeTableModel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributeTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java

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=793490&r1=793489&r2=793490&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 Mon Jul 13 08:41:50 2009
@@ -135,16 +135,16 @@
         private DataMap map;
         private ObjEntity objEntity;
         private DbEntity dbEntity;
-        
+
         private ObjAttribute[] objAttrs;
         private DbAttribute[] dbAttrs;
         private ObjRelationship[] objRels;
         private DbRelationship[] dbRels;
-        
+
         private Procedure procedure;
         private ProcedureParameter[] procedureParameters;
         private Query query;
-        
+
         /**
          * Paths of multiple selection
          */
@@ -170,23 +170,23 @@
 
             objEntity = null;
             dbEntity = null;
-            
+
             procedure = null;
-            
-            //life is much easier if these guys are never null
+
+            // life is much easier if these guys are never null
             dbAttrs = new DbAttribute[0];
             dbRels = new DbRelationship[0];
             procedureParameters = new ProcedureParameter[0];
             objAttrs = new ObjAttribute[0];
             objRels = new ObjRelationship[0];
-            
+
             callbackMethods = new String[0];
 
             query = null;
 
             event = null;
             paths = null;
-            
+
             isRefiring = false;
         }
 
@@ -422,46 +422,48 @@
     protected void refreshNamespace() {
         refreshNamespace(getCurrentDataDomain());
     }
-    
+
     protected void refreshNamespace(DataDomain domain) {
         if (domain != null) {
             domain.getEntityResolver().clearCache();
         }
     }
-    
+
     /**
      * Finds a domain containing specified DataNode.
      */
     public DataDomain findDomain(DataNode node) {
-        Collection<DataDomain> domains = ((ApplicationProject) getProject()).getConfiguration()
-            .getDomains();
-        
+        Collection<DataDomain> domains = ((ApplicationProject) getProject())
+                .getConfiguration()
+                .getDomains();
+
         for (DataDomain domain : domains) {
             if (domain.getNode(node.getName()) == node) {
                 return domain;
             }
         }
-        
+
         return null;
     }
-    
+
     /**
      * Finds a domain containing specified DataMap.
      */
     public DataDomain findDomain(DataMap map) {
-        Collection<DataDomain> domains = ((ApplicationProject) getProject()).getConfiguration()
-            .getDomains();
-        
+        Collection<DataDomain> domains = ((ApplicationProject) getProject())
+                .getConfiguration()
+                .getDomains();
+
         if (map == null) {
             map = getCurrentDataMap();
         }
-    
+
         for (DataDomain domain : domains) {
             if (domain.getMap(map.getName()) == map) {
                 return domain;
             }
         }
-    
+
         return null;
     }
 
@@ -548,21 +550,21 @@
     public DbEntity getCurrentDbEntity() {
         return currentState.dbEntity;
     }
-    
+
     /**
      * @return Array of selected ObjAttributes
      */
     public ObjAttribute[] getCurrentObjAttributes() {
         return currentState.objAttrs;
     }
-    
+
     /**
      * @return Array of selected DbAttributes
      */
     public DbAttribute[] getCurrentDbAttributes() {
         return currentState.dbAttrs;
     }
-    
+
     /**
      * @return Array of selected ObjRelationships
      */
@@ -588,7 +590,7 @@
     public ProcedureParameter[] getCurrentProcedureParameters() {
         return currentState.procedureParameters;
     }
-    
+
     public ProjectPath[] getCurrentPaths() {
         return currentState.paths;
     }
@@ -689,9 +691,8 @@
             ProcedureParameterDisplayListener listener) {
         listenerList.add(ProcedureParameterDisplayListener.class, listener);
     }
-    
-    public void addMultipleObjectsDisplayListener(
-            MultipleObjectsDisplayListener listener) {
+
+    public void addMultipleObjectsDisplayListener(MultipleObjectsDisplayListener listener) {
         listenerList.add(MultipleObjectsDisplayListener.class, listener);
     }
 
@@ -718,7 +719,8 @@
             saveState(e);
         }
 
-        for (EventListener listener : listenerList.getListeners(DomainDisplayListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(DomainDisplayListener.class)) {
             DomainDisplayListener temp = (DomainDisplayListener) listener;
             temp.currentDomainChanged(e);
         }
@@ -868,7 +870,8 @@
             removeFromHistory(e);
         }
 
-        for (EventListener eventListener : listenerList.getListeners(DataMapListener.class)) {
+        for (EventListener eventListener : listenerList
+                .getListeners(DataMapListener.class)) {
             DataMapListener listener = (DataMapListener) eventListener;
             switch (e.getId()) {
                 case MapEvent.ADD:
@@ -1000,7 +1003,8 @@
             removeFromHistory(e);
         }
 
-        for (EventListener eventListener : listenerList.getListeners(ProcedureListener.class)) {
+        for (EventListener eventListener : listenerList
+                .getListeners(ProcedureListener.class)) {
             ProcedureListener listener = (ProcedureListener) eventListener;
             switch (e.getId()) {
                 case MapEvent.ADD:
@@ -1026,7 +1030,8 @@
     public void fireProcedureParameterEvent(ProcedureParameterEvent e) {
         setDirty(true);
 
-        EventListener[] list = listenerList.getListeners(ProcedureParameterListener.class);
+        EventListener[] list = listenerList
+                .getListeners(ProcedureParameterListener.class);
         for (EventListener eventListener : list) {
             ProcedureParameterListener listener = (ProcedureParameterListener) eventListener;
             switch (e.getId()) {
@@ -1191,7 +1196,8 @@
             saveState(e);
         }
 
-        for (EventListener listener : listenerList.getListeners(ObjEntityDisplayListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(ObjEntityDisplayListener.class)) {
             ObjEntityDisplayListener temp = (ObjEntityDisplayListener) listener;
             temp.currentObjEntityChanged(e);
         }
@@ -1215,7 +1221,8 @@
             saveState(e);
         }
 
-        for (EventListener eventListener : listenerList.getListeners(QueryDisplayListener.class)) {
+        for (EventListener eventListener : listenerList
+                .getListeners(QueryDisplayListener.class)) {
             QueryDisplayListener listener = (QueryDisplayListener) eventListener;
             listener.currentQueryChanged(e);
         }
@@ -1239,14 +1246,17 @@
             saveState(e);
         }
 
-        for (EventListener eventListener : listenerList.getListeners(ProcedureDisplayListener.class)) {
+        for (EventListener eventListener : listenerList
+                .getListeners(ProcedureDisplayListener.class)) {
             ProcedureDisplayListener listener = (ProcedureDisplayListener) eventListener;
             listener.currentProcedureChanged(e);
         }
     }
 
     public void fireProcedureParameterDisplayEvent(ProcedureParameterDisplayEvent e) {
-        boolean changed = !Arrays.equals(e.getProcedureParameters(), currentState.procedureParameters);
+        boolean changed = !Arrays.equals(
+                e.getProcedureParameters(),
+                currentState.procedureParameters);
 
         if (changed) {
             if (currentState.procedure != e.getProcedure()) {
@@ -1258,7 +1268,8 @@
             currentState.procedureParameters = e.getProcedureParameters();
         }
 
-        EventListener[] list = listenerList.getListeners(ProcedureParameterDisplayListener.class);
+        EventListener[] list = listenerList
+                .getListeners(ProcedureParameterDisplayListener.class);
         for (EventListener eventListener : list) {
             ProcedureParameterDisplayListener listener = (ProcedureParameterDisplayListener) eventListener;
             listener.currentProcedureParameterChanged(e);
@@ -1283,7 +1294,8 @@
             saveState(e);
         }
 
-        for (EventListener listener : listenerList.getListeners(DbEntityDisplayListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(DbEntityDisplayListener.class)) {
             DbEntityDisplayListener temp = (DbEntityDisplayListener) listener;
             temp.currentDbEntityChanged(e);
         }
@@ -1293,7 +1305,8 @@
     public void fireDbAttributeEvent(AttributeEvent e) {
         setDirty(true);
 
-        for (EventListener listener : listenerList.getListeners(DbAttributeListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(DbAttributeListener.class)) {
             DbAttributeListener temp = (DbAttributeListener) listener;
             switch (e.getId()) {
                 case MapEvent.ADD:
@@ -1323,11 +1336,16 @@
                 currentState.dbEntity = (DbEntity) e.getEntity();
             }
             currentState.dbAttrs = new DbAttribute[e.getAttributes().length];
-            System.arraycopy(e.getAttributes(), 0, currentState.dbAttrs, 0, 
+            System.arraycopy(
+                    e.getAttributes(),
+                    0,
+                    currentState.dbAttrs,
+                    0,
                     currentState.dbAttrs.length);
         }
 
-        for (EventListener listener : listenerList.getListeners(DbAttributeDisplayListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(DbAttributeDisplayListener.class)) {
             DbAttributeDisplayListener temp = (DbAttributeDisplayListener) listener;
             temp.currentDbAttributeChanged(e);
         }
@@ -1337,7 +1355,8 @@
     public void fireObjAttributeEvent(AttributeEvent e) {
         setDirty(true);
 
-        for (EventListener listener : listenerList.getListeners(ObjAttributeListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(ObjAttributeListener.class)) {
             ObjAttributeListener temp = (ObjAttributeListener) listener;
             switch (e.getId()) {
                 case MapEvent.ADD:
@@ -1357,7 +1376,7 @@
     }
 
     public void fireObjAttributeDisplayEvent(AttributeDisplayEvent e) {
-        boolean changed = !Arrays.equals(e.getAttributes(), currentState.objAttrs); 
+        boolean changed = !Arrays.equals(e.getAttributes(), currentState.objAttrs);
 
         if (changed) {
             if (e.getEntity() != currentState.objEntity) {
@@ -1367,11 +1386,16 @@
                 currentState.objEntity = (ObjEntity) e.getEntity();
             }
             currentState.objAttrs = new ObjAttribute[e.getAttributes().length];
-            System.arraycopy(e.getAttributes(), 0, currentState.objAttrs, 0, 
+            System.arraycopy(
+                    e.getAttributes(),
+                    0,
+                    currentState.objAttrs,
+                    0,
                     currentState.objAttrs.length);
         }
 
-        EventListener[] list = listenerList.getListeners(ObjAttributeDisplayListener.class);
+        EventListener[] list = listenerList
+                .getListeners(ObjAttributeDisplayListener.class);
         for (EventListener listener : list) {
             ObjAttributeDisplayListener temp = (ObjAttributeDisplayListener) listener;
             temp.currentObjAttributeChanged(e);
@@ -1386,7 +1410,8 @@
             ((DbEntity) e.getEntity()).dbRelationshipChanged(e);
         }
 
-        for (EventListener listener : listenerList.getListeners(DbRelationshipListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(DbRelationshipListener.class)) {
             DbRelationshipListener temp = (DbRelationshipListener) listener;
             switch (e.getId()) {
                 case MapEvent.ADD:
@@ -1416,11 +1441,16 @@
                 currentState.dbEntity = (DbEntity) e.getEntity();
             }
             currentState.dbRels = new DbRelationship[e.getRelationships().length];
-            System.arraycopy(e.getRelationships(), 0, currentState.dbRels, 0, 
+            System.arraycopy(
+                    e.getRelationships(),
+                    0,
+                    currentState.dbRels,
+                    0,
                     currentState.dbRels.length);
         }
 
-        for (EventListener listener : listenerList.getListeners(DbRelationshipDisplayListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(DbRelationshipDisplayListener.class)) {
             DbRelationshipDisplayListener temp = (DbRelationshipDisplayListener) listener;
             temp.currentDbRelationshipChanged(e);
         }
@@ -1430,7 +1460,8 @@
     public void fireObjRelationshipEvent(RelationshipEvent e) {
         setDirty(true);
 
-        for (EventListener listener : listenerList.getListeners(ObjRelationshipListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(ObjRelationshipListener.class)) {
             ObjRelationshipListener temp = (ObjRelationshipListener) listener;
             switch (e.getId()) {
                 case MapEvent.ADD:
@@ -1448,12 +1479,13 @@
             }
         }
     }
-    
+
     public void fireMultipleObjectsDisplayEvent(MultipleObjectsDisplayEvent e) {
         clearState();
         currentState.paths = e.getPaths();
-        
-        EventListener[] list = listenerList.getListeners(MultipleObjectsDisplayListener.class);
+
+        EventListener[] list = listenerList
+                .getListeners(MultipleObjectsDisplayListener.class);
         for (EventListener listener : list) {
             MultipleObjectsDisplayListener temp = (MultipleObjectsDisplayListener) listener;
             temp.currentObjectsChanged(e);
@@ -1472,17 +1504,22 @@
                 currentState.objEntity = (ObjEntity) e.getEntity();
             }
             currentState.objRels = new ObjRelationship[e.getRelationships().length];
-            System.arraycopy(e.getRelationships(), 0, currentState.objRels, 0, 
+            System.arraycopy(
+                    e.getRelationships(),
+                    0,
+                    currentState.objRels,
+                    0,
                     currentState.objRels.length);
         }
 
-        EventListener[] list = listenerList.getListeners(ObjRelationshipDisplayListener.class);
+        EventListener[] list = listenerList
+                .getListeners(ObjRelationshipDisplayListener.class);
         for (EventListener listener : list) {
             ObjRelationshipDisplayListener temp = (ObjRelationshipDisplayListener) listener;
             temp.currentObjRelationshipChanged(e);
         }
     }
-    
+
     public void addDataMap(Object src, DataMap map) {
         addDataMap(src, map, true);
     }
@@ -1580,7 +1617,8 @@
     public void fireCallbackMethodEvent(CallbackMethodEvent e) {
         setDirty(true);
 
-        for (EventListener listener : listenerList.getListeners(CallbackMethodListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(CallbackMethodListener.class)) {
             CallbackMethodListener temp = (CallbackMethodListener) listener;
             switch (e.getId()) {
                 case MapEvent.ADD:
@@ -1616,7 +1654,8 @@
     public void fireEntityListenerEvent(EntityListenerEvent e) {
         setDirty(true);
 
-        for (EventListener listener : listenerList.getListeners(EntityListenerListener.class)) {
+        for (EventListener listener : listenerList
+                .getListeners(EntityListenerListener.class)) {
             EntityListenerListener temp = (EntityListenerListener) listener;
             switch (e.getId()) {
                 case MapEvent.ADD:
@@ -1641,9 +1680,10 @@
     public ProjectWatchdog getProjectWatcher() {
         return watchdog;
     }
-    
+
     /**
-     * Returns currently selected object, null if there are none, List if there are several
+     * Returns currently selected object, null if there are none, List if there are
+     * several
      */
     @SuppressWarnings("unchecked")
     public Object getCurrentObject() {
@@ -1668,29 +1708,29 @@
         else if (getCurrentDataDomain() != null) {
             return getCurrentDataDomain();
         }
-        else if (getCurrentPaths() != null) { //multiple objects
+        else if (getCurrentPaths() != null) { // multiple objects
             ProjectPath[] paths = getCurrentPaths();
             List<Object> result = new Vector<Object>();
-            
+
             Object parent = paths[0].getObjectParent();
 
             for (ProjectPath path : paths) {
                 Object lastObject = path.getObject();
                 result.add(lastObject);
             }
-            
+
             /**
              * Here we sort the list of objects to minimize the risk that objects will be
-             * pasted incorrectly. For instance, ObjEntity should go before Query, to increase
-             * chances that Query's root would be set. 
+             * pasted incorrectly. For instance, ObjEntity should go before Query, to
+             * increase chances that Query's root would be set.
              */
-            Collections.sort(result, parent instanceof DataMap ? 
-                    Comparators.getDataMapChildrenComparator() :
-                    Comparators.getDataDomainChildrenComparator());
-            
+            Collections.sort(result, parent instanceof DataMap ? Comparators
+                    .getDataMapChildrenComparator() : Comparators
+                    .getDataDomainChildrenComparator());
+
             return result;
         }
-        
+
         return null;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java?rev=793490&r1=793489&r2=793490&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAction.java Mon Jul 13 08:41:50 2009
@@ -17,14 +17,12 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.modeler.action;
 
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 import java.util.ArrayList;
-import java.util.Iterator;
 
 import javax.swing.KeyStroke;
 
@@ -79,17 +77,20 @@
 
     @Override
     public KeyStroke getAcceleratorKey() {
-        return KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
+        return KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit
+                .getDefaultToolkit()
+                .getMenuShortcutKeyMask());
     }
 
     /**
      * Creates and returns dialog for delete prompt
-     * @param allowAsking If false, no question will be asked no matter what settings are 
+     * 
+     * @param allowAsking If false, no question will be asked no matter what settings are
      */
     public ConfirmRemoveDialog getConfirmDeleteDialog(boolean allowAsking) {
         return new ConfirmRemoveDialog(allowAsking);
     }
-    
+
     @Override
     public void performAction(ActionEvent e) {
         performAction(e, true);
@@ -97,7 +98,8 @@
 
     /**
      * Performs delete action
-     * @param allowAsking If false, no question will be asked no matter what settings are 
+     * 
+     * @param allowAsking If false, no question will be asked no matter what settings are
      */
     public void performAction(ActionEvent e, boolean allowAsking) {
 
@@ -106,13 +108,16 @@
         ConfirmRemoveDialog dialog = getConfirmDeleteDialog(allowAsking);
 
         if (mediator.getCurrentObjEntity() != null) {
-            if (dialog.shouldDelete("ObjEntity", mediator.getCurrentObjEntity().getName())) {
-                removeObjEntity(mediator.getCurrentDataMap(), mediator.getCurrentObjEntity());
+            if (dialog
+                    .shouldDelete("ObjEntity", mediator.getCurrentObjEntity().getName())) {
+                removeObjEntity(mediator.getCurrentDataMap(), mediator
+                        .getCurrentObjEntity());
             }
         }
         else if (mediator.getCurrentDbEntity() != null) {
             if (dialog.shouldDelete("DbEntity", mediator.getCurrentDbEntity().getName())) {
-                removeDbEntity(mediator.getCurrentDataMap(), mediator.getCurrentDbEntity());
+                removeDbEntity(mediator.getCurrentDataMap(), mediator
+                        .getCurrentDbEntity());
             }
         }
         else if (mediator.getCurrentQuery() != null) {
@@ -121,8 +126,10 @@
             }
         }
         else if (mediator.getCurrentProcedure() != null) {
-            if (dialog.shouldDelete("procedure", mediator.getCurrentProcedure().getName())) {
-                removeProcedure(mediator.getCurrentDataMap(), mediator.getCurrentProcedure());
+            if (dialog
+                    .shouldDelete("procedure", mediator.getCurrentProcedure().getName())) {
+                removeProcedure(mediator.getCurrentDataMap(), mediator
+                        .getCurrentProcedure());
             }
         }
         else if (mediator.getCurrentDataMap() != null) {
@@ -130,25 +137,30 @@
 
                 // In context of Data node just remove from Data Node
                 if (mediator.getCurrentDataNode() != null) {
-                    removeDataMapFromDataNode(mediator.getCurrentDataNode(), mediator.getCurrentDataMap());
+                    removeDataMapFromDataNode(mediator.getCurrentDataNode(), mediator
+                            .getCurrentDataMap());
                 }
                 else {
                     // Not under Data Node, remove completely
-                    removeDataMap(mediator.getCurrentDataDomain(), mediator.getCurrentDataMap());
+                    removeDataMap(mediator.getCurrentDataDomain(), mediator
+                            .getCurrentDataMap());
                 }
             }
         }
         else if (mediator.getCurrentDataNode() != null) {
             if (dialog.shouldDelete("data node", mediator.getCurrentDataNode().getName())) {
-                removeDataNode(mediator.getCurrentDataDomain(), mediator.getCurrentDataNode());
+                removeDataNode(mediator.getCurrentDataDomain(), mediator
+                        .getCurrentDataNode());
             }
         }
         else if (mediator.getCurrentDataDomain() != null) {
-            if (dialog.shouldDelete("data domain", mediator.getCurrentDataDomain().getName())) {
+            if (dialog.shouldDelete("data domain", mediator
+                    .getCurrentDataDomain()
+                    .getName())) {
                 removeDomain(mediator.getCurrentDataDomain());
             }
         }
-        else if (mediator.getCurrentPaths() != null) { //multiple deletion
+        else if (mediator.getCurrentPaths() != null) { // multiple deletion
             if (dialog.shouldDelete("selected objects")) {
                 ProjectPath[] paths = mediator.getCurrentPaths();
                 for (ProjectPath path : paths) {
@@ -157,11 +169,11 @@
             }
         }
     }
-    
-    private void removeDomain(DataDomain domain){
+
+    private void removeDomain(DataDomain domain) {
         ApplicationProject project = (ApplicationProject) getCurrentProject();
         ProjectController mediator = getProjectController();
-        
+
         project.getConfiguration().removeDomain(domain.getName());
         mediator.fireDomainEvent(new DomainEvent(
                 Application.getFrame(),
@@ -171,11 +183,8 @@
 
     private void removeDataMap(DataDomain domain, DataMap map) {
         ProjectController mediator = getProjectController();
-        
-        DataMapEvent e = new DataMapEvent(
-                Application.getFrame(),
-                map,
-                MapEvent.REMOVE);
+
+        DataMapEvent e = new DataMapEvent(Application.getFrame(), map, MapEvent.REMOVE);
         e.setDomain(domain);
 
         domain.removeMap(map.getName());
@@ -184,11 +193,8 @@
 
     private void removeDataNode(DataDomain domain, DataNode node) {
         ProjectController mediator = getProjectController();
-        
-        DataNodeEvent e = new DataNodeEvent(
-                Application.getFrame(),
-                node,
-                MapEvent.REMOVE);
+
+        DataNodeEvent e = new DataNodeEvent(Application.getFrame(), node, MapEvent.REMOVE);
         e.setDomain(domain);
 
         domain.removeDataNode(node.getName());
@@ -200,11 +206,8 @@
      */
     private void removeDbEntity(DataMap map, DbEntity ent) {
         ProjectController mediator = getProjectController();
-        
-        EntityEvent e = new EntityEvent(
-                Application.getFrame(),
-                ent,
-                MapEvent.REMOVE);
+
+        EntityEvent e = new EntityEvent(Application.getFrame(), ent, MapEvent.REMOVE);
         e.setDomain(mediator.findDomain(map));
 
         map.removeDbEntity(ent.getName(), true);
@@ -216,14 +219,10 @@
      */
     private void removeQuery(DataMap map, Query query) {
         ProjectController mediator = getProjectController();
-        
-        QueryEvent e = new QueryEvent(
-                Application.getFrame(),
-                query,
-                MapEvent.REMOVE,
-                map);
+
+        QueryEvent e = new QueryEvent(Application.getFrame(), query, MapEvent.REMOVE, map);
         e.setDomain(mediator.findDomain(map));
-        
+
         map.removeQuery(query.getName());
         mediator.fireQueryEvent(e);
     }
@@ -233,13 +232,13 @@
      */
     private void removeProcedure(DataMap map, Procedure procedure) {
         ProjectController mediator = getProjectController();
-        
+
         ProcedureEvent e = new ProcedureEvent(
                 Application.getFrame(),
                 procedure,
                 MapEvent.REMOVE);
         e.setDomain(mediator.findDomain(map));
-        
+
         map.removeProcedure(procedure.getName());
         mediator.fireProcedureEvent(e);
     }
@@ -249,13 +248,10 @@
      */
     private void removeObjEntity(DataMap map, ObjEntity entity) {
         ProjectController mediator = getProjectController();
-        
-        EntityEvent e = new EntityEvent(
-                Application.getFrame(),
-                entity,
-                MapEvent.REMOVE);
+
+        EntityEvent e = new EntityEvent(Application.getFrame(), entity, MapEvent.REMOVE);
         e.setDomain(mediator.findDomain(map));
-        
+
         map.removeObjEntity(entity.getName(), true);
         mediator.fireObjEntityEvent(e);
 
@@ -269,8 +265,8 @@
 
             if (root == entity
                     || (root instanceof String && root
-                    .toString()
-                    .equals(entity.getName()))) {
+                            .toString()
+                            .equals(entity.getName()))) {
                 removeQuery(map, next);
             }
         }
@@ -278,10 +274,10 @@
 
     private void removeDataMapFromDataNode(DataNode node, DataMap map) {
         ProjectController mediator = getProjectController();
-        
+
         DataNodeEvent e = new DataNodeEvent(Application.getFrame(), node);
         e.setDomain(mediator.findDomain(node));
-        
+
         node.removeDataMap(map.getName());
 
         // Force reloading of the data node in the browse view
@@ -327,22 +323,23 @@
             return false;
         }
     }
-    
+
     /**
      * Removes an object, depending on its type
      */
     private void removeLastPathComponent(ProjectPath path) {
         Object lastObject = path.getObject();
-        
+
         if (lastObject instanceof DataDomain) {
             removeDomain((DataDomain) lastObject);
         }
         else if (lastObject instanceof DataMap) {
             Object parent = path.getObjectParent();
-            
-            if(parent instanceof DataDomain)
+
+            if (parent instanceof DataDomain)
                 removeDataMap((DataDomain) parent, (DataMap) lastObject);
-            else //if(parent instanceof DataNode)
+            else
+                // if(parent instanceof DataNode)
                 removeDataMapFromDataNode((DataNode) parent, (DataMap) lastObject);
         }
         else if (lastObject instanceof DataNode) {

Added: 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=793490&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialog.java Mon Jul 13 08:41:50 2009
@@ -0,0 +1,400 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.dialog.objentity;
+
+import java.awt.Component;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+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.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.Entity;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.Relationship;
+import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.editor.ObjAttributeTableModel;
+import org.apache.cayenne.modeler.util.CayenneController;
+import org.apache.cayenne.modeler.util.Comparators;
+import org.apache.cayenne.modeler.util.EntityTreeFilter;
+import org.apache.cayenne.modeler.util.EntityTreeModel;
+import org.apache.cayenne.swing.BindingBuilder;
+import org.apache.cayenne.util.CayenneMapEntry;
+
+public class ObjAttributeInfoDialog extends CayenneController implements
+        TreeSelectionListener {
+
+    private ObjAttributeTableModel model;
+    private int row;
+    protected ObjAttributeInfoDialogView view;
+    protected ObjAttribute attribute;
+    protected ObjAttribute attributeSaved;
+
+    protected List attributesList;
+    protected List attributesSavedList;
+
+    protected List<DbEntity> relTargets;
+
+    protected ObjEntity objectTarget;
+    protected List<ObjEntity> objectTargets;
+
+    protected List<String> mapKeys;
+    protected ProjectController mediator;
+
+    public ObjAttributeInfoDialog(ProjectController mediator, int row,
+            ObjAttributeTableModel model) {
+        super(mediator);
+        this.view = new ObjAttributeInfoDialogView();
+        this.mediator = mediator;
+        this.model = model;
+        this.row = row;
+        initController(model.getAttribute(row));
+    }
+
+    @Override
+    public Component getView() {
+        return view;
+    }
+
+    /**
+     * Starts options dialog.
+     */
+    public void startupAction() {
+        view.pack();
+        view.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
+        view.setModal(true);
+        makeCloseableOnEscape();
+        centerView();
+        view.setVisible(true);
+
+    }
+
+    private void initController(ObjAttribute attr) {
+        this.attribute = attr;
+        this.attributeSaved = new ObjAttribute();
+        attributeSaved.setDbAttributePath(attribute.getDbAttributePath());
+        attributeSaved.setName(attribute.getName());
+        attributeSaved.setEntity(attribute.getEntity());
+        attributeSaved.setParent(attribute.getParent());
+        attributeSaved.setType(attribute.getType());
+        attributeSaved.setUsedForLocking(attribute.isUsedForLocking());
+
+        relTargets = new ArrayList<DbEntity>(attribute
+                .getEntity()
+                .getDataMap()
+                .getDbEntities());
+
+        /**
+         * Register auto-selection of the target
+         */
+        view.getPathBrowser().addTreeSelectionListener(this);
+        this.objectTarget = (ObjEntity) attr.getEntity();
+        if (objectTarget != null) {
+            updateTargetCombo(objectTarget.getDbEntity());
+        }
+
+        view.getAttributeName().setText(attribute.getName());
+        if (attribute.getDbAttributePath() != null) {
+            if (attribute.getDbAttributePath().contains(".")) {
+                String path = attribute.getDbAttributePath();
+                view.getCurrentPathLabel().setText(path.replace(".", " -> "));
+            }
+            else {
+                view.getCurrentPathLabel().setText(attribute.getDbAttributePath());
+            }
+        }
+        else {
+            view.getCurrentPathLabel().setText("");
+        }
+        view.getSourceEntityLabel().setText(attribute.getEntity().getName());
+        BindingBuilder builder = new BindingBuilder(
+                getApplication().getBindingFactory(),
+                this);
+        builder.bindToAction(view.getCancelButton(), "closeAction()");
+        builder.bindToAction(view.getSelectPathButton(), "setPath()");
+        builder.bindToAction(view.getSaveButton(), "saveMapping()");
+
+        /*
+         * set filter for ObjAttributePathBrowser
+         */
+        if (view.getPathBrowser().getModel() == null) {
+            Entity firstEntity = null;
+            if (attribute.getDbAttribute() == null) {
+
+                Iterator<CayenneMapEntry> it = attribute.getDbPathIterator();
+                if (attribute.getParent() instanceof ObjEntity) {
+                    DbEntity dbEnt = ((ObjEntity) attribute.getParent()).getDbEntity();
+
+                    Collection<DbAttribute> attrib = dbEnt.getAttributes();
+                    Collection<DbRelationship> rel = dbEnt.getRelationships();
+
+                    if (attrib.size() > 0) {
+                        Iterator<DbAttribute> iter = attrib.iterator();
+                        firstEntity = iter.next().getEntity();
+                    }
+                    else if (rel.size() > 0) {
+                        Iterator<DbRelationship> iter = rel.iterator();
+                        firstEntity = iter.next().getSourceEntity();
+                    }
+                }
+            }
+            else {
+                firstEntity = getFirstEntity();
+            }
+
+            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);
+                    }
+                });
+                view.getPathBrowser().setModel(treeModel);
+
+            }
+        }
+
+        if (attribute.getDbAttribute() != null) {
+            setSelectionPath();
+        }
+    }
+
+    public void closeAction() {
+        view.dispose();
+    }
+
+    public boolean isChange() {
+        StringBuilder attriburePathStr = 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++) {
+                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());
+                }
+                else {
+                    attrOrRel = false;
+                }
+
+                if (i != ob.length - 1 && attrOrRel) {
+                    pathStr.append(" -> ");
+                    attriburePathStr.append(".");
+                }
+            }
+        }
+        else {
+            view.getCurrentPathLabel().setText("");
+            attriburePathStr = null;
+        }
+
+        view.getCurrentPathLabel().setText(pathStr.toString());
+
+        if (attribute.getDbAttributePath() != null) {
+            if (!attribute.getDbAttributePath().equals(attriburePathStr.toString())
+                    || !attribute.getName().equals(view.getAttributeName().getText())) {
+                attributeSaved.setDbAttributePath(attriburePathStr.toString());
+                attributeSaved.setName(view.getAttributeName().getText());
+                return true;
+            }
+        }
+        else if (attribute.getDbAttributePath() == null) {
+            if (attriburePathStr.toString().length() > 0
+                    || !attribute.getName().equals(view.getAttributeName().getText())) {
+                attributeSaved.setDbAttributePath(attriburePathStr.toString());
+                attributeSaved.setName(view.getAttributeName().getText());
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public void saveMapping() {
+
+        if (isChange()) {
+            if (JOptionPane.showConfirmDialog(
+                    (Component) getView(),
+                    "You have changed Db Attribute path. Do you want it to be saved?",
+                    "Save ObjAttribute",
+                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
+                model.setUpdatedValueAt(attributeSaved.getDbAttributePath(), row, 3);
+                model.setUpdatedValueAt(attributeSaved.getName(), row, 1);
+            }
+        }
+
+        closeAction();
+    }
+
+    public void valueChanged(TreeSelectionEvent e) {
+
+        TreePath selectedPath = e.getPath();
+
+        // first item in the path is Entity, so we must have
+        // at least two elements to constitute a valid ordering path
+        if (selectedPath == null || selectedPath.getPathCount() < 2) {
+            return;
+        }
+
+        DbEntity target = null;
+        if (selectedPath.getLastPathComponent() instanceof Relationship) {
+            Relationship rel = (Relationship) selectedPath.getLastPathComponent();
+            target = (DbEntity) rel.getTargetEntity();
+
+        }
+        else if (selectedPath.getLastPathComponent() instanceof Attribute) {
+            Attribute attr = (Attribute) selectedPath.getLastPathComponent();
+            target = (DbEntity) attr.getEntity();
+        }
+
+        if (target != null) {
+
+            /**
+             * Initialize root with one of mapped ObjEntities.
+             */
+            Collection<ObjEntity> objEntities = target.getDataMap().getMappedEntities(
+                    target);
+
+            List<DbRelationship> relPath = new Vector<DbRelationship>(selectedPath
+                    .getPathCount() - 1);
+            for (int i = 1; i < selectedPath.getPathCount(); i++) {
+                if (selectedPath.getLastPathComponent() instanceof Relationship) {
+                    relPath.add((DbRelationship) selectedPath.getPathComponent(i));
+                }
+            }
+
+            setObjectTarget(objEntities.size() == 0 ? null : objEntities
+                    .iterator()
+                    .next());
+            if (objectTarget != null) {
+                updateTargetCombo(objectTarget.getDbEntity());
+            }
+            else {
+                updateTargetCombo(null);
+            }
+        }
+    }
+
+    public void setObjectTarget(ObjEntity objectTarget) {
+        if (this.objectTarget != objectTarget) {
+            this.objectTarget = objectTarget;
+        }
+    }
+
+    protected void updateTargetCombo(DbEntity dbTarget) {
+        if (dbTarget != null) {
+            // copy those that have DbEntities mapped to dbTarget, and then sort
+
+            view.getTargCombo().removeAllItems();
+            this.objectTargets = new ArrayList<ObjEntity>();
+
+            if (dbTarget != null) {
+                objectTargets.addAll(dbTarget.getDataMap().getMappedEntities(dbTarget));
+                Collections.sort(objectTargets, Comparators.getNamedObjectComparator());
+            }
+
+            for (ObjEntity obj : objectTargets) {
+                view.getTargCombo().addItem(obj.getName());
+            }
+        }
+        else {
+            view.getTargCombo().addItem("");
+        }
+    }
+
+    private Entity getFirstEntity() {
+        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;
+    }
+
+    /**
+     * Selects path in browser
+     */
+    public void setSelectionPath() {
+        List list = new ArrayList();
+        boolean isAttributeLast = false;
+        Iterator<CayenneMapEntry> it = attribute.getDbPathIterator();
+        while (it.hasNext()) {
+            Object obj = it.next();
+            list.add(obj);
+            if (obj instanceof DbAttribute && !it.hasNext()) {
+                isAttributeLast = true;
+            }
+        }
+        if (isAttributeLast) {
+            Object[] path = new Object[list.size() + 1];
+            path[0] = getFirstEntity();
+            System.arraycopy(list.toArray(), 0, path, 1, list.size());
+            view.getPathBrowser().setSelectionPath(new TreePath(path));
+            view.getSaveButton().setEnabled(true);
+        }
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java?rev=793490&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributeInfoDialogView.java Mon Jul 13 08:41:50 2009
@@ -0,0 +1,150 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.modeler.dialog.objentity;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+
+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.modeler.util.MultiColumnBrowser;
+import org.apache.cayenne.modeler.util.PanelFactory;
+
+import com.jgoodies.forms.builder.PanelBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+
+public class ObjAttributeInfoDialogView extends JDialog {
+
+    /**
+     * // * Browser to select path for attribute //
+     */
+    protected MultiColumnBrowser pathBrowser;
+
+    protected JButton cancelButton;
+    protected JButton saveButton;
+    protected JButton selectPathButton;
+
+    protected JTextField attributeName;
+    protected JLabel currentPathLabel;
+    protected JLabel sourceEntityLabel;
+    protected JComboBox targCombo;
+    
+    static final Dimension BROWSER_CELL_DIM = new Dimension(130, 200);
+
+    public ObjAttributeInfoDialogView() {
+
+        // create widgets
+        this.cancelButton = new JButton("Close");
+        this.saveButton = new JButton("Done");
+        this.selectPathButton = new JButton("Select path");
+        this.attributeName = new JTextField(25);
+        this.currentPathLabel = new JLabel();
+        this.sourceEntityLabel = new JLabel();
+
+        saveButton.setEnabled(false);
+        cancelButton.setEnabled(true);
+        selectPathButton.setEnabled(false);
+
+        targCombo = new JComboBox();
+
+        setTitle("ObjAttribute Inspector");
+        setLayout(new BorderLayout());
+
+        CellConstraints cc = new CellConstraints();
+        PanelBuilder builder = new PanelBuilder(
+                new FormLayout(
+                        "right:max(50dlu;pref), 3dlu, fill:min(150dlu;pref), 3dlu, 300dlu, 3dlu, fill:min(120dlu;pref)",
+                        "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, top:14dlu, 3dlu, top:p:grow"));
+        builder.setDefaultDialogBorder();
+        builder.addSeparator("ObjAttribute Information", cc.xywh(1, 1, 5, 1));
+        builder.addLabel("Attribute:", cc.xy(1, 3));
+        builder.add(attributeName, cc.xywh(3, 3, 1, 1));
+
+        builder.addLabel("Current Db Path:", cc.xy(1, 5));
+        builder.add(currentPathLabel, cc.xywh(3, 5, 5, 1));
+
+        builder.addLabel("Source:", cc.xy(1, 7));
+        builder.add(sourceEntityLabel, cc.xywh(3, 7, 1, 1));
+
+        builder.addLabel("Target:", cc.xy(1, 9));
+        builder.add(targCombo, cc.xywh(3, 9, 1, 1));
+
+        builder.addSeparator("Mapping to DbRelationships", cc.xywh(1, 11, 5, 1));
+
+        JPanel buttonsPane = new JPanel(new FlowLayout(FlowLayout.LEADING));
+        buttonsPane.add(selectPathButton);
+
+        builder.add(buttonsPane, cc.xywh(1, 13, 5, 1));
+        pathBrowser = new ObjAttributePathBrowser(selectPathButton, saveButton);
+        pathBrowser.setPreferredColumnSize(BROWSER_CELL_DIM);
+        pathBrowser.setDefaultRenderer();
+        builder.add(new JScrollPane(
+                pathBrowser,
+                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+                JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), cc.xywh(1, 15, 5, 3));
+
+        add(builder.getPanel(), BorderLayout.CENTER);
+        add(PanelFactory.createButtonPanel(new JButton[] {
+                saveButton, cancelButton
+        }), BorderLayout.SOUTH);
+    }
+    
+
+    
+    
+    public JComboBox getTargCombo() {
+        return targCombo;
+    }
+
+    public MultiColumnBrowser getPathBrowser() {
+        return pathBrowser;
+    }
+
+    public JButton getCancelButton() {
+        return cancelButton;
+    }
+
+    public JButton getSaveButton() {
+        return saveButton;
+    }
+
+    public JButton getSelectPathButton() {
+        return selectPathButton;
+    }
+
+    public JTextField getAttributeName() {
+        return attributeName;
+    }
+
+    public JLabel getCurrentPathLabel() {
+        return currentPathLabel;
+    }
+
+    public JLabel getSourceEntityLabel() {
+        return sourceEntityLabel;
+    }
+}

Copied: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributePathBrowser.java (from r793489, cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipPathBrowser.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributePathBrowser.java?p2=cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributePathBrowser.java&p1=cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipPathBrowser.java&r1=793489&r2=793490&rev=793490&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipPathBrowser.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjAttributePathBrowser.java Mon Jul 13 08:41:50 2009
@@ -20,57 +20,43 @@
 
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
 
+import javax.swing.JButton;
 import javax.swing.SwingUtilities;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
 import javax.swing.tree.TreePath;
 
-import org.apache.cayenne.modeler.util.MultiColumnBrowser;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbRelationship;
 
-/**
- * Multi-column browser for obj relationships
- */
-public class ObjRelationshipPathBrowser extends MultiColumnBrowser {
-    /**
-     * Listener, which performs adding of new column
-     */
-    private MouseListener panelOpener;
-    
-    /**
-     * Listener, which performs removing of columns to the right of selected row
-     */
-    private ListSelectionListener panelRemover;
-    
-    public ObjRelationshipPathBrowser() {
-        this(DEFAULT_MIN_COLUMNS_COUNT);
-    }
+public class ObjAttributePathBrowser extends ObjRelationshipPathBrowser {
 
-    public ObjRelationshipPathBrowser(int minColumns) {
-        super(minColumns);
+    JButton selectPathButton;
+    JButton doneButton;
+
+    public ObjAttributePathBrowser(JButton selectPathButton, JButton doneButton) {
+        super();
+        this.selectPathButton = selectPathButton;
+        this.doneButton = doneButton;
     }
-    
+
     @Override
     protected void installColumn(BrowserPanel panel) {
         if (panelOpener == null) {
-            panelOpener = new PanelOpener();
+            panelOpener = new PanelAttributeOpener();
         }
-        
+
         if (panelRemover == null) {
             panelRemover = new PanelRemover();
         }
-        
+
         panel.addMouseListener(panelOpener);
         panel.addListSelectionListener(panelRemover);
-        
         panel.setCellRenderer(renderer);
     }
-    
+
     /**
-     * Selects one path component.
-     * Need to override this method, because list selection does not cause loading
-     * in this browser.
+     * Selects one path component. Need to override this method, because list selection
+     * does not cause loading in this browser.
      */
     @Override
     protected void selectRow(Object row, int index, TreePath path) {
@@ -82,17 +68,12 @@
             updateFromModel(row, index - 1);
         }
     }
-    
-    @Override
-    protected void uninstallColumn(BrowserPanel panel) {
-        panel.removeMouseListener(panelOpener);
-        panel.removeListSelectionListener(panelRemover);
-    }
-    
+
     /**
      * Listener, which performs adding of new column at double-click
      */
-    protected class PanelOpener extends MouseAdapter {
+    protected class PanelAttributeOpener extends MouseAdapter {
+
         /**
          * Invoked when the mouse has been clicked on a component.
          */
@@ -101,35 +82,21 @@
                 process(e);
             }
         }
-               
+
         private void process(MouseEvent e) {
             BrowserPanel panel = (BrowserPanel) e.getSource();
             Object selectedNode = panel.getSelectedValue();
 
             // ignore unselected
-            if (selectedNode != null) {
+            if (selectedNode != null && selectedNode instanceof DbRelationship) {
                 updateFromModel(selectedNode, columns.indexOf(panel));
+                selectPathButton.setEnabled(false);
+                doneButton.setEnabled(false);
             }
-        }
-    }
-    
-    /**
-     * Listener, which performs removing columns to the right of selected row
-     */
-    protected class PanelRemover implements ListSelectionListener {
-
-        public void valueChanged(ListSelectionEvent e) {
-         // ignore "adjusting"
-            if (!e.getValueIsAdjusting()) {
-                BrowserPanel panel = (BrowserPanel) e.getSource();
-                
-                Object selectedNode = panel.getSelectedValue();
-                
-                if (selectedNode != null) {
-                    updateFromModel(selectedNode, columns.indexOf(panel), false);
-                }
+            else if (selectedNode instanceof DbAttribute) {
+                doneButton.setEnabled(true);
+                selectPathButton.setEnabled(true);
             }
         }
-        
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoController.java?rev=793490&r1=793489&r2=793490&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoController.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoController.java Mon Jul 13 08:41:50 2009
@@ -49,12 +49,13 @@
 /**
  * @since 1.1
  */
-public class ObjRelationshipInfoController extends BasicController implements TreeSelectionListener {
+public class ObjRelationshipInfoController extends BasicController implements
+        TreeSelectionListener {
 
     public static final String SAVE_CONTROL = "cayenne.modeler.mapObjRelationship.save.button";
     public static final String CANCEL_CONTROL = "cayenne.modeler.mapObjRelationship.cancel.button";
     public static final String NEW_REL_CONTROL = "cayenne.modeler.mapObjRelationship.newrel.button";
-    
+
     public static final String SELECT_PATH_CONTROL = "cayenne.modeler.mapObjRelationship.select.path.button";
     public static final String REVERT_PATH_CONTROL = "cayenne.modeler.mapObjRelationship.revert.path.button";
     public static final String CLEAR_PATH_CONTROL = "cayenne.modeler.mapObjRelationship.clear.path.button";
@@ -68,30 +69,30 @@
         ObjRelationshipInfoModel model = new ObjRelationshipInfoModel(relationship);
         setModel(model);
     }
-    
+
     /**
      * Creates and runs the classpath dialog.
      */
     @Override
     public void startup() {
         /**
-         * Some workaround: need to save target first, because even if it is null,
-         * first item will be displayed in combobox. Also we do not want to have empty item
-         * in the combobox.
+         * Some workaround: need to save target first, because even if it is null, first
+         * item will be displayed in combobox. Also we do not want to have empty item in
+         * the combobox.
          */
         ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();
         ObjEntity target = model.getObjectTarget();
-        
+
         ObjRelationshipInfoDialog view = new ObjRelationshipInfoDialog();
         setView(view);
-        
+
         model.setObjectTarget(target);
-        
+
         /**
          * Register auto-selection of the target
          */
         view.getPathBrowser().addTreeSelectionListener(this);
-        
+
         view.initFromModel();
         super.startup();
     }
@@ -117,24 +118,25 @@
             clearPath();
         }
     }
-    
+
     /**
-     * Saves selected path 
+     * Saves selected path
      */
     protected void selectPath() {
         ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();
         model.selectPath();
     }
-    
+
     /**
      * Reverts current path to saved path
      */
     protected void revertPath() {
         ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();
-        ((ObjRelationshipInfoDialog) getView()).setSelectionPath(model.getSavedDbRelationships());
+        ((ObjRelationshipInfoDialog) getView()).setSelectionPath(model
+                .getSavedDbRelationships());
         model.setDbRelationships(model.getSavedDbRelationships());
     }
-    
+
     /**
      * Clears paths and selections in browser
      */
@@ -146,13 +148,13 @@
 
     protected void saveMapping() {
         ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();
-        
+
         if (!model.getDbRelationships().equals(model.getSavedDbRelationships())) {
-            if (JOptionPane.showConfirmDialog((Component) getView(), 
+            if (JOptionPane.showConfirmDialog(
+                    (Component) getView(),
                     "You have changed Db Relationship path. Do you want it to be saved?",
                     "Save ObjRelationship",
-                    JOptionPane.YES_NO_OPTION)
-                    == JOptionPane.YES_OPTION) {
+                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                 selectPath();
             }
         }
@@ -173,23 +175,28 @@
      */
     protected void createRelationship() {
         ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();
-        
+
         DbRelationship dbRel = model.getLastRelationship();
-        DbEntity source = dbRel != null ? (DbEntity) dbRel.getTargetEntity() : null; 
-        
-        DbRelationshipTargetController targetController = 
-            new DbRelationshipTargetController(model.getStartEntity(), source);
+        DbEntity source = dbRel != null ? (DbEntity) dbRel.getTargetEntity() : null;
+
+        DbRelationshipTargetController targetController = new DbRelationshipTargetController(
+                model.getStartEntity(),
+                source);
         targetController.startup();
-        
+
         if (!targetController.isSavePressed()) {
             return;
         }
-        
-        DbRelationshipTargetModel targetModel = (DbRelationshipTargetModel) targetController.getModel();
-        
-        DbRelationship dbRelationship = (DbRelationship) NamedObjectFactory.createRelationship(
-                targetModel.getSource(), targetModel.getTarget(), targetModel.isToMany());
-        
+
+        DbRelationshipTargetModel targetModel = (DbRelationshipTargetModel) targetController
+                .getModel();
+
+        DbRelationship dbRelationship = (DbRelationship) NamedObjectFactory
+                .createRelationship(
+                        targetModel.getSource(),
+                        targetModel.getTarget(),
+                        targetModel.isToMany());
+
         // note: NamedObjectFactory doesn't set source or target, just the name
         dbRelationship.setSourceEntity(targetModel.getSource());
         dbRelationship.setTargetEntity(targetModel.getTarget());
@@ -206,55 +213,62 @@
             targetModel.getSource().removeRelationship(dbRelationship.getName());
         }
         else {
-            MultiColumnBrowser pathBrowser = ((ObjRelationshipInfoDialog) getView()).getPathBrowser();
-            Object[] oldPath = targetModel.isSource1Selected() ?
-                    new Object[] { model.getStartEntity() } : pathBrowser.getSelectionPath().getPath();
-            
+            MultiColumnBrowser pathBrowser = ((ObjRelationshipInfoDialog) getView())
+                    .getPathBrowser();
+            Object[] oldPath = targetModel.isSource1Selected() ? new Object[] {
+                model.getStartEntity()
+            } : pathBrowser.getSelectionPath().getPath();
+
             /**
              * Update the view
              */
             EntityTreeModel treeModel = (EntityTreeModel) pathBrowser.getModel();
             treeModel.invalidate();
-            
-            pathBrowser.setSelectionPath(new TreePath(new Object[] { model.getStartEntity() }));
+
+            pathBrowser.setSelectionPath(new TreePath(new Object[] {
+                model.getStartEntity()
+            }));
             pathBrowser.repaint();
-            
+
             Object[] path = new Object[oldPath.length + 1];
             System.arraycopy(oldPath, 0, path, 0, path.length - 1);
-            
+
             path[path.length - 1] = dbRelationship;
             pathBrowser.setSelectionPath(new TreePath(path));
         }
 
         dialog.dispose();
     }
-    
+
     public void valueChanged(TreeSelectionEvent e) {
         TreePath selectedPath = e.getPath();
-        
+
         // first item in the path is Entity, so we must have
         // at least two elements to constitute a valid ordering path
         if (selectedPath == null || selectedPath.getPathCount() < 2) {
             return;
         }
-        
+
         Relationship rel = (Relationship) selectedPath.getLastPathComponent();
         DbEntity target = (DbEntity) rel.getTargetEntity();
-        
-        ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel(); 
-        
+
+        ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getModel();
+
         /**
          * Initialize root with one of mapped ObjEntities.
          */
         Collection<ObjEntity> objEntities = target.getDataMap().getMappedEntities(target);
-        
-        List<DbRelationship> relPath = new Vector<DbRelationship>(selectedPath.getPathCount() - 1);
+
+        List<DbRelationship> relPath = new Vector<DbRelationship>(selectedPath
+                .getPathCount() - 1);
         for (int i = 1; i < selectedPath.getPathCount(); i++) {
             relPath.add((DbRelationship) selectedPath.getPathComponent(i));
         }
         model.setDbRelationships(relPath);
-        model.setObjectTarget(objEntities.size() == 0 ? null : objEntities.iterator().next());
-        
+        model.setObjectTarget(objEntities.size() == 0 ? null : objEntities
+                .iterator()
+                .next());
+
         ((ObjRelationshipInfoDialog) getView()).updateCollectionChoosers();
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoDialog.java?rev=793490&r1=793489&r2=793490&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoDialog.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoDialog.java Mon Jul 13 08:41:50 2009
@@ -60,9 +60,9 @@
 public class ObjRelationshipInfoDialog extends SPanel {
 
     static final Dimension BROWSER_CELL_DIM = new Dimension(130, 200);
-    
+
     /**
-     * Browser to select path for flattened relationship 
+     * Browser to select path for flattened relationship
      */
     protected MultiColumnBrowser pathBrowser;
 
@@ -88,14 +88,14 @@
         SButton newRelButton = new SButton(new SAction(
                 ObjRelationshipInfoController.NEW_REL_CONTROL));
         newRelButton.setEnabled(true);
-        
+
         SButton selectPathButton = new SButton(new SAction(
                 ObjRelationshipInfoController.SELECT_PATH_CONTROL));
         selectPathButton.setEnabled(true);
-        
+
         STextField relationshipName = new STextField(25);
         relationshipName.setSelector(ObjRelationshipInfoModel.RELATIONSHIP_NAME_SELECTOR);
-        
+
         SLabel currentPathLabel = new SLabel();
         currentPathLabel.setSelector(ObjRelationshipInfoModel.CURRENT_PATH_SELECTOR);
 
@@ -118,11 +118,11 @@
         mapKeysCombo = new SComboBox();
         mapKeysCombo.setSelector(ObjRelationshipInfoModel.MAP_KEYS_SELECTOR);
         mapKeysCombo.setSelectionSelector(ObjRelationshipInfoModel.MAP_KEY_SELECTOR);
-        
+
         pathBrowser = new ObjRelationshipPathBrowser();
         pathBrowser.setPreferredColumnSize(BROWSER_CELL_DIM);
         pathBrowser.setDefaultRenderer();
-        
+
         // enable/disable map keys for collection type selection
         collectionTypeCombo.addActionListener(new ActionListener() {
 
@@ -146,10 +146,10 @@
         builder.addSeparator("ObjRelationship Information", cc.xywh(1, 1, 5, 1));
         builder.addLabel("Relationship:", cc.xy(1, 3));
         builder.add(relationshipName, cc.xywh(3, 3, 1, 1));
-        
+
         builder.addLabel("Current Db Path:", cc.xy(1, 5));
         builder.add(currentPathLabel, cc.xywh(3, 5, 5, 1));
-        
+
         builder.addLabel("Source:", cc.xy(1, 7));
         builder.add(sourceEntityLabel, cc.xywh(3, 7, 1, 1));
         builder.addLabel("Target:", cc.xy(1, 9));
@@ -160,21 +160,21 @@
         builder.add(mapKeysCombo, cc.xywh(3, 13, 1, 1));
 
         builder.addSeparator("Mapping to DbRelationships", cc.xywh(1, 15, 5, 1));
-        
+
         JPanel buttonsPane = new JPanel(new FlowLayout(FlowLayout.LEADING));
         buttonsPane.add(selectPathButton);
         buttonsPane.add(newRelButton);
-        
+
         builder.add(buttonsPane, cc.xywh(1, 17, 5, 1));
         builder.add(new JScrollPane(
                 pathBrowser,
                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), cc.xywh(1, 19, 5, 3));
-                
+
         add(builder.getPanel(), BorderLayout.CENTER);
         add(PanelFactory.createButtonPanel(new JButton[] {
                 saveButton, cancelButton
-            }), BorderLayout.SOUTH);
+        }), BorderLayout.SOUTH);
     }
 
     /**
@@ -191,43 +191,44 @@
         }
 
         ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getController()
-            .getModel();
-        
+                .getModel();
+
         if (pathBrowser.getModel() == null) {
             EntityTreeModel treeModel = new EntityTreeModel(model.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 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);
+                }
+
+            });
+
             pathBrowser.setModel(treeModel);
-        
+
             setSelectionPath(model.getSavedDbRelationships());
         }
     }
-    
+
     /**
      * Selects path in browser
      */
     void setSelectionPath(List<DbRelationship> rels) {
-        ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getController().getModel();
-        
+        ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getController()
+                .getModel();
+
         Object[] path = new Object[rels.size() + 1];
         path[0] = model.getStartEntity();
 
@@ -235,28 +236,28 @@
 
         pathBrowser.setSelectionPath(new TreePath(path));
     }
-    
+
     /**
-     * Updates 'collection type' and 'map keys' comboboxes 
+     * Updates 'collection type' and 'map keys' comboboxes
      */
     boolean updateCollectionChoosers() {
         if (getController() == null || getController().getModel() == null) {
             return false;
         }
-        
+
         ObjRelationshipInfoModel model = (ObjRelationshipInfoModel) getController()
                 .getModel();
-        
+
         boolean collectionTypeEnabled = model.isToMany();
         collectionTypeCombo.setEnabled(collectionTypeEnabled);
         collectionTypeLabel.setEnabled(collectionTypeEnabled);
-        
+
         boolean mapKeysEnabled = collectionTypeEnabled
                 && ObjRelationshipInfoModel.COLLECTION_TYPE_MAP
                         .equals(collectionTypeCombo.getSelectedItem());
         mapKeysCombo.setEnabled(mapKeysEnabled);
         mapKeysLabel.setEnabled(mapKeysEnabled);
-        
+
         return true;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java?rev=793490&r1=793489&r2=793490&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/objentity/ObjRelationshipInfoModel.java Mon Jul 13 08:41:50 2009
@@ -49,7 +49,7 @@
     static final String COLLECTION_TYPE_MAP = "java.util.Map";
     static final String COLLECTION_TYPE_SET = "java.util.Set";
     static final String COLLECTION_TYPE_COLLECTION = "java.util.Collection";
-    
+
     static final String DEFAULT_MAP_KEY = "ID (default)";
 
     public static final Selector DB_RELATIONSHIPS_SELECTOR = Selector
@@ -60,7 +60,7 @@
             .fromString("objectTarget");
     public static final Selector OBJECT_TARGETS_SELECTOR = Selector
             .fromString("objectTargets");
-    
+
     public static final Selector RELATIONSHIP_NAME_SELECTOR = Selector
             .fromString("relationshipName");
     public static final Selector TARGET_COLLECTIONS_SELECTOR = Selector
@@ -69,21 +69,22 @@
             .fromString("targetCollection");
     public static final Selector MAP_KEYS_SELECTOR = Selector.fromString("mapKeys");
     public static final Selector MAP_KEY_SELECTOR = Selector.fromString("mapKey");
-    
-    public static final Selector CURRENT_PATH_SELECTOR = Selector.fromString("currentPath");
+
+    public static final Selector CURRENT_PATH_SELECTOR = Selector
+            .fromString("currentPath");
 
     protected ObjRelationship relationship;
-    
+
     /**
      * List of DB Relationships current ObjRelationship is mapped to
      */
     protected List<DbRelationship> dbRelationships;
-    
+
     /**
      * List of current saved DB Relationships
      */
     protected List<DbRelationship> savedDbRelationships;
-    
+
     protected ObjEntity objectTarget;
     protected List<ObjEntity> objectTargets;
     protected List<String> targetCollections;
@@ -91,7 +92,7 @@
     protected String relationshipName;
     protected String targetCollection;
     protected String mapKey;
-    
+
     protected String currentPath;
 
     @SuppressWarnings("unchecked")
@@ -99,13 +100,13 @@
 
         this.relationship = relationship;
         this.relationshipName = relationship.getName();
-        
+
         this.mapKey = relationship.getMapKey();
         this.targetCollection = relationship.getCollectionType();
         if (targetCollection == null) {
             targetCollection = ObjRelationship.DEFAULT_COLLECTION_TYPE;
         }
-        
+
         this.objectTarget = (ObjEntity) relationship.getTargetEntity();
         if (objectTarget != null) {
             updateTargetCombo(objectTarget.getDbEntity());
@@ -121,7 +122,7 @@
         targetCollections.add(ObjRelationship.DEFAULT_COLLECTION_TYPE);
         targetCollections.add(COLLECTION_TYPE_MAP);
         targetCollections.add(COLLECTION_TYPE_SET);
-        
+
         this.mapKeys = new ArrayList<String>();
         initMapKeys();
 
@@ -135,7 +136,7 @@
         // add dummy last relationship if we are not connected
         connectEnds();
     }
-    
+
     /**
      * Places in objectTargets list all ObjEntities for specified DbEntity
      */
@@ -144,69 +145,71 @@
         // copy those that have DbEntities mapped to dbTarget, and then sort
 
         this.objectTargets = new ArrayList<ObjEntity>();
-        
+
         if (dbTarget != null) {
-            objectTargets.addAll(dbTarget.getDataMap().getMappedEntities(dbTarget));            
+            objectTargets.addAll(dbTarget.getDataMap().getMappedEntities(dbTarget));
             Collections.sort(objectTargets, Comparators.getNamedObjectComparator());
         }
-        
+
         fireModelChange(ModelChangeTypes.VALUE_CHANGED, OBJECT_TARGETS_SELECTOR);
     }
 
     public ObjRelationship getRelationship() {
         return relationship;
     }
-    
+
     /**
-     * @return list of DB Relationships current ObjRelationship is mapped to 
+     * @return list of DB Relationships current ObjRelationship is mapped to
      */
     public List<DbRelationship> getDbRelationships() {
         return dbRelationships;
     }
-    
+
     /**
-     * @return list of saved DB Relationships 
+     * @return list of saved DB Relationships
      */
     public List<DbRelationship> getSavedDbRelationships() {
         return savedDbRelationships;
     }
-    
+
     /**
      * @return last relationship in the path, or <code>null</code> if path is empty
      */
     public DbRelationship getLastRelationship() {
-        return dbRelationships.size() == 0 ? null : dbRelationships.get(dbRelationships.size() - 1);
+        return dbRelationships.size() == 0 ? null : dbRelationships.get(dbRelationships
+                .size() - 1);
     }
-    
+
     /**
      * Sets list of DB Relationships current ObjRelationship is mapped to
      */
     public void setDbRelationships(List<DbRelationship> rels) {
         this.dbRelationships = rels;
-        
-        updateTargetCombo(rels.size() > 0 ?
-                (DbEntity) rels.get(rels.size() - 1).getTargetEntity() : null);
+
+        updateTargetCombo(rels.size() > 0 ? (DbEntity) rels
+                .get(rels.size() - 1)
+                .getTargetEntity() : null);
     }
-    
+
     /**
      * Sets list of saved DB Relationships
      */
     public void setSavedDbRelationships(List<DbRelationship> rels) {
         this.savedDbRelationships = rels;
-        
+
         String currPath = "";
         for (DbRelationship rel : rels) {
             currPath += "->" + rel.getName();
         }
-        
+
         if (rels.size() > 0) {
             currPath = currPath.substring(2);
         }
-        
+
         currentPath = currPath;
         fireModelChange(ModelChangeTypes.VALUE_CHANGED, CURRENT_PATH_SELECTOR);
     }
-    
+
     /**
      * Confirms selection of Db Rels
      */
@@ -240,7 +243,7 @@
         this.mapKeys.clear();
 
         mapKeys.add(DEFAULT_MAP_KEY);
-        
+
         /**
          * Object target can be null when selected target DbEntity has no ObjEntities
          */
@@ -266,7 +269,7 @@
     public List<ObjEntity> getObjectTargets() {
         return objectTargets;
     }
-   
+
     public String getRelationshipName() {
         return relationshipName;
     }
@@ -307,32 +310,36 @@
      */
     public synchronized boolean savePath() {
         boolean hasChanges = false;
-        
+
         boolean oldToMany = relationship.isToMany();
 
         if (!Util.nullSafeEquals(relationship.getName(), relationshipName)) {
             hasChanges = true;
             relationship.setName(relationshipName);
         }
-        
+
         if (savedDbRelationships.size() > 0) {
-            DbEntity lastEntity = (DbEntity)
-                savedDbRelationships.get(savedDbRelationships.size() - 1).getTargetEntity();
+            DbEntity lastEntity = (DbEntity) savedDbRelationships.get(
+                    savedDbRelationships.size() - 1).getTargetEntity();
 
             if (objectTarget == null || objectTarget.getDbEntity() != lastEntity) {
                 /**
-                 * Entities in combobox and path browser do not match.
-                 * In this case, we rely on the browser and automatically select one
-                 * of lastEntity's ObjEntities
+                 * Entities in combobox and path browser do not match. In this case, we
+                 * rely on the browser and automatically select one of lastEntity's
+                 * ObjEntities
                  */
-                Collection<ObjEntity> objEntities = 
-                    lastEntity.getDataMap().getMappedEntities(lastEntity);
-                objectTarget = objEntities.size() == 0 ? null : objEntities.iterator().next();
+                Collection<ObjEntity> objEntities = lastEntity
+                        .getDataMap()
+                        .getMappedEntities(lastEntity);
+                objectTarget = objEntities.size() == 0 ? null : objEntities
+                        .iterator()
+                        .next();
             }
         }
-        
-        if (objectTarget == null || !Util.nullSafeEquals(objectTarget.getName(), relationship
-                .getTargetEntityName())) {
+
+        if (objectTarget == null
+                || !Util.nullSafeEquals(objectTarget.getName(), relationship
+                        .getTargetEntityName())) {
             hasChanges = true;
 
             // note on events notification - this needs to be propagated
@@ -350,7 +357,7 @@
         else {
             for (int i = 0; i < oldPath.size(); i++) {
                 DbRelationship next = savedDbRelationships.get(i);
-                
+
                 if (oldPath.get(i) != next) {
                     hasChanges = true;
                     updatePath();
@@ -374,7 +381,7 @@
             hasChanges = true;
             relationship.setMapKey(mapKey);
         }
-        
+
         /**
          * As of CAY-436 here we check if to-many property has changed during the editing,
          * and if so, delete rule must be reset to default value
@@ -427,7 +434,7 @@
 
                 Relationship anyConnector = source != null ? source
                         .getAnyRelationship(target) : null;
-                
+
                 if (anyConnector != null) {
                     dbRelationships.add((DbRelationship) anyConnector);
                 }
@@ -436,9 +443,8 @@
     }
 
     /**
-     * Checks if the entity can be edited with this inspector.
-     * NOTE: As of CAY-1077, relationship inspector can be opened even if no target entity 
-     * was set.
+     * Checks if the entity can be edited with this inspector. NOTE: As of CAY-1077,
+     * relationship inspector can be opened even if no target entity was set.
      */
     private void validateCanMap() {
         if (relationship.getSourceEntity() == null) {
@@ -463,7 +469,7 @@
         if (objectTarget == null) {
             return null;
         }
-        
+
         return objectTarget.getDbEntity();
     }
 



Mime
View raw message