cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1432433 - in /cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: action/PasteAction.java undo/PasteUndoableEdit.java
Date Sat, 12 Jan 2013 14:27:50 GMT
Author: aadamchik
Date: Sat Jan 12 14:27:50 2013
New Revision: 1432433

URL: http://svn.apache.org/viewvc?rev=1432433&view=rev
Log:
CAY-1701 Modeler cannot undo pasting of obj (db) entity

patch by Ilya Drabenia

(cherry picked from commit 00d6e8f5052a9417371b824f31b560689a2be35b)

Modified:
    cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
    cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java

Modified: cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java?rev=1432433&r1=1432432&r2=1432433&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
(original)
+++ cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
Sat Jan 12 14:27:50 2013
@@ -30,6 +30,7 @@ import java.util.Map;
 
 import javax.swing.JOptionPane;
 import javax.swing.KeyStroke;
+import javax.swing.undo.UndoableEdit;
 
 import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
@@ -40,6 +41,8 @@ import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.EmbeddableAttribute;
+import org.apache.cayenne.map.EntityResolver;
+import org.apache.cayenne.map.MappingNamespace;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
@@ -103,15 +106,15 @@ public class PasteAction extends Cayenne
             Object currentObject = getProjectController().getCurrentObject();
 
             if (content != null && currentObject != null) {
-
-                PasteCompoundUndoableEdit undoableEdit = new PasteCompoundUndoableEdit();
-
                 DataChannelDescriptor domain = (DataChannelDescriptor) getProjectController()
                         .getProject()
                         .getRootNode();
                 DataMap map = getProjectController().getCurrentDataMap();
 
+                UndoableEdit undoableEdit;
                 if (content instanceof List) {
+                    undoableEdit = new PasteCompoundUndoableEdit();
+
                     for (Object o : (List) content) {
                         paste(currentObject, o);
                         undoableEdit.addEdit(new PasteUndoableEdit(
@@ -123,11 +126,7 @@ public class PasteAction extends Cayenne
                 }
                 else {
                     paste(currentObject, content);
-                    undoableEdit.addEdit(new PasteUndoableEdit(
-                            domain,
-                            map,
-                            currentObject,
-                            content));
+                    undoableEdit = new PasteUndoableEdit(domain, map, currentObject, content);
                 }
 
                 application.getUndoManager().addEdit(undoableEdit);
@@ -260,6 +259,9 @@ public class PasteAction extends Cayenne
             // paste DbEntity to DataMap
             final DataMap dataMap = ((DataMap) where);
 
+            // clear data map parent cache
+            clearDataMapCache(dataMap);
+
             if (content instanceof DbEntity) {
                 DbEntity dbEntity = (DbEntity) content;
                 dbEntity.setName(getFreeName(new DbEntityNameChecker(domain), dbEntity
@@ -450,6 +452,13 @@ public class PasteAction extends Cayenne
         }
     }
 
+    private void clearDataMapCache(DataMap dataMap) {
+        MappingNamespace ns = dataMap.getNamespace();
+        if (ns instanceof EntityResolver) {
+            ((EntityResolver) ns).clearCache();
+        }
+    }
+
     /**
      * Finds avaliable name for an object
      */

Modified: cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java?rev=1432433&r1=1432432&r2=1432433&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java
(original)
+++ cayenne/main/branches/STABLE-3.1/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java
Sat Jan 12 14:27:50 2013
@@ -102,6 +102,9 @@ public class PasteUndoableEdit extends C
             else if (content instanceof ObjEntity) {
                 rAction.removeObjEntity(map, (ObjEntity) content);
             }
+            else if (content instanceof Embeddable) {
+                rAction.removeEmbeddable(map, (Embeddable) content);
+            }
             else if (content instanceof Query) {
                 rAction.removeQuery(map, (Query) content);
             }



Mime
View raw message