cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r821956 [1/4] - in /cayenne/main/trunk/framework/cayenne-modeler/src: main/java/org/apache/cayenne/modeler/ main/java/org/apache/cayenne/modeler/action/ main/java/org/apache/cayenne/modeler/dialog/ main/java/org/apache/cayenne/modeler/dialo...
Date Mon, 05 Oct 2009 18:40:28 GMT
Author: andrey
Date: Mon Oct  5 18:40:25 2009
New Revision: 821956

URL: http://svn.apache.org/viewvc?rev=821956&view=rev
Log:
CAY-1191 Undo/Redo support in modeler (patch by Anton Sakalouski)

Added:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RedoAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/UndoAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/AddPrefetchUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneCompoundEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneTableModelUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoManager.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CayenneUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateAttributeUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDataMapUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDbEntityUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateDomainUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbAttributeUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEmbeddableUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateEntityListenerUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateNodeUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateObjEntityUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateProcedureUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateQueryUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateRelationshipUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/InferRelationshipsUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JComboBoxUndoListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JComboBoxUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/JTextFieldUndoListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteCompoundUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RelationshipUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveAttributeUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCompoundUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveRelationshipUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveUndoableEdit.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/JTextFieldUndoable.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-redo.gif   (with props)
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-undo.gif   (with props)
Modified:
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDbEntityAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDomainAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateNodeAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityListenerAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateQueryAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateRelationshipAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DocumentationAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/InferRelationshipsAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.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/action/RemoveAttributeAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerForDataMapAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveProcedureParameterAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveRelationshipAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RevertAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/AboutDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/FindDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ResolveDbRelationshipDialog.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/autorelationship/InferRelationshipsController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/query/QueryTypeController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataDomainView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EmbeddableAttributeTableModel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ProcedureQueryView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/RawQueryPropertiesPanel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateMainTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectPropertiesPanel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryOrderingTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SelectQueryPrefetchTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/AdapterView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/CustomDataSourceView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/DBCPDataSourceView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/JDBCDataSourceView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/JNDIDataSourceView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/MainDataNodeView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/datanode/PasswordEncoderView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneTableModel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneWidgetFactory.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/TextAdapter.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/swing/components/textpane/JCayenneTextPane.java
    cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/CreateNodeActionTest.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ActionManager.java Mon Oct  5 18:40:25 2009
@@ -75,6 +75,7 @@
 import org.apache.cayenne.modeler.action.OpenProjectAction;
 import org.apache.cayenne.modeler.action.PasteAction;
 import org.apache.cayenne.modeler.action.ProjectAction;
+import org.apache.cayenne.modeler.action.RedoAction;
 import org.apache.cayenne.modeler.action.RemoveAction;
 import org.apache.cayenne.modeler.action.RemoveAttributeAction;
 import org.apache.cayenne.modeler.action.RemoveCallbackMethodAction;
@@ -88,6 +89,7 @@
 import org.apache.cayenne.modeler.action.SaveAction;
 import org.apache.cayenne.modeler.action.SaveAsAction;
 import org.apache.cayenne.modeler.action.ShowLogConsoleAction;
+import org.apache.cayenne.modeler.action.UndoAction;
 import org.apache.cayenne.modeler.action.ValidateAction;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.ProjectPath;
@@ -99,7 +101,7 @@
 public class ActionManager {
 
     static final Collection<String> SPECIAL_ACTIONS = Arrays.asList(SaveAction
-            .getActionName());
+            .getActionName(), UndoAction.getActionName(), RedoAction.getActionName());
 
     // search action added to project actions
     static final Collection<String> PROJECT_ACTIONS = Arrays.asList(RevertAction
@@ -116,7 +118,6 @@
                 CreateNodeAction.getActionName(),
                 ImportDBAction.getActionName(),
                 ImportEOModelAction.getActionName(),
-                
                 PasteAction.getActionName()));
     }
     
@@ -247,6 +248,14 @@
         registerAction(new CopyProcedureParameterAction(application));
         registerAction(new PasteAction(application));
         
+        UndoAction undoAction = new UndoAction(application); 
+        undoAction.setEnabled(false);
+        registerAction(undoAction);
+        
+        RedoAction redoAction = new RedoAction(application);
+        redoAction.setEnabled(false);
+        registerAction(redoAction);
+        
         registerAction(new CreateEmbeddableAction(application));
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/Application.java Mon Oct  5 18:40:25 2009
@@ -29,6 +29,7 @@
 import javax.swing.JOptionPane;
 import javax.swing.JRootPane;
 import javax.swing.SwingUtilities;
+import javax.swing.undo.UndoManager;
 
 import org.apache.cayenne.modeler.dialog.LogConsole;
 import org.apache.cayenne.modeler.util.AdapterMapping;
@@ -84,6 +85,8 @@
     protected String preferencesDB;
     protected BindingFactory bindingFactory;
     protected AdapterMapping adapterMapping;
+    
+    protected UndoManager undoManager;
 
     // This is for OS X support
     private boolean isQuittingApplication = false;
@@ -146,6 +149,13 @@
     public ActionManager getActionManager() {
         return actionManager;
     }
