cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1509355 - in /cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: ./ action/ editor/ undo/
Date Thu, 01 Aug 2013 18:00:43 GMT
Author: aadamchik
Date: Thu Aug  1 18:00:42 2013
New Revision: 1509355

URL: http://svn.apache.org/r1509355
Log:
CAY-1846  Reworking of callback mapping

Jul 31 patch from Ilya Vasiuk

Added:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjCallbackMethod.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCallbackMethodUndoableEdit.java
      - copied, changed from r1509353, cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java
Modified:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyCallbackMethodAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java Thu Aug  1 18:00:42 2013
@@ -80,6 +80,7 @@ import org.apache.cayenne.modeler.action
 import org.apache.cayenne.modeler.action.RevertAction;
 import org.apache.cayenne.modeler.action.SaveAction;
 import org.apache.cayenne.modeler.editor.CallbackType;
+import org.apache.cayenne.modeler.editor.ObjCallbackMethod;
 import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
 import org.apache.cayenne.modeler.event.CallbackMethodEvent;
 import org.apache.cayenne.modeler.event.CallbackMethodListener;
@@ -170,7 +171,7 @@ public class ProjectController extends C
         /**
          * currently selected callback methods
          */
-        private String[] callbackMethods;
+        private ObjCallbackMethod[] callbackMethods;
 
         public ControllerState() {
 
@@ -182,7 +183,7 @@ public class ProjectController extends C
             objAttrs = new ObjAttribute[0];
             objRels = new ObjRelationship[0];
 
-            callbackMethods = new String[0];
+            callbackMethods = new ObjCallbackMethod[0];
         }
 
         /*
@@ -1516,7 +1517,7 @@ public class ProjectController extends C
     /**
      * @return currently selected callback methods
      */