+    
+    /**
+     * Returns undo-edits controller.
+     */
+    public UndoManager getUndoManager() {
+        return undoManager;
+    }
 
     /**
      * Returns controller for the main frame.
@@ -175,6 +185,7 @@
         // init actions before the frame, as it will attempt to build menus out of
         // actions.
         this.actionManager = new ActionManager(this);
+        this.undoManager = new org.apache.cayenne.modeler.undo.CayenneUndoManager(this);
 
         // ...create main frame
         this.frameController = new CayenneModelerController(this, initialProject);

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerFrame.java Mon Oct  5 18:40:25 2009
@@ -74,11 +74,13 @@
 import org.apache.cayenne.modeler.action.OpenProjectAction;
 import org.apache.cayenne.modeler.action.PasteAction;
 import org.apache.cayenne.modeler.action.ProjectAction;
+import org.apache.cayenne.modeler.action.RedoAction;
 import org.apache.cayenne.modeler.action.RemoveAction;
 import org.apache.cayenne.modeler.action.RevertAction;
 import org.apache.cayenne.modeler.action.SaveAction;
 import org.apache.cayenne.modeler.action.SaveAsAction;
 import org.apache.cayenne.modeler.action.ShowLogConsoleAction;
+import org.apache.cayenne.modeler.action.UndoAction;
 import org.apache.cayenne.modeler.action.ValidateAction;
 import org.apache.cayenne.modeler.dialog.LogConsole;
 import org.apache.cayenne.modeler.editor.EditorView;
@@ -197,6 +199,8 @@
         fileMenu.add(getAction(RevertAction.getActionName()).buildMenu());
         fileMenu.addSeparator();
         
+        editMenu.add(getAction(UndoAction.getActionName()).buildMenu());
+        editMenu.add(getAction(RedoAction.getActionName()).buildMenu());
         editMenu.add(getAction(CutAction.getActionName()).buildMenu());
         editMenu.add(getAction(CopyAction.getActionName()).buildMenu());
         editMenu.add(getAction(PasteAction.getActionName()).buildMenu());
@@ -367,6 +371,11 @@
         toolBar.add(getAction(PasteAction.getActionName()).buildButton());
 
         toolBar.addSeparator();
+        
+        toolBar.add(getAction(UndoAction.getActionName()).buildButton());
+        toolBar.add(getAction(RedoAction.getActionName()).buildButton());
+        
+        toolBar.addSeparator();
 
         toolBar.add(getAction(CreateDomainAction.getActionName()).buildButton());
         toolBar.add(getAction(CreateNodeAction.getActionName()).buildButton());

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java Mon Oct  5 18:40:25 2009
@@ -26,19 +26,22 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.editor.CallbackType;
 import org.apache.cayenne.modeler.event.CallbackMethodEvent;
+import org.apache.cayenne.modeler.undo.CreateCallbackMethodUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.util.NameConverter;
 
 /**
  * Base class for creating callback methods
- *
+ * 
  * @version 1.0 Oct 28, 2007
  */
 public abstract class AbstractCreateCallbackMethodAction extends CayenneAction {
 
+    
+
     /**
      * Constructor.
-     *
+     * 
      * @param actionName unique action name
      * @param application Application instance
      */
@@ -60,40 +63,59 @@
 
     /**
      * performs adding new callback method
+     * 
      * @param e event
      */
     public final void performAction(ActionEvent e) {
         CallbackType callbackType = getProjectController().getCurrentCallbackType();
 
-        //generate methodName
+        // generate methodName
         String methodNamePrefix = toMethodName(callbackType.getType());
         String methodName;
-        //now that we're generating the method names based on the callback type, check to see if the
-        //raw prefix, no numbers, is taken.
-        if (!getCallbackMap().getCallbackDescriptor(callbackType.getType()).getCallbackMethods().contains(methodNamePrefix)) {
+        // now that we're generating the method names based on the callback type, check to
+        // see if the
+        // raw prefix, no numbers, is taken.
+        if (!getCallbackMap()
+                .getCallbackDescriptor(callbackType.getType())
+                .getCallbackMethods()
+                .contains(methodNamePrefix)) {
             methodName = methodNamePrefix;
-        } else {
+        }
+        else {
             int counter = 1;
             do {
                 methodName = methodNamePrefix + counter;
                 counter++;
-            } while(getCallbackMap().getCallbackDescriptor(callbackType.getType()).getCallbackMethods().contains(methodName));
+            } while (getCallbackMap()
+                    .getCallbackDescriptor(callbackType.getType())
+                    .getCallbackMethods()
+                    .contains(methodName));
         }
 
-        getCallbackMap().getCallbackDescriptor(callbackType.getType()).addCallbackMethod(methodName);
+        createCallbackMethod(getCallbackMap(), callbackType, methodName);
+        application.getUndoManager().addEdit(
+                new CreateCallbackMethodUndoableEdit(
+                        getCallbackMap(),
+                        callbackType,
+                        methodName));
+    }
+
+    public void createCallbackMethod(
+            CallbackMap map,
+            CallbackType callbackType,
+            String methodName) {
+        map.getCallbackDescriptor(callbackType.getType()).addCallbackMethod(methodName);
 
         CallbackMethodEvent ce = new CallbackMethodEvent(
-                e.getSource(),
+                this,
                 null,
                 methodName,
-                MapEvent.ADD
-        );
+                MapEvent.ADD);
 
         getProjectController().fireCallbackMethodEvent(ce);
     }
 
     private String toMethodName(LifecycleEvent event) {
-        return "on" + NameConverter.underscoredToJava(event.name(),true);
+        return "on" + NameConverter.underscoredToJava(event.name(), true);
     }
 }
-

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java Mon Oct  5 18:40:25 2009
@@ -35,6 +35,8 @@
  */
 public abstract class AbstractRemoveCallbackMethodAction extends RemoveAction {
 
+    
+
     /**
      * Constructor.
      *
@@ -87,16 +89,23 @@
         String[] callbackMethods = mediator.getCurrentCallbackMethods();
 
         for (String callbackMethod : callbackMethods) {
-            getCallbackMap().getCallbackDescriptor(callbackType.getType()).removeCallbackMethod(callbackMethod);
-            CallbackMethodEvent e = new CallbackMethodEvent(
-                    actionEvent.getSource(),
-                    null,
-                    callbackMethod,
-                    MapEvent.REMOVE);
-            mediator.fireCallbackMethodEvent(e);
+            removeCallbackMethod(getCallbackMap(), callbackType, callbackMethod);
         }
     }
     
+    public void removeCallbackMethod(CallbackMap map, CallbackType callbackType, String method) {
+        ProjectController mediator = getProjectController();
+        map.getCallbackDescriptor(callbackType.getType()).removeCallbackMethod(method);
+        
+        CallbackMethodEvent e = new CallbackMethodEvent(
+                this,
+                null,
+                method,
+                MapEvent.REMOVE);
+        
+        mediator.fireCallbackMethodEvent(e);
+    }
+    
     /**
      * Returns action name, depending on count of selected rows
      */

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateAttributeAction.java Mon Oct  5 18:40:25 2009
@@ -21,6 +21,8 @@
 
 import java.awt.event.ActionEvent;
 
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.Embeddable;
@@ -35,6 +37,8 @@
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
 import org.apache.cayenne.modeler.event.EmbeddableAttributeDisplayEvent;
+import org.apache.cayenne.modeler.undo.CreateAttributeUndoableEdit;
+import org.apache.cayenne.modeler.undo.CreateEmbAttributeUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.NamedObjectFactory;
 import org.apache.cayenne.project.ProjectPath;
@@ -43,6 +47,8 @@
  */
 public class CreateAttributeAction extends CayenneAction {
 
+    
+
     public static String getActionName() {
         return "Create Attribute";
     }
@@ -64,26 +70,64 @@
      */
     @Override
     public void performAction(ActionEvent e) {
+        ProjectController mediator = getProjectController();
+
         if (getProjectController().getCurrentEmbeddable() != null) {
-            createEmbAttribute();
+            Embeddable embeddable = mediator.getCurrentEmbeddable();
+
+            EmbeddableAttribute attr = (EmbeddableAttribute) NamedObjectFactory
+                    .createObject(EmbeddableAttribute.class, embeddable);
+
+            createEmbAttribute(embeddable, attr);
+
+            application.getUndoManager().addEdit(
+                    new CreateEmbAttributeUndoableEdit(
+                            embeddable,
+                            new EmbeddableAttribute[] {
+                                attr
+                            }));
         }
+
         if (getProjectController().getCurrentObjEntity() != null) {
-            createObjAttribute();
+
+            ObjEntity objEntity = mediator.getCurrentObjEntity();
+
+            ObjAttribute attr = (ObjAttribute) NamedObjectFactory.createObject(
+                    ObjAttribute.class,
+                    objEntity);
+
+            createObjAttribute(mediator.getCurrentDataDomain(), mediator
+                    .getCurrentDataMap(), objEntity, attr);
+
+            application.getUndoManager().addEdit(
+                    new CreateAttributeUndoableEdit(
+                            mediator.getCurrentDataDomain(),
+                            mediator.getCurrentDataMap(),
+                            objEntity,
+                            attr));
         }
         else if (getProjectController().getCurrentDbEntity() != null) {
-            createDbAttribute();
+            DbEntity dbEntity = getProjectController().getCurrentDbEntity();
+
+            DbAttribute attr = (DbAttribute) NamedObjectFactory.createObject(
+                    DbAttribute.class,
+                    dbEntity);
+
+            createDbAttribute(mediator.getCurrentDataDomain(), mediator
+                    .getCurrentDataMap(), dbEntity, attr);
+
+            application.getUndoManager().addEdit(
+                    new CreateAttributeUndoableEdit(
+                            mediator.getCurrentDataDomain(),
+                            mediator.getCurrentDataMap(),
+                            dbEntity,
+                            attr));
         }
     }
 
-    private void createEmbAttribute() {
+    public void createEmbAttribute(Embeddable embeddable, EmbeddableAttribute attr) {
         ProjectController mediator = getProjectController();
-        Embeddable embeddable = mediator.getCurrentEmbeddable();
-
-        EmbeddableAttribute attr = (EmbeddableAttribute) NamedObjectFactory.createObject(
-                EmbeddableAttribute.class,
-                embeddable);
         embeddable.addAttribute(attr);
-
         fireEmbeddableAttributeEvent(this, mediator, embeddable, attr);
     }
 
@@ -92,6 +136,7 @@
             ProjectController mediator,
             Embeddable embeddable,
             EmbeddableAttribute attr) {
+
         mediator.fireEmbeddableAttributeEvent(new EmbeddableAttributeEvent(
                 src,
                 attr,
@@ -108,16 +153,15 @@
         mediator.fireEmbeddableAttributeDisplayEvent(e);
     }
 
-    public void createObjAttribute() {
-        ProjectController mediator = getProjectController();
-        ObjEntity objEntity = mediator.getCurrentObjEntity();
+    public void createObjAttribute(
+            DataDomain domain,
+            DataMap map,
+            ObjEntity objEntity,
+            ObjAttribute attr) {
 
-        ObjAttribute attr = (ObjAttribute) NamedObjectFactory.createObject(
-                ObjAttribute.class,
-                objEntity);
+        ProjectController mediator = getProjectController();
         objEntity.addAttribute(attr);
-
-        fireObjAttributeEvent(this, mediator, objEntity, attr);
+        fireObjAttributeEvent(this, mediator, domain, map, objEntity, attr);
     }
 
     /**
@@ -126,8 +170,11 @@
     static void fireObjAttributeEvent(
             Object src,
             ProjectController mediator,
+            DataDomain domain,
+            DataMap map,
             ObjEntity objEntity,
             ObjAttribute attr) {
+
         mediator.fireObjAttributeEvent(new AttributeEvent(
                 src,
                 attr,
@@ -138,21 +185,20 @@
                 src,
                 attr,
                 objEntity,
-                mediator.getCurrentDataMap(),
-                mediator.getCurrentDataDomain());
+                map,
+                domain);
 
         mediator.fireObjAttributeDisplayEvent(ade);
     }
 
-    public void createDbAttribute() {
-        DbEntity dbEntity = getProjectController().getCurrentDbEntity();
-        DbAttribute attr = (DbAttribute) NamedObjectFactory.createObject(
-                DbAttribute.class,
-                dbEntity);
+    public void createDbAttribute(
+            DataDomain domain,
+            DataMap map,
+            DbEntity dbEntity,
+            DbAttribute attr) {
         dbEntity.addAttribute(attr);
-
         ProjectController mediator = getProjectController();
-        fireDbAttributeEvent(this, mediator, dbEntity, attr);
+        fireDbAttributeEvent(this, mediator, domain, map, dbEntity, attr);
     }
 
     /**
@@ -161,6 +207,8 @@
     static void fireDbAttributeEvent(
             Object src,
             ProjectController mediator,
+            DataDomain domain,
+            DataMap map,
             DbEntity dbEntity,
             DbAttribute attr) {
         mediator.fireDbAttributeEvent(new AttributeEvent(
@@ -173,8 +221,8 @@
                 src,
                 attr,
                 dbEntity,
-                mediator.getCurrentDataMap(),
-                mediator.getCurrentDataDomain());
+                map,
+                domain);
 
         mediator.fireDbAttributeDisplayEvent(ade);
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java Mon Oct  5 18:40:25 2009
@@ -27,11 +27,16 @@
  * @version 1.0 Oct 30, 2007
  */
 public class CreateCallbackMethodAction extends AbstractCreateCallbackMethodAction {
+    
     /**
      * unique action name
      */
     public static final String ACTION_NAME = "Create callback method";
-
+    
+    public static String getActionName() {
+        return ACTION_NAME;
+    }
+    
     /**
      * Constructor.
      *

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapAction.java Mon Oct  5 18:40:25 2009
@@ -25,6 +25,7 @@
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.undo.CreateDataMapUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.NamedObjectFactory;
 import org.apache.cayenne.project.ProjectPath;
@@ -35,9 +36,11 @@
  */
 public class CreateDataMapAction extends CayenneAction {
 
-	public static String getActionName() {
-		return "Create DataMap";
-	}
+    
+
+    public static String getActionName() {
+        return "Create DataMap";
+    }
 
     public CreateDataMapAction(Application application) {
         super(getActionName(), application);
@@ -47,27 +50,32 @@
         return "icon-datamap.gif";
     }
 
-    /** Calls addDataMap() or creates new data map if no data node selected.*/
-    protected void createDataMap() {
+    /** Calls addDataMap() or creates new data map if no data node selected. */
+    public void createDataMap(DataDomain domain, DataMap map) {
+        ProjectController mediator = getProjectController();
+        mediator.addDataMap(this, map);
+    }
+
+    public void performAction(ActionEvent e) {
         ProjectController mediator = getProjectController();
         DataDomain currentDomain = mediator.getCurrentDataDomain();
-        
-        // use domain name as DataMap base, as map names must be unique across the project...
-        DataMap map =
-            (DataMap) NamedObjectFactory.createObject(
+
+        // use domain name as DataMap base, as map names must be unique across the
+        // project...
+        DataMap map = (DataMap) NamedObjectFactory.createObject(
                 DataMap.class,
                 currentDomain,
                 currentDomain.getName() + "Map");
-        mediator.addDataMap(this, map);
-    }
 
-    public void performAction(ActionEvent e) {
-        createDataMap();
+        createDataMap(currentDomain, map);
+
+        application.getUndoManager().addEdit(
+                new CreateDataMapUndoableEdit(currentDomain, map));
     }
 
     /**
-    * Returns <code>true</code> if path contains a DataDomain object.
-    */
+     * Returns <code>true</code> if path contains a DataDomain object.
+     */
     public boolean enableForPath(ProjectPath path) {
         if (path == null) {
             return false;

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDbEntityAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDbEntityAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDbEntityAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDbEntityAction.java Mon Oct  5 18:40:25 2009
@@ -28,6 +28,7 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
+import org.apache.cayenne.modeler.undo.CreateDbEntityUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.NamedObjectFactory;
 import org.apache.cayenne.project.ProjectPath;
@@ -36,6 +37,8 @@
  */
 public class CreateDbEntityAction extends CayenneAction {
 
+    
+
     public static String getActionName() {
         return "Create DbEntity";
     }
@@ -59,11 +62,15 @@
      */
     public void performAction(ActionEvent e) {
         ProjectController mediator = getProjectController();
-        DbEntity entity = createEntity(mediator.getCurrentDataMap());
 
-        fireDbEntityEvent(this, mediator, entity);
+        DataMap map = mediator.getCurrentDataMap();
+        DbEntity entity = (DbEntity) NamedObjectFactory.createObject(DbEntity.class, map);
+
+        createEntity(map, entity);
+
+        application.getUndoManager().addEdit(new CreateDbEntityUndoableEdit(map, entity));
     }
-    
+
     /**
      * Fires events when a db entity was added
      */
@@ -79,11 +86,11 @@
     /**
      * Constructs and returns a new DbEntity. Entity returned is added to the DataMap.
      */
-    protected DbEntity createEntity(DataMap map) {
-        DbEntity entity = (DbEntity) NamedObjectFactory.createObject(DbEntity.class, map);
+    public void createEntity(DataMap map, DbEntity entity) {
+        ProjectController mediator = getProjectController();
         entity.setSchema(map.getDefaultSchema());
         map.addDbEntity(entity);
-        return entity;
+        fireDbEntityEvent(this, mediator, entity);
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDomainAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDomainAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDomainAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDomainAction.java Mon Oct  5 18:40:25 2009
@@ -27,6 +27,7 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.DomainDisplayEvent;
+import org.apache.cayenne.modeler.undo.CreateDomainUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.ApplicationProject;
 import org.apache.cayenne.project.NamedObjectFactory;
@@ -36,6 +37,8 @@
  */
 public class CreateDomainAction extends CayenneAction {
 
+    
+
     public static String getActionName() {
         return "Create DataDomain";
     }
@@ -54,18 +57,24 @@
     }
 
     public void performAction(ActionEvent e) {
-        createDomain();
-    }
-
-    protected void createDomain() {
-        // only ApplicationProjects can have domains, so this cast is reasonable
         ApplicationProject project = (ApplicationProject) getCurrentProject();
-
         ProjectController mediator = getProjectController();
+
         DataDomain domain = (DataDomain) NamedObjectFactory.createObject(
                 DataDomain.class,
                 project.getConfiguration());
+
         domain.getEntityResolver().setIndexedByClass(false);
+
+        createDomain(domain);
+
+        application.getUndoManager().addEdit(new CreateDomainUndoableEdit(domain));
+    }
+
+    public void createDomain(DataDomain domain) {
+        ApplicationProject project = (ApplicationProject) getCurrentProject();
+        ProjectController mediator = getProjectController();
+
         project.getConfiguration().addDomain(domain);
         mediator.fireDomainEvent(new DomainEvent(this, domain, MapEvent.ADD));
         mediator.fireDomainDisplayEvent(new DomainDisplayEvent(this, domain));

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateEmbeddableAction.java Mon Oct  5 18:40:25 2009
@@ -27,6 +27,7 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.EmbeddableDisplayEvent;
+import org.apache.cayenne.modeler.undo.CreateEmbeddableUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.NamedObjectFactory;
 import org.apache.cayenne.project.ProjectPath;
@@ -48,21 +49,23 @@
 
     @Override
     public void performAction(ActionEvent e) {
-        createEmbeddable();
-    }
-
-    private void createEmbeddable() {
         ProjectController mediator = getProjectController();
 
         DataMap dataMap = mediator.getCurrentDataMap();
+
         Embeddable embeddable = (Embeddable) NamedObjectFactory.createObject(
                 Embeddable.class,
                 mediator.getCurrentDataMap());
 
+        createEmbeddable(dataMap, embeddable);
 
-        dataMap.addEmbeddable(embeddable);
+        application.getUndoManager().addEdit(
+                new CreateEmbeddableUndoableEdit(dataMap, embeddable));
+    }
 
-        fireEmbeddableEvent(this, mediator, dataMap, embeddable);
+    public void createEmbeddable(DataMap dataMap, Embeddable embeddable) {
+        dataMap.addEmbeddable(embeddable);
+        fireEmbeddableEvent(this, getProjectController(), dataMap, embeddable);
     }
 
     static void fireEmbeddableEvent(
@@ -71,7 +74,9 @@
             DataMap dataMap,
             Embeddable embeddable) {
 
-        mediator.fireEmbeddableEvent(new EmbeddableEvent(src, embeddable, MapEvent.ADD), dataMap);
+        mediator.fireEmbeddableEvent(
+                new EmbeddableEvent(src, embeddable, MapEvent.ADD),
+                dataMap);
         EmbeddableDisplayEvent displayEvent = new EmbeddableDisplayEvent(
                 src,
                 embeddable,

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateNodeAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateNodeAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateNodeAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateNodeAction.java Mon Oct  5 18:40:25 2009
@@ -33,6 +33,7 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.DataNodeDisplayEvent;
+import org.apache.cayenne.modeler.undo.CreateNodeUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.ModelerDbAdapter;
 import org.apache.cayenne.project.NamedObjectFactory;
@@ -43,6 +44,8 @@
  */
 public class CreateNodeAction extends CayenneAction {
 
+    
+
     public static String getActionName() {
         return "Create DataNode";
     }
@@ -64,34 +67,42 @@
      * @see org.apache.cayenne.modeler.util.CayenneAction#performAction(ActionEvent)
      */
     public void performAction(ActionEvent e) {
-        ProjectController mediator = getProjectController();
-        DataDomain domain = mediator.getCurrentDataDomain();
-
-        // use domain name as DataNode base, as node names must be unique across the
-        // project...
         DataNode node = buildDataNode();
-        fireDataNodeEvent(this, mediator, domain, node);
+        createDataNode(getProjectController().getCurrentDataDomain(), node);
+        application.getUndoManager().addEdit(
+                new CreateNodeUndoableEdit(application, getProjectController()
+                        .getCurrentDataDomain(), node));
     }
-    
+
+    public void createDataNode(DataDomain domain, DataNode node) {
+        domain.addNode(node);
+        getProjectController().fireDataNodeEvent(
+                new DataNodeEvent(this, node, MapEvent.ADD));
+        getProjectController().fireDataNodeDisplayEvent(
+                new DataNodeDisplayEvent(this, domain, node));
+    }
+
     /**
-     * Fires events when a obj entity was added
+     * Returns <code>true</code> if path contains a DataDomain object.
      */
-    static void fireDataNodeEvent(Object src, ProjectController mediator, DataDomain domain,
-            DataNode node) {
-        mediator.fireDataNodeEvent(new DataNodeEvent(src, node, MapEvent.ADD));
-        mediator.fireDataNodeDisplayEvent(new DataNodeDisplayEvent(src, domain, node));
+    public boolean enableForPath(ProjectPath path) {
+        if (path == null) {
+            return false;
+        }
+
+        return path.firstInstanceOf(DataDomain.class) != null;
     }
 
     /**
      * Creates a new DataNode, adding to the current domain, but doesn't send any events.
      */
-    protected DataNode buildDataNode() {
+    public DataNode buildDataNode() {
         ProjectController mediator = getProjectController();
         DataDomain domain = mediator.getCurrentDataDomain();
 
         // use domain name as DataNode base, as node names must be unique across the
         // project...
-        DataNode node = createDataNode(domain);
+        DataNode node = buildDataNode(domain);
 
         ProjectDataSource src = new ProjectDataSource(new DataSourceInfo());
         node.setDataSource(src);
@@ -100,15 +111,14 @@
         // by default create JDBC Node
         node.setDataSourceFactory(DriverDataSourceFactory.class.getName());
         node.setSchemaUpdateStrategyName(SkipSchemaUpdateStrategy.class.getName());
-        
-        domain.addNode(node);
+
         return node;
     }
 
     /**
      * A factory method that makes a new DataNode.
      */
-    protected DataNode createDataNode(DataDomain domain) {
+    DataNode buildDataNode(DataDomain domain) {
         String name = NamedObjectFactory.createName(DataNode.class, domain, domain
                 .getName()
                 + "Node");
@@ -122,15 +132,4 @@
             }
         };
     }
-
-    /**
-     * Returns <code>true</code> if path contains a DataDomain object.
-     */
-    public boolean enableForPath(ProjectPath path) {
-        if (path == null) {
-            return false;
-        }
-
-        return path.firstInstanceOf(DataDomain.class) != null;
-    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityAction.java Mon Oct  5 18:40:25 2009
@@ -29,6 +29,7 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.EntityDisplayEvent;
+import org.apache.cayenne.modeler.undo.CreateObjEntityUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.NamedObjectFactory;
 import org.apache.cayenne.project.ProjectPath;
@@ -40,6 +41,8 @@
  */
 public class CreateObjEntityAction extends CayenneAction {
 
+    
+
     public static String getActionName() {
         return "Create ObjEntity";
     }
@@ -115,12 +118,24 @@
         merger.synchronizeWithDbEntity(entity);
 
         fireObjEntityEvent(this, mediator, dataMap, entity);
+
+        application.getUndoManager().addEdit(
+                new CreateObjEntityUndoableEdit(dataMap, entity));
     }
-    
+
+    public void createObjEntity(DataMap dataMap, ObjEntity entity) {
+        ProjectController mediator = getProjectController();
+        dataMap.addObjEntity(entity);
+        fireObjEntityEvent(this, mediator, dataMap, entity);
+    }
+
     /**
      * Fires events when a obj entity was added
      */
-    static void fireObjEntityEvent(Object src, ProjectController mediator, DataMap dataMap,
+    static void fireObjEntityEvent(
+            Object src,
+            ProjectController mediator,
+            DataMap dataMap,
             ObjEntity entity) {
         mediator.fireObjEntityEvent(new EntityEvent(src, entity, MapEvent.ADD));
         EntityDisplayEvent displayEvent = new EntityDisplayEvent(

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityListenerAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityListenerAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityListenerAction.java Mon Oct  5 18:40:25 2009
@@ -23,18 +23,22 @@
 import javax.swing.JOptionPane;
 
 import org.apache.cayenne.map.EntityListener;
+import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.event.MapEvent;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.event.EntityListenerEvent;
+import org.apache.cayenne.modeler.undo.CreateEntityListenerUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 
-
 /**
  * Action class for creating entity listeners on an ObjEntity
- *
+ * 
  * @version 1.0 Oct 30, 2007
  */
 public class CreateObjEntityListenerAction extends CayenneAction {
+
+    
+
     /**
      * unique action name
      */
@@ -42,7 +46,7 @@
 
     /**
      * Constructor.
-     *
+     * 
      * @param application Application instance
      */
     public CreateObjEntityListenerAction(Application application) {
@@ -51,7 +55,7 @@
 
     /**
      * Constructor for extending classes.
-     *
+     * 
      * @param actionName unique action name
      * @param application Application instance
      */
@@ -75,7 +79,7 @@
 
     /**
      * checks whether the new name of listener class already exists
-     *
+     * 
      * @param className entered class name
      * @return true or false
      */
@@ -84,41 +88,36 @@
     }
 
     /**
-     * adds new entity listener
-     * @param listener new EntityListener instance
-     */
-    protected void addEntityListener(EntityListener listener) {
-        getProjectController().getCurrentObjEntity().addEntityListener(listener);
-    }
-
-    /**
      * base entity listenre creation logic
-     *
+     * 
      * @param e event
      */
     public void performAction(ActionEvent e) {
-        String listenerClass = JOptionPane.showInputDialog("Please enter listener class:");
+        String listenerClass = JOptionPane
+                .showInputDialog("Please enter listener class:");
         if (listenerClass != null && listenerClass.trim().length() > 0) {
             if (isListenerClassAlreadyExists(listenerClass)) {
                 JOptionPane.showMessageDialog(
                         null,
                         "Listener class already exists.",
                         "Error creating entity listener",
-                        JOptionPane.ERROR_MESSAGE
-                );
+                        JOptionPane.ERROR_MESSAGE);
             }
             else {
-                addEntityListener(new EntityListener(listenerClass));
-                getProjectController().fireEntityListenerEvent(
-                        new EntityListenerEvent(
-                                CreateObjEntityListenerAction.this,
-                                listenerClass,
-                                listenerClass,
-                                MapEvent.ADD
-                        )
-                );
+                ObjEntity objEntity = getProjectController().getCurrentObjEntity();
+                EntityListener listener = new EntityListener(listenerClass);
+                createEntityListener(objEntity, listener);
+                application.getUndoManager().addEdit(
+                        new CreateEntityListenerUndoableEdit(objEntity, listener));
             }
         }
     }
-}
 
+    public void createEntityListener(ObjEntity objEntity, EntityListener listener) {
+        objEntity.addEntityListener(listener);
+
+        getProjectController().fireEntityListenerEvent(
+                new EntityListenerEvent(CreateObjEntityListenerAction.this, listener
+                        .getClassName(), listener.getClassName(), MapEvent.ADD));
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureAction.java Mon Oct  5 18:40:25 2009
@@ -28,6 +28,7 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.ProcedureDisplayEvent;
+import org.apache.cayenne.modeler.undo.CreateProcedureUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.NamedObjectFactory;
 import org.apache.cayenne.project.ProjectPath;
@@ -38,6 +39,8 @@
  */
 public class CreateProcedureAction extends CayenneAction {
 
+    
+
     public static String getActionName() {
         return "Create Stored Procedure";
     }
@@ -48,15 +51,25 @@
 
     public void performAction(ActionEvent e) {
         ProjectController mediator = getProjectController();
-        Procedure procedure = createProcedure(mediator.getCurrentDataMap());
+        DataMap map = mediator.getCurrentDataMap();
+
+        Procedure procedure = (Procedure) NamedObjectFactory.createObject(
+                Procedure.class,
+                map);
+
+        createProcedure(map, procedure);
 
-        fireProcedureEvent(this, mediator, mediator.getCurrentDataMap(), procedure);
+        application.getUndoManager().addEdit(
+                new CreateProcedureUndoableEdit(map, procedure));
     }
-    
+
     /**
      * Fires events when a procedure was added
      */
-    static void fireProcedureEvent(Object src, ProjectController mediator, DataMap dataMap,
+    static void fireProcedureEvent(
+            Object src,
+            ProjectController mediator,
+            DataMap dataMap,
             Procedure procedure) {
         mediator.fireProcedureEvent(new ProcedureEvent(src, procedure, MapEvent.ADD));
         mediator.fireProcedureDisplayEvent(new ProcedureDisplayEvent(
@@ -66,14 +79,11 @@
                 mediator.getCurrentDataDomain()));
     }
 
-    protected Procedure createProcedure(DataMap map) {
-        Procedure procedure = (Procedure) NamedObjectFactory.createObject(
-                Procedure.class,
-                map);
+    public void createProcedure(DataMap map, Procedure procedure) {
+        ProjectController mediator = getProjectController();
         procedure.setSchema(map.getDefaultSchema());
-
         map.addProcedure(procedure);
-        return procedure;
+        fireProcedureEvent(this, mediator, map, procedure);
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateProcedureParameterAction.java Mon Oct  5 18:40:25 2009
@@ -36,6 +36,8 @@
  */
 public class CreateProcedureParameterAction extends CayenneAction {
 
+    
+
     public static String getActionName() {
     	return "Create Parameter";
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateQueryAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateQueryAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateQueryAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateQueryAction.java Mon Oct  5 18:40:25 2009
@@ -21,15 +21,24 @@
 
 import java.awt.event.ActionEvent;
 
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.event.MapEvent;
+import org.apache.cayenne.map.event.QueryEvent;
 import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.query.QueryTypeController;
+import org.apache.cayenne.modeler.event.QueryDisplayEvent;
 import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.query.Query;
 
 /**
  * @since 1.1
  */
 public class CreateQueryAction extends CayenneAction {
 
+    
+
     public static String getActionName() {
         return "Create Query";
     }
@@ -52,4 +61,19 @@
     protected void createQuery() {
         new QueryTypeController(getProjectController()).startup();
     }
+    
+    public void createQuery(DataDomain domain, DataMap dataMap, Query query) {
+        dataMap.addQuery(query);
+        // notify listeners
+        fireQueryEvent(this, getProjectController(), domain, dataMap, query);
+    }
+     
+    /**
+     * Fires events when a query was added
+     */
+    public static void fireQueryEvent(Object src, ProjectController mediator, DataDomain domain,
+            DataMap dataMap, Query query) {
+        mediator.fireQueryEvent(new QueryEvent(src, query, MapEvent.ADD, dataMap));
+        mediator.fireQueryDisplayEvent(new QueryDisplayEvent(src, query, dataMap, domain));
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateRelationshipAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateRelationshipAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateRelationshipAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateRelationshipAction.java Mon Oct  5 18:40:25 2009
@@ -31,6 +31,7 @@
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.event.RelationshipDisplayEvent;
+import org.apache.cayenne.modeler.undo.CreateRelationshipUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.NamedObjectFactory;
 import org.apache.cayenne.project.ProjectPath;
@@ -40,9 +41,11 @@
  */
 public class CreateRelationshipAction extends CayenneAction {
 
-	public static String getActionName() {
-		return "Create Relationship";
-	}
+    
+
+    public static String getActionName() {
+        return "Create Relationship";
+    }
 
     /**
      * Constructor for CreateRelationshipAction.
@@ -63,66 +66,94 @@
     public void performAction(ActionEvent e) {
         ObjEntity objEnt = getProjectController().getCurrentObjEntity();
         if (objEnt != null) {
-            createObjRelationship(objEnt);
-        } else {
+
+            ObjRelationship rel = (ObjRelationship) NamedObjectFactory.createObject(
+                    ObjRelationship.class,
+                    objEnt);
+
+            createObjRelationship(objEnt, rel);
+
+            application.getUndoManager().addEdit(
+                    new CreateRelationshipUndoableEdit(objEnt, new ObjRelationship[] {
+                        rel
+                    }));
+        }
+        else {
             DbEntity dbEnt = getProjectController().getCurrentDbEntity();
             if (dbEnt != null) {
-                createDbRelationship(dbEnt);
+
+                DbRelationship rel = (DbRelationship) NamedObjectFactory.createObject(
+                        DbRelationship.class,
+                        dbEnt);
+
+                createDbRelationship(dbEnt, rel);
+
+                application.getUndoManager().addEdit(
+                        new CreateRelationshipUndoableEdit(dbEnt, new DbRelationship[] {
+                            rel
+                        }));
             }
         }
     }
 
-    public void createObjRelationship(ObjEntity objEntity) {
+    public void createObjRelationship(ObjEntity objEntity, ObjRelationship rel) {
         ProjectController mediator = getProjectController();
 
-        ObjRelationship rel =
-            (ObjRelationship) NamedObjectFactory.createObject(
-                ObjRelationship.class,
-                objEntity);
         rel.setSourceEntity(objEntity);
         DeleteRuleUpdater.updateObjRelationship(rel);
-        
+
         objEntity.addRelationship(rel);
         fireObjRelationshipEvent(this, mediator, objEntity, rel);
     }
-    
+
     /**
      * Fires events when a obj rel was added
      */
-    static void fireObjRelationshipEvent(Object src, ProjectController mediator, ObjEntity objEntity, 
+    static void fireObjRelationshipEvent(
+            Object src,
+            ProjectController mediator,
+            ObjEntity objEntity,
             ObjRelationship rel) {
-        mediator.fireObjRelationshipEvent(
-            new RelationshipEvent(src, rel, objEntity, MapEvent.ADD));
-            
+
+        mediator.fireObjRelationshipEvent(new RelationshipEvent(
+                src,
+                rel,
+                objEntity,
+                MapEvent.ADD));
+
         RelationshipDisplayEvent rde = new RelationshipDisplayEvent(
                 src,
                 rel,
                 objEntity,
                 mediator.getCurrentDataMap(),
                 mediator.getCurrentDataDomain());
-        
+
         mediator.fireObjRelationshipDisplayEvent(rde);
     }
 
-    public void createDbRelationship(DbEntity dbEntity) {
+    public void createDbRelationship(DbEntity dbEntity, DbRelationship rel) {
         ProjectController mediator = getProjectController();
 
-        DbRelationship rel =
-            (DbRelationship) NamedObjectFactory.createObject(DbRelationship.class, dbEntity);
-
         rel.setSourceEntity(dbEntity);
         dbEntity.addRelationship(rel);
 
         fireDbRelationshipEvent(this, mediator, dbEntity, rel);
     }
-    
+
     /**
      * Fires events when a db rel was added
      */
-    static void fireDbRelationshipEvent(Object src, ProjectController mediator, DbEntity dbEntity, 
+    static void fireDbRelationshipEvent(
+            Object src,
+            ProjectController mediator,
+            DbEntity dbEntity,
             DbRelationship rel) {
-        mediator.fireDbRelationshipEvent(
-            new RelationshipEvent(src, rel, dbEntity, MapEvent.ADD));
+
+        mediator.fireDbRelationshipEvent(new RelationshipEvent(
+                src,
+                rel,
+                dbEntity,
+                MapEvent.ADD));
 
         RelationshipDisplayEvent rde = new RelationshipDisplayEvent(
                 src,
@@ -130,13 +161,13 @@
                 dbEntity,
                 mediator.getCurrentDataMap(),
                 mediator.getCurrentDataDomain());
-        
+
         mediator.fireDbRelationshipDisplayEvent(rde);
     }
 
     /**
-    * Returns <code>true</code> if path contains an Entity object.
-    */
+     * Returns <code>true</code> if path contains an Entity object.
+     */
     @Override
     public boolean enableForPath(ProjectPath path) {
         if (path == null) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DocumentationAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DocumentationAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DocumentationAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DocumentationAction.java Mon Oct  5 18:40:25 2009
@@ -29,7 +29,7 @@
  */
 public class DocumentationAction extends CayenneAction {
 
-    private static final long serialVersionUID = 1L;
+    
 
     public final static String getActionName() {
         return "Documentation";

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FindAction.java Mon Oct  5 18:40:25 2009
@@ -28,24 +28,17 @@
 import javax.swing.JTextField;
 
 import org.apache.cayenne.map.Attribute;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.Entity;
-import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.CayenneModelerFrame;
 import org.apache.cayenne.modeler.dialog.FindDialog;
-import org.apache.cayenne.modeler.editor.EditorView;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.ProjectPath;
 
 public class FindAction extends CayenneAction {
-    private java.util.List paths;
+    private java.util.List<Object> paths;
 
     public static String getActionName() {
         return "Find";
@@ -62,7 +55,7 @@
     public void performAction(ActionEvent e) {
         JTextField source = (JTextField) e.getSource();
 
-        paths = new ArrayList();
+        paths = new ArrayList<Object>();
         if (!source.getText().trim().equals("")) {
             Pattern pattern = Pattern.compile(source.getText().trim(), Pattern.CASE_INSENSITIVE);
 
@@ -90,8 +83,7 @@
             int index = 0;
             if (it.hasNext()) {
                 Object[] path = (Object[]) it.next();
-                EditorView editor =  ((CayenneModelerFrame) getApplication().getFrameController().getView()).getView();
-                FindDialog.jumpToResult(path, editor);
+                FindDialog.jumpToResult(path);
             }   
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ImportDBAction.java Mon Oct  5 18:40:25 2009
@@ -22,6 +22,8 @@
 import java.awt.event.ActionEvent;
 import java.sql.Connection;
 
+import javax.swing.SwingUtilities;
+
 import org.apache.cayenne.access.DataDomain;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.modeler.Application;
@@ -68,7 +70,7 @@
         Connection connection = connectWizard.getConnection();
         DbAdapter adapter = connectWizard.getAdapter();
         DBConnectionInfo dataSourceInfo = connectWizard.getConnectionInfo();
-        
+
         // from here pass control to DbLoaderHelper, running it from a thread separate
         // from EventDispatch
 
@@ -81,8 +83,16 @@
 
             public void run() {
                 helper.execute();
+
+                SwingUtilities.invokeLater(new Runnable() {
+
+                    public void run() {
+                        application.getUndoManager().discardAllEdits();
+                    }
+                });
             }
         });
+        
         th.start();
     }
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/InferRelationshipsAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/InferRelationshipsAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/InferRelationshipsAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/InferRelationshipsAction.java Mon Oct  5 18:40:25 2009
@@ -23,7 +23,6 @@
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.dialog.autorelationship.InferRelationshipsController;
-import org.apache.cayenne.modeler.dialog.codegen.CodeGeneratorController;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.project.ProjectPath;
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/OpenProjectAction.java Mon Oct  5 18:40:25 2009
@@ -73,7 +73,7 @@
         if (getProjectController() != null && !checkSaveOnClose()) {
             return;
         }
-
+       
         File f = null;
         if (e.getSource() instanceof FileMenuItem) {
             FileMenuItem menu = (FileMenuItem) e.getSource();
@@ -101,6 +101,8 @@
 
             openProject(f);
         }
+        
+        application.getUndoManager().discardAllEdits();
     }
 
     /** Opens specified project file. File must already exist. */

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java Mon Oct  5 18:40:25 2009
@@ -48,6 +48,8 @@
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ErrorDebugDialog;
 import org.apache.cayenne.modeler.dialog.query.QueryTypeController;
+import org.apache.cayenne.modeler.undo.PasteCompoundUndoableEdit;
+import org.apache.cayenne.modeler.undo.PasteUndoableEdit;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.CayenneTransferable;
 import org.apache.cayenne.project.ProjectPath;
@@ -100,14 +102,23 @@
             Object currentObject = getProjectController().getCurrentObject();
 
             if (content != null && currentObject != null) {
+                
+                PasteCompoundUndoableEdit undoableEdit = new PasteCompoundUndoableEdit();
+                DataDomain domain = getProjectController().getCurrentDataDomain();
+                DataMap map = getProjectController().getCurrentDataMap();
+                
                 if (content instanceof List) {
                     for (Object o : (List) content) {
                         paste(currentObject, o);
+                        undoableEdit.addEdit(new PasteUndoableEdit(domain, map, currentObject, o));
                     }
                 }
                 else {
                     paste(currentObject, content);
+                    undoableEdit.addEdit(new PasteUndoableEdit(domain, map, currentObject, content));
                 }
+                
+                application.getUndoManager().addEdit(undoableEdit);
             }
         }
         catch (UnsupportedFlavorException ufe) {
@@ -117,13 +128,17 @@
             ErrorDebugDialog.guiException(ex);
         }
     }
+    
+    private void paste(Object where, Object content) {
+    	paste(where, content, getProjectController().getCurrentDataDomain(), getProjectController().getCurrentDataMap()); 
+    }
 
     /**
      * Pastes single object
      */
-    protected void paste(Object where, Object content) {
+    public void paste(Object where, Object content, DataDomain domain, DataMap map) {
         final ProjectController mediator = getProjectController();
-        final DataDomain domain = mediator.getCurrentDataDomain();
+      
 
         /**
          * Add a little intelligence - if a tree leaf is selected, we can paste to a
@@ -331,7 +346,7 @@
 
                 dbEntity.addAttribute(attr);
                 CreateAttributeAction
-                        .fireDbAttributeEvent(this, mediator, dbEntity, attr);
+                        .fireDbAttributeEvent(this, mediator, domain, mediator.getCurrentDataMap(), dbEntity, attr);
             }
             else if (content instanceof DbRelationship) {
                 DbRelationship rel = (DbRelationship) content;
@@ -364,7 +379,7 @@
                 objEntity.addAttribute(attr);
                 CreateAttributeAction.fireObjAttributeEvent(
                         this,
-                        mediator,
+                        mediator, domain, mediator.getCurrentDataMap(), 
                         objEntity,
                         attr);
             }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java?rev=821956&r1=821955&r2=821956&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ProjectAction.java Mon Oct  5 18:40:25 2009
@@ -85,6 +85,9 @@
         CayenneModelerController controller = Application
                 .getInstance()
                 .getFrameController();
+        
+        application.getUndoManager().discardAllEdits();
+        
         controller.projectClosedAction();
 
         return true;

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RedoAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RedoAction.java?rev=821956&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RedoAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RedoAction.java Mon Oct  5 18:40:25 2009
@@ -0,0 +1,67 @@
+/*****************************************************************
+ *   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.action;
+
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.KeyStroke;
+
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.util.CayenneAction;
+
+public class RedoAction extends CayenneAction {
+
+    @Override
+    public void setEnabled(boolean b) {
+        super.setEnabled(b);
+    }
+
+    
+
+    @Override
+    public boolean isAlwaysOn() {
+        return false;
+    }
+
+    public static String getActionName() {
+        return "Redo";
+    }
+    
+    public RedoAction(Application application) {
+        super(getActionName(), application);
+    }
+    
+    @Override
+    public KeyStroke getAcceleratorKey() {
+        return KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | InputEvent.SHIFT_MASK);
+    }
+    
+    @Override
+    public String getIconName() {
+        return "icon-redo.gif";
+    }
+
+    @Override
+    public void performAction(ActionEvent e) {
+        application.getUndoManager().redo();
+    }
+}



Mime
View raw message