-    public String[] getCurrentCallbackMethods() {
+    public ObjCallbackMethod[] getCurrentCallbackMethods() {
         return currentState.callbackMethods;
     }
 
@@ -1537,7 +1538,7 @@ public class ProjectController extends C
     /**
      * @return currently selected callback methods
      */
-    public void setCurrentCallbackMethods(String[] callbackMethods) {
+    public void setCurrentCallbackMethods(ObjCallbackMethod[] callbackMethods) {
         currentState.callbackMethods = callbackMethods;
     }
 

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java Thu Aug  1 18:00:42 2013
@@ -1,121 +0,0 @@
-/*****************************************************************
- *   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.event.ActionEvent;
-
-import org.apache.cayenne.map.CallbackMap;
-import org.apache.cayenne.map.LifecycleEvent;
-import org.apache.cayenne.map.event.MapEvent;
-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
-     */
-    public AbstractCreateCallbackMethodAction(String actionName, Application application) {
-        super(actionName, application);
-    }
-
-    /**
-     * @return CallbackMap instance where to create a method
-     */
-    public abstract CallbackMap getCallbackMap();
-
-    /**
-     * @return icon file name for button
-     */
-    public String getIconName() {
-        return "icon-create-method.gif";
-    }
-
-    /**
-     * performs adding new callback method
-     * 
-     * @param e event
-     */
-    public final void performAction(ActionEvent e) {
-        CallbackType callbackType = getProjectController().getCurrentCallbackType();
-
-        // 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)) {
-            methodName = methodNamePrefix;
-        }
-        else {
-            int counter = 1;
-            do {
-                methodName = methodNamePrefix + counter;
-                counter++;
-            } while (getCallbackMap()
-                    .getCallbackDescriptor(callbackType.getType())
-                    .getCallbackMethods()
-                    .contains(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(
-                this,
-                null,
-                methodName,
-                MapEvent.ADD);
-
-        getProjectController().fireCallbackMethodEvent(ce);
-    }
-
-    private String toMethodName(LifecycleEvent event) {
-        return "on" + NameConverter.underscoredToJava(event.name(), true);
-    }
-}

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java Thu Aug  1 18:00:42 2013
@@ -1,114 +0,0 @@
-/*****************************************************************
- *   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.event.ActionEvent;
-
-import org.apache.cayenne.map.CallbackMap;
-import org.apache.cayenne.map.event.MapEvent;
-import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.ProjectController;
-import org.apache.cayenne.modeler.dialog.ConfirmRemoveDialog;
-import org.apache.cayenne.modeler.editor.CallbackType;
-import org.apache.cayenne.modeler.event.CallbackMethodEvent;
-
-/**
- * Base class for removing callback methofs
- *
- * @version 1.0 Oct 28, 2007
- */
-public abstract class AbstractRemoveCallbackMethodAction extends RemoveAction {
-
-    
-
-    /**
-     * Constructor.
-     *
-     * @param actionName unique action name
-     * @param application Application instance
-     */
-    public AbstractRemoveCallbackMethodAction(String actionName, Application application) {
-        super(actionName, application);
-    }
-
-    /**
-     * @return CallbackMap instance where to create a method
-     */
-    public abstract CallbackMap getCallbackMap();
-
-    /**
-     * @return icon file name for button
-     */
-    @Override
-    public String getIconName() {
-        return "icon-trash.gif";
-    }
-
-    /**
-     * performs callback method removing
-     * @param e event
-     */
-    @Override
-    public final void performAction(ActionEvent e, boolean allowAsking) {
-        ConfirmRemoveDialog dialog = getConfirmDeleteDialog(allowAsking);
-        
-        String[] methods = getProjectController().getCurrentCallbackMethods();
-
-        if (methods.length > 0) {
-            if ((methods.length == 1 && dialog.shouldDelete("callback method", methods[0]))
-                    || (methods.length > 1 && dialog.shouldDelete("selected callback methods"))) {
-                removeCallbackMethods(e);
-            }
-        }
-    }
-
-    /**
-     * base logic for callback method removing
-     * @param actionEvent event
-     */
-    private void removeCallbackMethods(ActionEvent actionEvent) {
-        ProjectController mediator = getProjectController();
-        CallbackType callbackType = mediator.getCurrentCallbackType();
-
-        String[] callbackMethods = mediator.getCurrentCallbackMethods();
-
-        for (String callbackMethod : callbackMethods) {
-            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
-     */
-    public abstract String getActionName(boolean multiple);
-}
-

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyAction.java Thu Aug  1 18:00:42 2013
@@ -39,6 +39,7 @@ import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.map.ProcedureParameter;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.editor.ObjCallbackMethod;
 import org.apache.cayenne.modeler.util.CayenneAction;
 import org.apache.cayenne.modeler.util.CayenneTransferable;
 import org.apache.cayenne.query.Query;
@@ -131,6 +132,7 @@ public class CopyAction extends CayenneA
                 || object instanceof DbRelationship
                 || object instanceof ObjAttribute
                 || object instanceof ObjRelationship
+                || object instanceof ObjCallbackMethod
                 || object instanceof Procedure
                 || object instanceof ProcedureParameter) {
             return true;

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyCallbackMethodAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyCallbackMethodAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CopyCallbackMethodAction.java Thu Aug  1 18:00:42 2013
@@ -5,6 +5,7 @@ import java.util.Arrays;
 import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.editor.ObjCallbackMethod;
 
 public class CopyCallbackMethodAction extends CopyAction implements MultipleObjectsAction {
 
@@ -33,7 +34,11 @@ public class CopyCallbackMethodAction ex
      */
     @Override
     public boolean enableForPath(ConfigurationNode object) {
-        return object != null;
+        if (object == null) {
+            return false;
+        }
+
+        return object instanceof ObjCallbackMethod;
     }
 
     @Override

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java Thu Aug  1 18:00:42 2013
@@ -18,20 +18,109 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.action;
 
+import java.awt.event.ActionEvent;
+
 import org.apache.cayenne.map.CallbackMap;
+import org.apache.cayenne.map.LifecycleEvent;
+import org.apache.cayenne.map.event.MapEvent;
 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;
 
 /**
  * Action class for creating callback methods on ObjEntity
  *
  * @version 1.0 Oct 30, 2007
  */
-public class CreateCallbackMethodAction extends AbstractCreateCallbackMethodAction {
+public class CreateCallbackMethodAction extends CayenneAction {
     
     /**
      * unique action name
      */
     public static final String ACTION_NAME = "Create callback method";
+
+    /**
+     * Constructor.
+     * 
+     * @param actionName unique action name
+     * @param application Application instance
+     */
+    public CreateCallbackMethodAction(String actionName, Application application) {
+        super(actionName, application);
+    }
+
+    /**
+     * @return CallbackMap instance where to create a method
+     */
+    public CallbackMap getCallbackMap() {
+        return getProjectController().getCurrentObjEntity().getCallbackMap();
+    }
+    
+    /**
+     * @return icon file name for button
+     */
+    public String getIconName() {
+        return "icon-create-method.gif";
+    }
+
+    /**
+     * performs adding new callback method
+     * 
+     * @param e event
+     */
+    public final void performAction(ActionEvent e) {
+        CallbackType callbackType = getProjectController().getCurrentCallbackType();
+
+        // 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)) {
+            methodName = methodNamePrefix;
+        }
+        else {
+            int counter = 1;
+            do {
+                methodName = methodNamePrefix + counter;
+                counter++;
+            } while (getCallbackMap()
+                    .getCallbackDescriptor(callbackType.getType())
+                    .getCallbackMethods()
+                    .contains(methodName));
+        }
+
+        createCallbackMethod(callbackType, methodName);
+        application.getUndoManager().addEdit(
+                new CreateCallbackMethodUndoableEdit(
+                        callbackType,
+                        methodName));
+    }
+
+    public void createCallbackMethod(
+            CallbackType callbackType,
+            String methodName) {
+        getCallbackMap().getCallbackDescriptor(callbackType.getType()).addCallbackMethod(methodName);
+
+        CallbackMethodEvent ce = new CallbackMethodEvent(
+                this,
+                null,
+                methodName,
+                MapEvent.ADD);
+
+        getProjectController().fireCallbackMethodEvent(ce);
+    }
+
+    private String toMethodName(LifecycleEvent event) {
+        return "on" + NameConverter.underscoredToJava(event.name(), true);
+    }
     
     public static String getActionName() {
         return ACTION_NAME;
@@ -45,12 +134,5 @@ public class CreateCallbackMethodAction 
     public CreateCallbackMethodAction(Application application) {
         super(ACTION_NAME, application);
     }
-
-    /**
-     * @return CallbackMap instance where to create a method
-     */
-    public CallbackMap getCallbackMap() {
-        return getProjectController().getCurrentObjEntity().getCallbackMap();
-    }
 }
 

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java Thu Aug  1 18:00:42 2013
@@ -1,55 +0,0 @@
-/*****************************************************************
- *   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 org.apache.cayenne.map.CallbackMap;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.modeler.Application;
-
-
-/**
- * Action class for creating callback methods on ObjEntity entity listener
- *
- * @version 1.0 Oct 30, 2007
- */
-public class CreateCallbackMethodForListenerAction extends AbstractCreateCallbackMethodAction {
-    /**
-     * unique action name
-     */
-    public static final String ACTION_NAME = "Create callback method for entity listener";
-
-    /**
-     * Constructor.
-     *
-     * @param application Application instance
-     */
-    public CreateCallbackMethodForListenerAction(Application application) {
-        super(ACTION_NAME, application);
-    }
-
-    /**
-     * @return CallbackMap instance where to create a method
-     */
-    public CallbackMap getCallbackMap() {
-        ObjEntity objEnt = getProjectController().getCurrentObjEntity();
-        String listenerClass = getProjectController().getCurrentListenerClass();
-        return objEnt.getEntityListener(listenerClass).getCallbackMap();
-    }
-}
-

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java Thu Aug  1 18:00:42 2013
@@ -83,9 +83,7 @@ public class DefaultActionManager implem
         registerAction(new RemoveRelationshipAction(application));
         // start callback-related actions
         registerAction(new CreateCallbackMethodAction(application)).setAlwaysOn(true);
-        registerAction(new CreateCallbackMethodForListenerAction(application));
         registerAction(new RemoveCallbackMethodAction(application));
-        registerAction(new RemoveCallbackMethodForListenerAction(application));
         registerAction(new CreateObjEntityListenerAction(application)).setAlwaysOn(true);
         registerAction(new CreateDataMapEntityListenerAction(application)).setAlwaysOn(
                 true);

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/PasteAction.java Thu Aug  1 18:00:42 2013
@@ -41,7 +41,6 @@ import org.apache.cayenne.map.DbRelation
 import org.apache.cayenne.map.Embeddable;
 import org.apache.cayenne.map.EmbeddableAttribute;
 import org.apache.cayenne.map.EntityResolver;
-import org.apache.cayenne.map.LifecycleEvent;
 import org.apache.cayenne.map.MappingNamespace;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
@@ -53,6 +52,7 @@ import org.apache.cayenne.modeler.Applic
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ErrorDebugDialog;
 import org.apache.cayenne.modeler.dialog.query.QueryType;
+import org.apache.cayenne.modeler.editor.ObjCallbackMethod;
 import org.apache.cayenne.modeler.event.CallbackMethodEvent;
 import org.apache.cayenne.modeler.undo.PasteCompoundUndoableEdit;
 import org.apache.cayenne.modeler.undo.PasteUndoableEdit;
@@ -366,7 +366,6 @@ public class PasteAction extends Cayenne
         }
         else if (where instanceof ObjEntity) {
             final ObjEntity objEntity = (ObjEntity) where;
-            final LifecycleEvent whereType = mediator.getCurrentCallbackType().getType();
 
             // attrs and rels must be unique in entity namespace
             FreeNameChecker checker = new FreeNameChecker() {
@@ -374,8 +373,10 @@ public class PasteAction extends Cayenne
                 public boolean isNameFree(String name) {
                     return objEntity.getAttribute(name) == null
                             && objEntity.getRelationship(name) == null
-                            && !objEntity.getCallbackMap().getCallbackDescriptor(whereType)
-                            		.getCallbackMethods().contains(name);
+                            // uninitialized mediator.currentCallbackType should not affect a copying of rels or attrs
+                            && (mediator.getCurrentCallbackType() == null ? true : 
+                            	!objEntity.getCallbackMap().getCallbackDescriptor(mediator.getCurrentCallbackType().getType())
+                            		.getCallbackMethods().contains(name));
                 }
             };
 
@@ -398,16 +399,16 @@ public class PasteAction extends Cayenne
                         objEntity,
                         rel);
             }
-            else if(content.getClass().equals(String.class)) {
-                String methodName = (String) content;
-                methodName = getFreeName(checker, methodName);
+            else if(content instanceof ObjCallbackMethod) {
+            	ObjCallbackMethod method = (ObjCallbackMethod) content;
+            	method.setName(getFreeName(checker, method.getName()));
                 
-                objEntity.getCallbackMap().getCallbackDescriptor(whereType).addCallbackMethod(methodName);
+                objEntity.getCallbackMap().getCallbackDescriptor(mediator.getCurrentCallbackType().getType()).addCallbackMethod(method.getName());
 
                 CallbackMethodEvent ce = new CallbackMethodEvent(
                         this,
                         null,
-                        methodName,
+                        method.getName(),
                         MapEvent.ADD);
 
                 getProjectController().fireCallbackMethodEvent(ce);
@@ -544,7 +545,7 @@ public class PasteAction extends Cayenne
                     ||
 
                     (currentObject instanceof ObjEntity && (content instanceof ObjAttribute
-                            || content instanceof ObjRelationship || content.getClass().equals(String.class) || isTreeLeaf(content)))
+                            || content instanceof ObjRelationship || content instanceof ObjCallbackMethod || isTreeLeaf(content)))
                     ||
 
                     (currentObject instanceof Embeddable && (content instanceof EmbeddableAttribute || isTreeLeaf(content)))

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java Thu Aug  1 18:00:42 2013
@@ -18,8 +18,17 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.action;
 
+import java.awt.event.ActionEvent;
+
 import org.apache.cayenne.map.CallbackMap;
+import org.apache.cayenne.map.event.MapEvent;
 import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.dialog.ConfirmRemoveDialog;
+import org.apache.cayenne.modeler.editor.CallbackType;
+import org.apache.cayenne.modeler.editor.ObjCallbackMethod;
+import org.apache.cayenne.modeler.event.CallbackMethodEvent;
+import org.apache.cayenne.modeler.undo.RemoveCallbackMethodUndoableEdit;
 
 
 /**
@@ -27,10 +36,8 @@ import org.apache.cayenne.modeler.Applic
  *
  * @version 1.0 Oct 30, 2007
  */
-public class RemoveCallbackMethodAction extends AbstractRemoveCallbackMethodAction {
-    
+public class RemoveCallbackMethodAction extends RemoveAction {
     
-
     /**
      * unique action name
      */
@@ -44,10 +51,65 @@ public class RemoveCallbackMethodAction 
     /**
      * Constructor.
      *
+     * @param actionName unique action name
      * @param application Application instance
      */
     public RemoveCallbackMethodAction(Application application) {
-        super(ACTION_NAME, application);
+        super(getActionName(), application);
+    }
+
+    /**
+     * @return icon file name for button
+     */
+    @Override
+    public String getIconName() {
+        return "icon-trash.gif";
+    }
+    
+    /**
+     * performs callback method removing
+     * @param e event
+     */
+    public void performAction(ActionEvent e, boolean allowAsking) {
+        ConfirmRemoveDialog dialog = getConfirmDeleteDialog(allowAsking);
+        
+        ObjCallbackMethod[] methods = getProjectController().getCurrentCallbackMethods();
+
+        if ((methods.length == 1 && dialog.shouldDelete("callback method", methods[0].getName()))
+        		|| (methods.length > 1 && dialog.shouldDelete("selected callback methods"))) {
+        	removeCallbackMethods(e);
+        }
+    }
+
+    /**
+     * base logic for callback method removing
+     * @param actionEvent event
+     */
+    private void removeCallbackMethods(ActionEvent actionEvent) {
+        ProjectController mediator = getProjectController();
+        CallbackType callbackType = mediator.getCurrentCallbackType();
+
+        ObjCallbackMethod[] callbackMethods = mediator.getCurrentCallbackMethods();
+
+        for (ObjCallbackMethod callbackMethod : callbackMethods) {
+            removeCallbackMethod(callbackType, callbackMethod.getName());
+        }
+        
+        Application.getInstance().getUndoManager().addEdit( 
+        		new RemoveCallbackMethodUndoableEdit(callbackType, callbackMethods));
+    }
+    
+    public void removeCallbackMethod(CallbackType callbackType, String method) {
+        ProjectController mediator = getProjectController();
+        getCallbackMap().getCallbackDescriptor(callbackType.getType()).removeCallbackMethod(method);
+        
+        CallbackMethodEvent e = new CallbackMethodEvent(
+                this,
+                null,
+                method,
+                MapEvent.REMOVE);
+        
+        mediator.fireCallbackMethodEvent(e);
     }
 
     /**
@@ -60,12 +122,10 @@ public class RemoveCallbackMethodAction 
     /**
      * @return CallbackMap fom which remove callback method
      */
-    @Override
     public CallbackMap getCallbackMap() {
         return getProjectController().getCurrentObjEntity().getCallbackMap();
     }
 
-    @Override
     public String getActionName(boolean multiple) {
         return multiple ? ACTION_NAME_MULTIPLE : ACTION_NAME;
     }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java Thu Aug  1 18:00:42 2013
@@ -1,66 +0,0 @@
-/*****************************************************************
- *   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 org.apache.cayenne.map.CallbackMap;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.modeler.Application;
-
-
-/**
- * Action class for removing callback methods from ObjEntity's entity listener
- *
- * @version 1.0 Oct 30, 2007
- */
-public class RemoveCallbackMethodForListenerAction extends AbstractRemoveCallbackMethodAction{
-    /**
-     * unique action name
-     */
-    public final static String ACTION_NAME = "Remove callback method for entity listener";
-    
-    /**
-     * action name for multiple selection
-     */
-    private final static String ACTION_NAME_MULTIPLE = "Remove callback methods for entity listener";
-
-    /**
-     * Constructor.
-     *
-     * @param application Application instance
-     */
-    public RemoveCallbackMethodForListenerAction(Application application) {
-        super(ACTION_NAME, application);
-    }
-
-    /**
-     * @return CallbackMap fom which remove callback method
-     */
-    @Override
-    public CallbackMap getCallbackMap() {
-        ObjEntity objEnt = getProjectController().getCurrentObjEntity();
-        String listenerClass = getProjectController().getCurrentListenerClass();
-        return objEnt.getEntityListener(listenerClass).getCallbackMap();
-    }
-    
-    @Override
-    public String getActionName(boolean multiple) {
-        return multiple ? ACTION_NAME_MULTIPLE : ACTION_NAME;
-    }
-}
-

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java Thu Aug  1 18:00:42 2013
@@ -52,7 +52,6 @@ import org.apache.cayenne.map.CallbackMa
 import org.apache.cayenne.map.LifecycleEvent;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
-import org.apache.cayenne.modeler.action.AbstractRemoveCallbackMethodAction;
 import org.apache.cayenne.modeler.action.CopyCallbackMethodAction;
 import org.apache.cayenne.modeler.action.CreateCallbackMethodAction;
 import org.apache.cayenne.modeler.action.CutCallbackMethodAction;
@@ -150,7 +149,7 @@ public abstract class AbstractCallbackMe
     /**
      * @return remove callback method action
      */
-    protected AbstractRemoveCallbackMethodAction getRemoveCallbackMethodAction() {
+    protected RemoveCallbackMethodAction getRemoveCallbackMethodAction() {
         Application app = Application.getInstance();
         return app.getActionManager().getAction(RemoveCallbackMethodAction.class);
     }
@@ -226,7 +225,26 @@ public abstract class AbstractCallbackMe
             }
 
             public void callbackMethodRemoved(CallbackMethodEvent e) {
-                rebuildTables();
+            	int row = -1, i;
+            	
+            	for(i = 0; i < callbackTypes.length; i++) {
+            		if(callbackTypes[i] == getSelectedCallbackType()) {
+                        row = tables[i].getSelectedRow();
+                        break;
+            		}
+            	}
+                
+            	rebuildTables();
+                
+            	if(row == tables[i].getRowCount()) {
+                	row--;
+                }
+                
+            	if (row < 0) {
+                    return;
+                }
+
+            	tables[i].changeSelection(row, 0, false, false);
             }
         });
         
@@ -320,10 +338,11 @@ public abstract class AbstractCallbackMe
     private JPopupMenu createPopup() {
 	    JPopupMenu popup = new JPopupMenu();
 
+	    popup.add(getRemoveCallbackMethodAction().buildMenu());
+	    popup.addSeparator();
 	    popup.add(getCopyCallbackMethodAction().buildMenu());
 	    popup.add(getCutCallbackMethodAction().buildMenu());
 	    popup.add(getPasteCallbackMethodAction().buildMenu());
-	    popup.add(getRemoveCallbackMethodAction().buildMenu());
 	    
 		return popup;
 	}
@@ -472,7 +491,7 @@ public abstract class AbstractCallbackMe
     	
     	public void valueChanged(ListSelectionEvent e) {
             if (!e.getValueIsAdjusting()) {
-            	String[] methods = new String[0];
+            	ObjCallbackMethod[] methods = new ObjCallbackMethod[0];
 
                 if(!((ListSelectionModel)e.getSource()).isSelectionEmpty()) {
 	                for(int i = 0; i < tables.length; i++) {
@@ -490,14 +509,17 @@ public abstract class AbstractCallbackMe
             	
                 if (table.getSelectedRow() != -1) {
                     int[] sel = table.getSelectedRows();
-                    methods = new String[sel.length];
-
+                    CallbackType callbackType = mediator.getCurrentCallbackType();
+                    
+                    methods = new ObjCallbackMethod[sel.length];
+                                        
                     for (int i = 0; i < sel.length; i++) {
-                        methods[i] = (String) table
+                    	String methodName = (String) table
                                 .getValueAt(
                                         sel[i],
                                         table
                                                 .convertColumnIndexToView(CallbackDescriptorTableModel.METHOD_NAME));
+                    	methods[i] = new ObjCallbackMethod(methodName, callbackType);
                     }
                 }
 

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java Thu Aug  1 18:00:42 2013
@@ -18,8 +18,9 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.editor;
 
+import java.io.Serializable;
+
 import org.apache.cayenne.map.LifecycleEvent;
-import org.apache.cayenne.util.ConversionUtil;
 import org.apache.cayenne.util.NameConverter;
 
 /**
@@ -28,7 +29,7 @@ import org.apache.cayenne.util.NameConve
  * @version 1.0 Oct 26, 2007
  */
 
-public class CallbackType {
+public class CallbackType implements Serializable {
 
     private LifecycleEvent type;
 

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjCallbackMethod.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjCallbackMethod.java?rev=1509355&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjCallbackMethod.java (added)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjCallbackMethod.java Thu Aug  1 18:00:42 2013
@@ -0,0 +1,65 @@
+package org.apache.cayenne.modeler.editor;
+
+import java.io.Serializable;
+
+import org.apache.cayenne.util.XMLEncoder;
+import org.apache.cayenne.util.XMLSerializable;
+
+public class ObjCallbackMethod implements XMLSerializable,
+	Serializable {
+	
+	private String name;
+	private CallbackType callbackType;
+
+	public ObjCallbackMethod(String name, CallbackType callbackType) {
+		this.name = name;
+		this.callbackType = callbackType;
+	}
+
+	@Override
+	public void encodeAsXML(XMLEncoder encoder) {
+
+        encoder.print("<" + encodeCallbackTypeForXML(callbackType));
+        encoder.print(" name=\"" + getName());
+
+        encoder.println("\"/>");
+	}
+
+	private String encodeCallbackTypeForXML(CallbackType type) {
+		switch(type.getType()) {
+			case POST_ADD : 
+				return "post-add";
+			case POST_LOAD :
+				return "post-load";
+			case POST_PERSIST :
+				return "post-persist";
+			case POST_REMOVE :
+				return "post-remove";
+			case POST_UPDATE :
+				return "post-update";
+			case PRE_PERSIST :
+				return "pre-persist";
+			case PRE_REMOVE :
+				return "pre-remove";
+			default:
+				return "pre-update";
+		}
+	}
+	
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;	
+	}
+
+	public CallbackType getCallbackType() {
+		return callbackType;
+	}
+
+	public void setCallbackType(CallbackType callbackType) {
+		this.callbackType = callbackType;
+	}
+
+}

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java Thu Aug  1 18:00:42 2013
@@ -21,14 +21,12 @@ package org.apache.cayenne.modeler.undo;
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.map.CallbackMap;
 import org.apache.cayenne.modeler.action.CreateCallbackMethodAction;
 import org.apache.cayenne.modeler.action.RemoveCallbackMethodAction;
 import org.apache.cayenne.modeler.editor.CallbackType;
 
 public class CreateCallbackMethodUndoableEdit extends CayenneUndoableEdit {
 
-    private CallbackMap map;
     private CallbackType callbackType;
     private String methodName;
 
@@ -41,19 +39,18 @@ public class CreateCallbackMethodUndoabl
     public void redo() throws CannotRedoException {
         CreateCallbackMethodAction action = actionManager
                 .getAction(CreateCallbackMethodAction.class);
-        action.createCallbackMethod(map, callbackType, methodName);
+        action.createCallbackMethod(callbackType, methodName);
     }
 
     @Override
     public void undo() throws CannotUndoException {
         RemoveCallbackMethodAction action = actionManager
                 .getAction(RemoveCallbackMethodAction.class);
-        action.removeCallbackMethod(map, callbackType, methodName);
+        action.removeCallbackMethod(callbackType, methodName);
     }
 
-    public CreateCallbackMethodUndoableEdit(CallbackMap map, CallbackType callbackType,
+    public CreateCallbackMethodUndoableEdit(CallbackType callbackType,
             String methodName) {
-        this.map = map;
         this.callbackType = callbackType;
         this.methodName = methodName;
     }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java?rev=1509355&r1=1509354&r2=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/PasteUndoableEdit.java Thu Aug  1 18:00:42 2013
@@ -36,8 +36,10 @@ import org.apache.cayenne.map.ProcedureP
 import org.apache.cayenne.modeler.action.PasteAction;
 import org.apache.cayenne.modeler.action.RemoveAction;
 import org.apache.cayenne.modeler.action.RemoveAttributeAction;
+import org.apache.cayenne.modeler.action.RemoveCallbackMethodAction;
 import org.apache.cayenne.modeler.action.RemoveProcedureParameterAction;
 import org.apache.cayenne.modeler.action.RemoveRelationshipAction;
+import org.apache.cayenne.modeler.editor.ObjCallbackMethod;
 import org.apache.cayenne.query.Query;
 
 public class PasteUndoableEdit extends CayenneUndoableEdit {
@@ -82,6 +84,9 @@ public class PasteUndoableEdit extends C
         RemoveRelationshipAction rRelationShipAction = actionManager
                 .getAction(RemoveRelationshipAction.class);
 
+        RemoveCallbackMethodAction rCallbackMethodAction = actionManager
+                .getAction(RemoveCallbackMethodAction.class);
+
         RemoveProcedureParameterAction rProcedureParamAction = actionManager
                 .getAction(RemoveProcedureParameterAction.class);
 
@@ -150,6 +155,15 @@ public class PasteUndoableEdit extends C
                             (ObjRelationship) content
                         });
             }
+            else if (content instanceof ObjCallbackMethod) {
+            		ObjCallbackMethod[] methods = new ObjCallbackMethod[] {
+                            (ObjCallbackMethod) content };
+            		for(ObjCallbackMethod callbackMethod : methods) {
+	            		rCallbackMethodAction.removeCallbackMethod(
+	                			methods[0].getCallbackType(), 
+	                			callbackMethod.getName());
+            		}
+            }
         }
         else if (where instanceof Procedure) {
             final Procedure procedure = (Procedure) where;

Copied: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCallbackMethodUndoableEdit.java (from r1509353, cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCallbackMethodUndoableEdit.java?p2=cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCallbackMethodUndoableEdit.java&p1=cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java&r1=1509353&r2=1509355&rev=1509355&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/CreateCallbackMethodUndoableEdit.java (original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/undo/RemoveCallbackMethodUndoableEdit.java Thu Aug  1 18:00:42 2013
@@ -21,41 +21,42 @@ package org.apache.cayenne.modeler.undo;
 import javax.swing.undo.CannotRedoException;
 import javax.swing.undo.CannotUndoException;
 
-import org.apache.cayenne.map.CallbackMap;
 import org.apache.cayenne.modeler.action.CreateCallbackMethodAction;
 import org.apache.cayenne.modeler.action.RemoveCallbackMethodAction;
 import org.apache.cayenne.modeler.editor.CallbackType;
+import org.apache.cayenne.modeler.editor.ObjCallbackMethod;
 
-public class CreateCallbackMethodUndoableEdit extends CayenneUndoableEdit {
+public class RemoveCallbackMethodUndoableEdit extends CayenneUndoableEdit {
 
-    private CallbackMap map;
     private CallbackType callbackType;
-    private String methodName;
+    private ObjCallbackMethod[] methods;
+
+    public RemoveCallbackMethodUndoableEdit(CallbackType callbackType,
+    		ObjCallbackMethod[] methods) {
+        this.callbackType = callbackType;
+        this.methods = methods;
+    }
 
     @Override
     public String getPresentationName() {
-        return "Create Callback Method";
+    	return "Remove Obj Callback Methods";
     }
 
     @Override
     public void redo() throws CannotRedoException {
-        CreateCallbackMethodAction action = actionManager
-                .getAction(CreateCallbackMethodAction.class);
-        action.createCallbackMethod(map, callbackType, methodName);
+    	RemoveCallbackMethodAction action = actionManager
+                .getAction(RemoveCallbackMethodAction.class);
+        for (ObjCallbackMethod method : methods) {
+            action.removeCallbackMethod(callbackType, method.getName());
+        }
     }
 
     @Override
     public void undo() throws CannotUndoException {
-        RemoveCallbackMethodAction action = actionManager
-                .getAction(RemoveCallbackMethodAction.class);
-        action.removeCallbackMethod(map, callbackType, methodName);
-    }
-
-    public CreateCallbackMethodUndoableEdit(CallbackMap map, CallbackType callbackType,
-            String methodName) {
-        this.map = map;
-        this.callbackType = callbackType;
-        this.methodName = methodName;
+    	CreateCallbackMethodAction action = actionManager
+                .getAction(CreateCallbackMethodAction.class);
+        for (ObjCallbackMethod method : methods) {
+            action.createCallbackMethod(callbackType, method.getName());
+        }
     }
-
 }



Mime
View raw message