cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r591617 [1/2] - in /cayenne/main/trunk/framework/cayenne-modeler/src/main: java/org/apache/cayenne/modeler/ java/org/apache/cayenne/modeler/action/ java/org/apache/cayenne/modeler/editor/ java/org/apache/cayenne/modeler/event/ resources/org...
Date Sat, 03 Nov 2007 13:17:31 GMT
Author: aadamchik
Date: Sat Nov  3 06:17:28 2007
New Revision: 591617

URL: http://svn.apache.org/viewvc?rev=591617&view=rev
Log:
CAY-900 Create CayenneModeler Swing UI for managing callbacks and lifecycle listeners
(first cut)

Added:
    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/ChangeDataMapEntityListenerClassAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeObjEntityListenerClassAction.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/CreateCallbackMethodForDataMapListenerAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapEntityListenerAction.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/RemoveCallbackMethodAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForDataMapListenerAction.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.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/editor/AbstractCallbackListenersTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackDescriptorTableModel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapCallbackListenersTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackListenersTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackMethodsTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/StringTransferHandler.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/CallbackMethodDisplayEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/CallbackMethodDisplayListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/CallbackMethodEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/CallbackMethodListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/CallbackTypeSelectionEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/CallbackTypeSelectionListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EntityListenerEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/EntityListenerListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/ListenerClassSelectionEvent.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/event/ListenerClassSelectionListener.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-change-listener.gif   (with props)
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-create-listener.gif   (with props)
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-create-method.gif   (with props)
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-remove-listener.gif   (with props)
    cayenne/main/trunk/framework/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-remove-method.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/ProjectController.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EditorView.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityTabbedView.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=591617&r1=591616&r2=591617&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 Sat Nov  3 06:17:28 2007
@@ -125,6 +125,20 @@
         registerAction(new RemoveAttributeAction(application));
         registerAction(new CreateRelationshipAction(application));
         registerAction(new RemoveRelationshipAction(application));
+        // start callback-related actions
+        registerAction(new CreateCallbackMethodAction(application)).setAlwaysOn(true);
+        registerAction(new CreateCallbackMethodForListenerAction(application)).setAlwaysOn(true);
+        registerAction(new CreateCallbackMethodForDataMapListenerAction(application)).setAlwaysOn(true);
+        registerAction(new RemoveCallbackMethodAction(application));
+        registerAction(new RemoveCallbackMethodForListenerAction(application));
+        registerAction(new RemoveCallbackMethodForDataMapListenerAction(application));
+        registerAction(new CreateObjEntityListenerAction(application)).setAlwaysOn(true);
+        registerAction(new CreateDataMapEntityListenerAction(application)).setAlwaysOn(true);
+        registerAction(new ChangeObjEntityListenerClassAction(application));
+        registerAction(new ChangeDataMapEntityListenerClassAction(application));
+        registerAction(new RemoveEntityListenerAction(application)).setAlwaysOn(true);
+        registerAction(new RemoveEntityListenerForDataMapAction(application)).setAlwaysOn(true);
+        // end callback-related actions
         registerAction(new DbEntitySyncAction(application));
         registerAction(new ObjEntitySyncAction(application));
         registerAction(new DerivedEntitySyncAction(application));
@@ -148,6 +162,8 @@
 
     /**
      * Returns an action for key.
+     * @param key action name
+     * @return action
      */
     public CayenneAction getAction(String key) {
         return (CayenneAction) actionMap.get(key);
@@ -213,6 +229,7 @@
     /**
      * Sets the state of all controlled actions, flipping it to "enabled" for all actions
      * in provided collection and to "disabled" for the rest.
+     * @param namesOfEnabled action names
      */
     protected void processActionsState(Collection namesOfEnabled) {
         Iterator it = actionMap.entrySet().iterator();

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java?rev=591617&r1=591616&r2=591617&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectController.java Sat Nov  3 06:17:28 2007
@@ -65,32 +65,12 @@
 import org.apache.cayenne.modeler.action.NavigateForwardAction;
 import org.apache.cayenne.modeler.action.RevertAction;
 import org.apache.cayenne.modeler.action.SaveAction;
-import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
-import org.apache.cayenne.modeler.event.DataMapDisplayEvent;
-import org.apache.cayenne.modeler.event.DataMapDisplayListener;
-import org.apache.cayenne.modeler.event.DataNodeDisplayEvent;
-import org.apache.cayenne.modeler.event.DataNodeDisplayListener;
-import org.apache.cayenne.modeler.event.DbAttributeDisplayListener;
-import org.apache.cayenne.modeler.event.DbEntityDisplayListener;
-import org.apache.cayenne.modeler.event.DbRelationshipDisplayListener;
-import org.apache.cayenne.modeler.event.DisplayEvent;
-import org.apache.cayenne.modeler.event.DomainDisplayEvent;
-import org.apache.cayenne.modeler.event.DomainDisplayListener;
-import org.apache.cayenne.modeler.event.EntityDisplayEvent;
-import org.apache.cayenne.modeler.event.ObjAttributeDisplayListener;
-import org.apache.cayenne.modeler.event.ObjEntityDisplayListener;
-import org.apache.cayenne.modeler.event.ObjRelationshipDisplayListener;
-import org.apache.cayenne.modeler.event.ProcedureDisplayEvent;
-import org.apache.cayenne.modeler.event.ProcedureDisplayListener;
-import org.apache.cayenne.modeler.event.ProcedureParameterDisplayEvent;
-import org.apache.cayenne.modeler.event.ProcedureParameterDisplayListener;
-import org.apache.cayenne.modeler.event.QueryDisplayEvent;
-import org.apache.cayenne.modeler.event.QueryDisplayListener;
-import org.apache.cayenne.modeler.event.RelationshipDisplayEvent;
+import org.apache.cayenne.modeler.event.*;
 import org.apache.cayenne.modeler.pref.DataMapDefaults;
 import org.apache.cayenne.modeler.pref.DataNodeDefaults;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.modeler.util.CircularArray;
+import org.apache.cayenne.modeler.editor.CallbackType;
 import org.apache.cayenne.pref.Domain;
 import org.apache.cayenne.project.Project;
 import org.apache.cayenne.query.Query;
@@ -123,6 +103,18 @@
         private ObjAttribute objAttr;
         private DbAttribute dbAttr;
         private ObjRelationship objRel;
+        /**
+         * currently selecte entity listener class
+         */
+        private String listenerClass;
+        /**
+         * currently selected callback type
+         */
+        private CallbackType callbackType;
+        /**
+         * currently selected callback method
+         */
+        private String callbackMethod;
         private DbRelationship dbRel;
         private Procedure procedure;
         private ProcedureParameter procedureParameter;
@@ -137,6 +129,8 @@
             objAttr = null;
             objRel = null;
 
+            callbackMethod = null;
+
             dbEntity = null;
             dbAttr = null;
             dbRel = null;
@@ -453,6 +447,27 @@
         return currentState.objRel;
     }
 
+    /**
+     * @return currently selecte entity listener class
+     */
+    public String getCurrentListenerClass() {
+        return currentState.listenerClass;
+    }
+
+    /**
+     * @return currently selected callback type
+     */
+    public CallbackType getCurrentCallbackType() {
+        return currentState.callbackType;
+    }
+
+    /**
+     * @return currently selected callback method
+     */
+    public String getCurrentCallbackMethod() {
+        return currentState.callbackMethod;
+    }
+
     public DbRelationship getCurrentDbRelationship() {
         return currentState.dbRel;
     }
@@ -537,6 +552,46 @@
         listenerList.add(ObjRelationshipListener.class, listener);
     }
 
+    /**
+     * adds callback method manipulation listener
+     * @param listener listener
+     */
+    public void addCallbackMethodListener(CallbackMethodListener listener) {
+        listenerList.add(CallbackMethodListener.class, listener);
+    }
+
+    /**
+     * adds callback type selection listener
+     * @param listener listener
+     */
+    public void addCallbackTypeSelectionListener(CallbackTypeSelectionListener listener) {
+        listenerList.add(CallbackTypeSelectionListener.class, listener);
+    }
+
+    /**
+     * adds listener class selection listener
+     * @param listener listener
+     */
+    public void addListenerClassSelectionListener(ListenerClassSelectionListener listener) {
+        listenerList.add(ListenerClassSelectionListener.class, listener);
+    }
+
+    /**
+     * adds listener class manipulation listener
+     * @param listener listener
+     */
+    public void addEntityListenerListener(EntityListenerListener listener) {
+        listenerList.add(EntityListenerListener.class, listener);
+    }
+
+    /**
+     * adds callback method display listener
+     * @param listener listener
+     */
+    public void addCallbackMethodDisplayListener(CallbackMethodDisplayListener listener) {
+        listenerList.add(CallbackMethodDisplayListener.class, listener);
+    }
+
     public void addObjRelationshipDisplayListener(ObjRelationshipDisplayListener listener) {
         listenerList.add(ObjRelationshipDisplayListener.class, listener);
     }
@@ -1349,6 +1404,121 @@
             }
         }
     }
+
+    /**
+     * fires callback type selection event
+     * @param e event
+     */
+    public void fireCallbackTypeSelectionEvent(CallbackTypeSelectionEvent e) {
+        currentState.callbackType = e.getCallbackType();
+
+        EventListener[] list = listenerList.getListeners(CallbackTypeSelectionListener.class);
+        for (int i = 0; i < list.length; i++) {
+            CallbackTypeSelectionListener temp = (CallbackTypeSelectionListener) list[i];
+            temp.callbackTypeSelected(e);
+        }
+    }
+
+    /**
+     * fires listener class selection event
+     * @param e event
+     */
+    public void fireListenerClassSelectionEvent(ListenerClassSelectionEvent e) {
+        currentState.listenerClass = e.getListenerClass();
+
+        EventListener[] list = listenerList.getListeners(ListenerClassSelectionListener.class);
+        for (int i = 0; i < list.length; i++) {
+            ListenerClassSelectionListener temp = (ListenerClassSelectionListener) list[i];
+            temp.listenerClassSelected(e);
+        }
+    }
+
+    /**
+     * fires callback method manipulation event
+     * @param e event
+     */
+    public void fireCallbackMethodEvent(CallbackMethodEvent e) {
+        setDirty(true);
+
+        //if (currentState.map != null && e.getId() == MapEvent.CHANGE) {
+        //    currentState.map.objRelationshipChanged(e);
+        //}
+
+        EventListener[] list = listenerList.getListeners(CallbackMethodListener.class);
+        for (int i = 0; i < list.length; i++) {
+            CallbackMethodListener temp = (CallbackMethodListener) list[i];
+            switch (e.getId()) {
+                case MapEvent.ADD:
+                    temp.callbackMethodAdded(e);
+                    break;
+                case MapEvent.CHANGE:
+                    temp.callbackMethodChanged(e);
+                    break;
+                case MapEvent.REMOVE:
+                    temp.callbackMethodRemoved(e);
+                    break;
+                default:
+                    throw new IllegalArgumentException("Invalid CallbackEvent type: "
+                            + e.getId());
+            }
+        }
+    }
+
+
+    /**
+     * fires entity listener manipulation event
+     * @param e event
+     */
+    public void fireEntityListenerEvent(EntityListenerEvent e) {
+        setDirty(true);
+
+        EventListener[] list = listenerList.getListeners(EntityListenerListener.class);
+        for (int i = 0; i < list.length; i++) {
+            EntityListenerListener temp = (EntityListenerListener) list[i];
+            switch (e.getId()) {
+                case MapEvent.ADD:
+                    temp.entityListenerAdded(e);
+                    break;
+                case MapEvent.CHANGE:
+                    temp.entityListenerChanged(e);
+                    break;
+                case MapEvent.REMOVE:
+                    temp.entityListenerRemoved(e);
+                    break;
+                default:
+                    throw new IllegalArgumentException("Invalid CallbackEvent type: "
+                            + e.getId());
+            }
+        }
+    }
+
+    /**
+     * fires callback method display event event
+     * @param e event
+     */
+
+    public void fireCallbackMethodDisplayEvent(CallbackMethodDisplayEvent e) {
+        boolean changed;
+
+        if (e.getCallbackMethod() != null) {
+            changed = !e.getCallbackMethod().equals(currentState.callbackMethod);
+        }
+        else {
+            changed = currentState != null;
+        }
+        
+        if (changed) {
+            currentState.callbackMethod = e.getCallbackMethod();
+        }
+
+        EventListener[] list = listenerList
+                .getListeners(CallbackMethodDisplayListener.class);
+        for (int i = 0; i < list.length; i++) {
+            CallbackMethodDisplayListener temp = (CallbackMethodDisplayListener) list[i];
+            temp.currentCallbackMethodCahnged(e);
+        }
+    }
+
 
     public void fireObjRelationshipDisplayEvent(RelationshipDisplayEvent e) {
         boolean changed = e.getRelationship() != currentState.objRel;

Added: 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=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,82 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.modeler.event.CallbackMethodEvent;
+import org.apache.cayenne.modeler.editor.CallbackType;
+import org.apache.cayenne.map.CallbackMap;
+import org.apache.cayenne.map.event.MapEvent;
+
+import java.awt.event.ActionEvent;
+
+/**
+ * Base class for creating callback methods
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 28, 2007
+ */
+public abstract class AbstractCreateCallbackMethodAction extends CayenneAction {
+    /**
+     * default name for new callback method
+     */
+    private static final String NEW_CALLBACK_METHOD = "untitled";
+
+    /**
+     * 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();
+        getCallbackMap().getCallbackDescriptor(callbackType.getType()).addCallbackMethod(NEW_CALLBACK_METHOD);
+
+        CallbackMethodEvent ce = new CallbackMethodEvent(
+                e.getSource(),
+                null,
+                NEW_CALLBACK_METHOD,
+                MapEvent.ADD
+        );
+
+        getProjectController().fireCallbackMethodEvent(ce);
+    }
+}
+

Added: 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=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractRemoveCallbackMethodAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,88 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.modeler.editor.CallbackType;
+import org.apache.cayenne.modeler.event.CallbackMethodEvent;
+import org.apache.cayenne.map.event.MapEvent;
+import org.apache.cayenne.map.CallbackMap;
+
+import java.awt.event.ActionEvent;
+
+/**
+ * Base class for removing callback methofs
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 28, 2007
+ */
+public abstract class AbstractRemoveCallbackMethodAction extends CayenneAction {
+
+    /**
+     * 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
+     */
+    public String getIconName() {
+        return "icon-remove-method.gif";
+    }
+
+    /**
+     * performs callback method removing
+     * @param e event
+     */
+    public final void performAction(ActionEvent e) {
+        if (getProjectController().getCurrentCallbackMethod() != null) {
+            removeCallbackMethod(e);
+        }
+    }
+
+    /**
+     * base logic for callback method removing
+     * @param actionEvent event
+     */
+    private void removeCallbackMethod(ActionEvent actionEvent) {
+        ProjectController mediator = getProjectController();
+        CallbackType callbackType = mediator.getCurrentCallbackType();
+        String callbackMethod = mediator.getCurrentCallbackMethod();
+        getCallbackMap().getCallbackDescriptor(callbackType.getType()).removeCallbackMethod(callbackMethod);
+        CallbackMethodEvent e = new CallbackMethodEvent(
+                actionEvent.getSource(),
+                null,
+                callbackMethod,
+                MapEvent.REMOVE);
+        mediator.fireCallbackMethodEvent(e);
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeDataMapEntityListenerClassAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeDataMapEntityListenerClassAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeDataMapEntityListenerClassAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeDataMapEntityListenerClassAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,71 @@
+/*****************************************************************
+ *   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.modeler.Application;
+
+
+/**
+ * Action class for renaming entity listener class for DataMap
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class ChangeDataMapEntityListenerClassAction extends ChangeObjEntityListenerClassAction {
+    /**
+     * unique action name
+     */
+    private static final String ACTION_NAME = "Change datamap entity listener class";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public ChangeDataMapEntityListenerClassAction(Application application) {
+        super(getActionName(), application);
+    }
+
+    /**
+     * @return unique action name
+     */
+    public static String getActionName() {
+        return ACTION_NAME;
+    }
+
+    /**
+     * checks whether the new name of listener class already exists
+     *
+     * @param className entered class name
+     * @return true or false
+     */
+    protected boolean isListenerClassAlreadyExists(String className) {
+        return getProjectController().getCurrentDataMap().getDefaultEntityListener(className) != null;
+    }
+
+    /**
+     * change entity listener class
+     * @param prevListenerClass previous class name
+     * @param newListenerClass new class name
+     */
+    protected void renameEntityListener(String prevListenerClass, String newListenerClass) {
+        getProjectController().getCurrentDataMap().getDefaultEntityListener(prevListenerClass).setClassName(newListenerClass);
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeObjEntityListenerClassAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeObjEntityListenerClassAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeObjEntityListenerClassAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ChangeObjEntityListenerClassAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,127 @@
+/*****************************************************************
+ *   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.modeler.util.CayenneAction;
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.event.EntityListenerEvent;
+import org.apache.cayenne.map.event.MapEvent;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+
+
+/**
+ * Action class for renaming entity listener class for ObjEntity
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class ChangeObjEntityListenerClassAction extends CayenneAction {
+    /**
+     * unique action name
+     */
+    private static final String ACTION_NAME = "Change objentity entity listener class";
+
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public ChangeObjEntityListenerClassAction(Application application) {
+        super(getActionName(), application);
+    }
+
+    /**
+     * Constructor for extending classes
+     *
+     * @param name unique action name
+     * @param application Application instance
+     */
+    protected ChangeObjEntityListenerClassAction(String name, Application application) {
+        super(name, application);
+    }
+
+    /**
+     * @return unique action name
+     */
+    public static String getActionName() {
+        return ACTION_NAME;
+    }
+
+    /**
+     * @return icon file name for button
+     */
+    public String getIconName() {
+        return "icon-change-listener.gif";
+    }
+
+    /**
+     * checks whether the new name of listener class already exists
+     *
+     * @param className entered class name
+     * @return true or false
+     */
+    protected boolean isListenerClassAlreadyExists(String className) {
+        return getProjectController().getCurrentObjEntity().getEntityListener(className) != null;
+    }
+
+    /**
+     * change entity listener class
+     * @param prevListenerClass previous class name
+     * @param newListenerClass new class name
+     */
+    protected void renameEntityListener(String prevListenerClass, String newListenerClass) {
+        getProjectController().getCurrentObjEntity().getEntityListener(prevListenerClass).setClassName(newListenerClass);
+    }
+
+    /**
+     * base entity listener class renaming logic
+     * @param e event
+     */
+    public void performAction(ActionEvent e) {
+        String currentListenerClass =  getProjectController().getCurrentListenerClass();
+        String newListenerClass = JOptionPane.showInputDialog(
+                "Please enter listener class:",
+                currentListenerClass);
+        if (newListenerClass != null && newListenerClass.trim().length() > 0) {
+            if (isListenerClassAlreadyExists(newListenerClass)) {
+                JOptionPane.showMessageDialog(
+                        null,
+                        "Listener class already exists.",
+                        "Error creating entity listener",
+                        JOptionPane.ERROR_MESSAGE
+                );
+            }
+            else {
+                renameEntityListener(currentListenerClass, newListenerClass);
+                getProjectController().fireEntityListenerEvent(
+                        new EntityListenerEvent(
+                                e.getSource(),
+                                currentListenerClass,
+                                newListenerClass,
+                                MapEvent.ADD
+                        )
+                );
+            }
+        }
+    }
+}
+

Added: 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=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,52 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.map.CallbackMap;
+
+/**
+ * Action class for creating callback methods on ObjEntity
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class CreateCallbackMethodAction extends AbstractCreateCallbackMethodAction {
+    /**
+     * unique action name
+     */
+    public static final String ACTION_NAME = "Create callback method";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public CreateCallbackMethodAction(Application application) {
+        super(ACTION_NAME, application);
+    }
+
+    /**
+     * @return CallbackMap instance where to create a method
+     */
+    public CallbackMap getCallbackMap() {
+        return getProjectController().getCurrentObjEntity().getCallbackMap();
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForDataMapListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForDataMapListenerAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForDataMapListenerAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForDataMapListenerAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,54 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.map.CallbackMap;
+
+
+/**
+ * Action class for creating callback methods on DataMap entity listener
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class CreateCallbackMethodForDataMapListenerAction extends AbstractCreateCallbackMethodAction {
+    /**
+     * unique action name
+     */
+    public static final String ACTION_NAME = "Create callback method for data map entity listener";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public CreateCallbackMethodForDataMapListenerAction(Application application) {
+        super(ACTION_NAME, application);
+    }
+
+    /**
+     * @return CallbackMap instance where to create a method
+     */
+    public CallbackMap getCallbackMap() {
+        String listenerClass = getProjectController().getCurrentListenerClass();
+        return getProjectController().getCurrentDataMap().getDefaultEntityListener(listenerClass).getCallbackMap();
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateCallbackMethodForListenerAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,56 @@
+/*****************************************************************
+ *   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
+ *
+ * @author Vasil Tarasevich
+ * @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();
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapEntityListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapEntityListenerAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapEntityListenerAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateDataMapEntityListenerAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,71 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.map.EntityListener;
+
+
+/**
+ * Action class for creating entity listeners on a DataMap
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class CreateDataMapEntityListenerAction extends CreateObjEntityListenerAction {
+    /**
+     * unique action name
+     */
+    private static final String CREATE_ENTITY_LISTENER = "Create datamap entity listener";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public CreateDataMapEntityListenerAction(Application application) {
+        super(getActionName(), application);
+    }
+
+    /**
+     * @return unique action name
+     */
+    public static String getActionName() {
+        return CREATE_ENTITY_LISTENER;
+    }
+
+    /**
+     * checks whether the new name of listener class already exists
+     *
+     * @param className entered class name
+     * @return true or false
+     */
+    protected boolean isListenerClassAlreadyExists(String className) {
+        return getProjectController().getCurrentDataMap().getDefaultEntityListener(className) != null;
+    }
+
+    /**
+     * adds new entity listener
+     * @param listener new EntityListener instance
+     */
+    protected void addEntityListener(EntityListener listener) {
+        getProjectController().getCurrentDataMap().addDefaultEntityListener(listener);
+    }
+}
+

Added: 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=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityListenerAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CreateObjEntityListenerAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,124 @@
+/*****************************************************************
+ *   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.modeler.util.CayenneAction;
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.event.EntityListenerEvent;
+import org.apache.cayenne.map.EntityListener;
+import org.apache.cayenne.map.event.MapEvent;
+
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+
+
+/**
+ * Action class for creating entity listeners on an ObjEntity
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class CreateObjEntityListenerAction extends CayenneAction {
+    /**
+     * unique action name
+     */
+    private static final String CREATE_ENTITY_LISTENER = "Create objentity entity listener";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public CreateObjEntityListenerAction(Application application) {
+        super(getActionName(), application);
+    }
+
+    /**
+     * Constructor for extending classes.
+     *
+     * @param actionName unique action name
+     * @param application Application instance
+     */
+    protected CreateObjEntityListenerAction(String actionName, Application application) {
+        super(actionName, application);
+    }
+
+    /**
+     * @return unique action name
+     */
+    public static String getActionName() {
+        return CREATE_ENTITY_LISTENER;
+    }
+
+    /**
+     * @return icon file name for button
+     */
+    public String getIconName() {
+        return "icon-create-listener.gif";
+    }
+
+    /**
+     * checks whether the new name of listener class already exists
+     *
+     * @param className entered class name
+     * @return true or false
+     */
+    protected boolean isListenerClassAlreadyExists(String className) {
+        return getProjectController().getCurrentObjEntity().getEntityListener(className) != null;
+    }
+
+    /**
+     * 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:");
+        if (listenerClass != null && listenerClass.trim().length() > 0) {
+            if (isListenerClassAlreadyExists(listenerClass)) {
+                JOptionPane.showMessageDialog(
+                        null,
+                        "Listener class already exists.",
+                        "Error creating entity listener",
+                        JOptionPane.ERROR_MESSAGE
+                );
+            }
+            else {
+                addEntityListener(new EntityListener(listenerClass));
+                getProjectController().fireEntityListenerEvent(
+                        new EntityListenerEvent(
+                                e.getSource(),
+                                listenerClass,
+                                listenerClass,
+                                MapEvent.ADD
+                        )
+                );
+            }
+        }
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,60 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.map.CallbackMap;
+
+
+/**
+ * Action class for removing callback methods from ObjEntity
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class RemoveCallbackMethodAction extends AbstractRemoveCallbackMethodAction {
+    /**
+     * unique action name
+     */
+    public final static String ACTION_NAME = "Remove Callback Method";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public RemoveCallbackMethodAction(Application application) {
+        super(ACTION_NAME, application);
+    }
+
+    /**
+     * @return unique action name
+     */
+    public static String getActionName() {
+        return ACTION_NAME;
+    }
+
+    /**
+     * @return CallbackMap fom which remove callback method
+     */
+    public CallbackMap getCallbackMap() {
+        return getProjectController().getCurrentObjEntity().getCallbackMap();
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForDataMapListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForDataMapListenerAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForDataMapListenerAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForDataMapListenerAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,54 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.map.CallbackMap;
+
+
+/**
+ * Action class for removing callback methods from DataMap's entity listener
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class RemoveCallbackMethodForDataMapListenerAction extends AbstractRemoveCallbackMethodAction {
+    /**
+     * unique action name
+     */
+    public final static String ACTION_NAME = "Remove callback method for data map entity listener";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public RemoveCallbackMethodForDataMapListenerAction(Application application) {
+        super(ACTION_NAME, application);
+    }
+
+    /**
+     * @return CallbackMap fom which remove callback method
+     */
+    public CallbackMap getCallbackMap() {
+        String listenerClass = getProjectController().getCurrentListenerClass();
+        return getProjectController().getCurrentDataMap().getDefaultEntityListener(listenerClass).getCallbackMap();
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveCallbackMethodForListenerAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,56 @@
+/*****************************************************************
+ *   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
+ *
+ * @author Vasil Tarasevich
+ * @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";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public RemoveCallbackMethodForListenerAction(Application application) {
+        super(ACTION_NAME, application);
+    }
+
+    /**
+     * @return CallbackMap fom which remove callback method
+     */
+    public CallbackMap getCallbackMap() {
+        ObjEntity objEnt = getProjectController().getCurrentObjEntity();
+        String listenerClass = getProjectController().getCurrentListenerClass();
+        return objEnt.getEntityListener(listenerClass).getCallbackMap();
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,85 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.modeler.event.EntityListenerEvent;
+import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.event.MapEvent;
+
+import java.awt.event.ActionEvent;
+
+
+/**
+ * Action class for removing entity listeners from an ObjEntity
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class RemoveEntityListenerAction extends CayenneAction {
+    /**
+     * unique action name
+     */
+    private static final String ACTION_NAME = "Remove entity listener";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public RemoveEntityListenerAction(Application application) {
+        super(getActionName(), application);
+    }
+
+    /**
+     * @return unique action name
+     */
+    public static String getActionName() {
+        return ACTION_NAME;
+    }
+
+    /**
+     * @return icon file name for button
+     */
+    public String getIconName() {
+        return "icon-remove-listener.gif";
+    }
+
+    /**
+     * base entity listener removing logic
+     * @param e event
+     */
+    public void performAction(ActionEvent e) {
+        ObjEntity objEnt = getProjectController().getCurrentObjEntity();
+        String listenerClass = getProjectController().getCurrentListenerClass();
+
+        objEnt.removeEntityListener(listenerClass);
+
+        getProjectController().fireEntityListenerEvent(
+                new EntityListenerEvent(
+                        e.getSource(),
+                        listenerClass,
+                        listenerClass,
+                        MapEvent.REMOVE
+                )
+        );
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerForDataMapAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerForDataMapAction.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerForDataMapAction.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveEntityListenerForDataMapAction.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,82 @@
+/*****************************************************************
+ *   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.modeler.Application;
+import org.apache.cayenne.modeler.event.EntityListenerEvent;
+import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.map.event.MapEvent;
+
+import java.awt.event.ActionEvent;
+
+
+/**
+ * Action class for removing entity listeners from a DamaMap
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 30, 2007
+ */
+public class RemoveEntityListenerForDataMapAction extends CayenneAction {
+    /**
+     * unique action name
+     */
+    private static final String ACTION_NAME = "Remove entity listener for data map";
+
+    /**
+     * Constructor.
+     *
+     * @param application Application instance
+     */
+    public RemoveEntityListenerForDataMapAction(Application application) {
+        super(getActionName(), application);
+    }
+
+    /**
+     * @return unique action name
+     */
+    public static String getActionName() {
+        return ACTION_NAME;
+    }
+
+    /**
+     * @return icon file name for button
+     */
+    public String getIconName() {
+        return "icon-remove-listener.gif";
+    }
+    
+    /**
+     * base entity listener removing logic
+     * @param e event
+     */
+    public void performAction(ActionEvent e) {
+        String listenerClass = getProjectController().getCurrentListenerClass();
+        getProjectController().getCurrentDataMap().removeDefaultEntityListener(listenerClass);
+
+        getProjectController().fireEntityListenerEvent(
+                new EntityListenerEvent(
+                        e.getSource(),
+                        listenerClass,
+                        listenerClass,
+                        MapEvent.REMOVE
+                )
+        );
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackListenersTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackListenersTab.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackListenersTab.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackListenersTab.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,198 @@
+/*****************************************************************
+ *   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.editor;
+
+import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.util.CayenneWidgetFactory;
+import org.apache.cayenne.modeler.util.CayenneAction;
+import org.apache.cayenne.modeler.event.ListenerClassSelectionEvent;
+import org.apache.cayenne.modeler.event.EntityListenerEvent;
+import org.apache.cayenne.modeler.event.ListenerClassSelectionListener;
+import org.apache.cayenne.modeler.event.EntityListenerListener;
+import org.apache.cayenne.map.EntityListener;
+
+import javax.swing.*;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.awt.event.ItemListener;
+import java.awt.event.ItemEvent;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+
+
+/**
+ * Base abstract class for editing callback mapping on listener class
+ * Adds entity listener class processing logic
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 29, 2007
+ */
+public abstract class AbstractCallbackListenersTab extends AbstractCallbackMethodsTab
+        implements ListenerClassSelectionListener, EntityListenerListener {
+
+    /**
+     * listener class seiection combo
+     */
+    protected JComboBox listenerClassCombo;
+
+    /**
+     * Constructor
+     * @param mediator mediator instance
+     */
+    protected AbstractCallbackListenersTab(ProjectController mediator) {
+        super(mediator);
+    }
+
+    /**
+     * @return returns entity listeners list
+     */
+    protected abstract List getEntityListeners();
+
+    /**
+     * @return action for removing entity listeners
+     */
+    protected abstract CayenneAction getRemoveEntityListenerAction();
+
+    /**
+     * @return action for creating entity listeners
+     */
+    public abstract CayenneAction getCreateEntityListenerAction();
+
+    /**
+     * @return action for changing entity listeners
+     */
+    public abstract CayenneAction getChangeEntityListenerAction();
+
+    /**
+     * performs GUI components initialization
+     */
+    protected void init() {
+        super.init();
+
+        toolBar.addSeparator();
+        toolBar.add(getCreateEntityListenerAction().buildButton());
+        toolBar.add(getChangeEntityListenerAction().buildButton());
+        toolBar.add(getRemoveEntityListenerAction().buildButton());
+
+        listenerClassCombo.addItemListener(
+                new ItemListener() {
+                    public void itemStateChanged(ItemEvent e) {
+                        if (e.getStateChange() == ItemEvent.SELECTED) {
+                            mediator.fireListenerClassSelectionEvent(
+                                    new ListenerClassSelectionEvent(
+                                            AbstractCallbackListenersTab.this,
+                                            (String)listenerClassCombo.getSelectedItem()
+                                    )
+                            );
+                        }
+                    }
+                }
+        );
+    }
+
+    /**
+     * init listeners
+     */
+    protected void initController() {
+        super.initController();
+        mediator.addListenerClassSelectionListener(this);
+        mediator.addEntityListenerListener(this);
+    }
+
+    /**
+     * rebuils listener class selection dropdown content and fires selection event
+     */
+    protected void rebuildListenerClassCombo() {
+        List entityListeners = getEntityListeners();
+        List listenerClasses = new ArrayList();
+        if (entityListeners !=  null) {
+            for (Iterator i = getEntityListeners().iterator(); i.hasNext();) {
+                EntityListener entityListener = (EntityListener)i.next();
+                listenerClasses.add(entityListener.getClassName());
+            }
+        }
+
+        listenerClassCombo.setModel(
+                new DefaultComboBoxModel(listenerClasses.toArray())
+        );
+
+        mediator.fireListenerClassSelectionEvent(
+                new ListenerClassSelectionEvent(
+                        this,
+                        listenerClassCombo.getItemCount() > 0 ?
+                        (String)listenerClassCombo.getItemAt(0) : null)
+        );
+    }
+
+
+    /**
+     * adds listener class dropdown to filter bar
+     * @param builder filter forms builder
+     */
+    protected void buildFilter(DefaultFormBuilder builder) {
+        listenerClassCombo = CayenneWidgetFactory.createComboBox();
+        builder.append(new JLabel("Listener class:"), listenerClassCombo);
+        builder.nextLine();
+        super.buildFilter(builder);
+    }
+
+    /**
+     * processes adding of new entity listener
+     * @param e event
+     */
+    public void entityListenerAdded(EntityListenerEvent e) {
+        rebuildListenerClassCombo();
+        listenerClassCombo.setSelectedItem(e.getNewName());
+        mediator.fireListenerClassSelectionEvent(
+                new ListenerClassSelectionEvent(
+                        this,
+                        e.getNewName()
+                )
+        );
+    }
+
+    /**
+     * processes renaming of an entity listener
+     * @param e event
+     */
+    public void entityListenerChanged(EntityListenerEvent e) {
+        rebuildListenerClassCombo();
+    }
+
+    /**
+     * processes removing of an entity listener
+     * @param e event
+     */
+    public void entityListenerRemoved(EntityListenerEvent e) {
+        rebuildListenerClassCombo();
+    }
+
+    /**
+     * processes listener class selection
+     * @param e event
+     */
+    public void listenerClassSelected(ListenerClassSelectionEvent e) {
+        if (e.getSource() == this) {
+            rebuildTable();
+            getChangeEntityListenerAction().setEnabled(e.getListenerClass() != null);
+        }
+    }
+}
+

Added: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java?rev=591617&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java (added)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java Sat Nov  3 06:17:28 2007
@@ -0,0 +1,358 @@
+/*****************************************************************
+ *   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.editor;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.FormLayout;
+import org.apache.cayenne.LifecycleListener;
+import org.apache.cayenne.map.*;
+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.CreateCallbackMethodAction;
+import org.apache.cayenne.modeler.action.RemoveCallbackMethodAction;
+import org.apache.cayenne.modeler.editor.StringTransferHandler;
+import org.apache.cayenne.modeler.event.*;
+import org.apache.cayenne.modeler.util.*;
+
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.TableColumn;
+import java.awt.*;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.Iterator;
+import java.util.List;
+
+
+/**
+ * Base abstract class for all calback methids editing tabs
+ * Contains logic for callback methods displaying, creating, removing, esiting, reordering
+ *
+ * @author Vasil Tarasevich
+ * @version 1.0 Oct 23, 2007
+ */
+
+public abstract class AbstractCallbackMethodsTab extends JPanel
+        implements
+            ExistingSelectionProcessor,
+            CallbackMethodListener,
+            CallbackTypeSelectionListener {
+    /**
+     * mediator instance
+     */
+    ProjectController mediator;
+
+    /**
+     * toolbar for actions
+     */
+    protected JToolBar toolBar;
+
+    /**
+     * table for displaying callback method names
+     */
+    protected CayenneTable table;
+
+    /**
+     * Dropdown for callback type selection.
+     * Contains fixed list of 7 callback types.
+     */
+    protected JComboBox callbackTypeCombo = CayenneWidgetFactory.createComboBox(
+            new Object[]{
+                    new CallbackType(LifecycleListener.PRE_PERSIST, "pre-persist"),
+                    new CallbackType(LifecycleListener.POST_PERSIST, "post-persist"),
+                    new CallbackType(LifecycleListener.PRE_UPDATE, "pre-update"),
+                    new CallbackType(LifecycleListener.POST_UPDATE, "post-update"),
+                    new CallbackType(LifecycleListener.PRE_REMOVE, "pre-remove"),
+                    new CallbackType(LifecycleListener.POST_REMOVE, "post-remove"),
+                    new CallbackType(LifecycleListener.POST_LOAD, "post-load"),
+            }, false);
+
+    /**
+     * constructor
+     * @param mediator mediator instance
+     */
+    public AbstractCallbackMethodsTab(ProjectController mediator) {
+        this.mediator = mediator;
+        init();
+        initController();
+    }
+
+    /**
+     * @return CallbackMap with callback methods
+     */
+    protected abstract CallbackMap getCallbackMap();
+
+    /**
+     * creates filter pane for filtering callback methods list
+     * adds callback method type dropdown
+     * @param builder forms builder
+     */
+    protected void buildFilter(DefaultFormBuilder builder) {
+        JLabel callbacktypeLabel = new JLabel("Callback type:");
+        builder.append(callbacktypeLabel, callbackTypeCombo);
+    }
+
+    /**
+     * @return create callback method action
+     */
+    protected CayenneAction getCreateCallbackMethodAction() {
+        Application app = Application.getInstance();
+        return app.getAction(CreateCallbackMethodAction.ACTION_NAME);
+    }
+
+    /**
+     * @return remove callback method action
+     */
+    protected AbstractRemoveCallbackMethodAction getRemoveCallbackMethodAction() {
+        Application app = Application.getInstance();
+        return (AbstractRemoveCallbackMethodAction)app.getAction(RemoveCallbackMethodAction.ACTION_NAME);
+    }
+
+    /**
+     * GUI components initialization
+     */
+    protected void init() {
+        this.setLayout(new BorderLayout());
+
+        toolBar = new JToolBar();
+        toolBar.add(getCreateCallbackMethodAction().buildButton());
+        toolBar.add(getRemoveCallbackMethodAction().buildButton());
+        add(toolBar, BorderLayout.NORTH);
+
+        JPanel auxPanel = new JPanel();
+        auxPanel.setOpaque(false);
+        auxPanel.setLayout(new BorderLayout());
+
+        callbackTypeCombo.addItemListener(
+                new ItemListener() {
+                    public void itemStateChanged(ItemEvent e) {
+                        if (e.getStateChange() == ItemEvent.SELECTED) {
+                            mediator.fireCallbackTypeSelectionEvent(
+                                    new CallbackTypeSelectionEvent(
+                                            e.getSource(),
+                                            (CallbackType)callbackTypeCombo.getSelectedItem())
+                            );
+                        }
+                    }
+                }
+        );
+
+        FormLayout formLayout = new FormLayout("right:70dlu, 3dlu, fill:150dlu");
+        DefaultFormBuilder builder = new DefaultFormBuilder(formLayout);
+        buildFilter(builder);
+        auxPanel.add(builder.getPanel(), BorderLayout.NORTH);
+
+        table = new CayenneTable();
+        table.setDefaultRenderer(String.class, new StringRenderer());
+        table.getTableHeader().setReorderingAllowed(false);
+
+        //drag-and-drop initialization
+        table.setDragEnabled(true);
+        table.setTransferHandler(new StringTransferHandler() {
+            protected String exportString(JComponent c) {
+                JTable table = (JTable)c;
+                int rowIndex = table.getSelectedRow();
+
+                String result = null;
+                if (rowIndex >= 0 && rowIndex < table.getModel().getRowCount()) {
+                    result = String.valueOf(table.getModel().getValueAt(rowIndex, 0));
+                }
+
+                return result;
+            }
+
+            protected void importString(JComponent c, String callbackMethod) {
+                JTable table = (JTable)c;
+                int rowIndex = table.getSelectedRow();
+
+                //move callback method inside of model
+                CallbackDescriptor callbackDescriptor =
+                        getCallbackMap().getCallbackDescriptor(mediator.getCurrentCallbackType().getType());
+                mediator.setDirty(callbackDescriptor.moveMethod(callbackMethod, rowIndex));
+                rebuildTable();
+            }
+
+            protected void cleanup(JComponent c, boolean remove) {
+                //System.out.println("c");
+            }
+        });
+        auxPanel.add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
+
+        add(auxPanel, BorderLayout.CENTER);
+    }
+
+    /**
+     * listeners initialization
+     */
+    protected void initController() {
+        mediator.addCallbackMethodListener(this);
+        mediator.addCallbackTypeSelectionListener(this);
+
+        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
+            public void valueChanged(ListSelectionEvent e) {
+                if (!e.getValueIsAdjusting()) {
+                    processExistingSelection(e);
+                }
+            }
+        });
+    }
+
+    /**
+     * process table selection change
+     * @param e event
+     */
+    public void processExistingSelection(EventObject e) {
+        if (e instanceof ChangeEvent) {
+            table.clearSelection();
+        }
+        String method = null;
+        if (table.getSelectedRow() >= 0) {
+            CallbackDescriptorTableModel model = (CallbackDescriptorTableModel) table.getModel();
+            method = model.getCallbackMethod(table.getSelectedRow());
+            // scroll table
+            UIUtil.scrollToSelectedRow(table);
+        }
+
+        getRemoveCallbackMethodAction().setEnabled(table.getSelectedRow() >= 0);
+
+        CallbackMethodDisplayEvent ev = new CallbackMethodDisplayEvent(e.getSource(), method);
+
+
+        mediator.fireCallbackMethodDisplayEvent(ev);
+    }
+
+    /**
+     * rebuilds table content
+     */
+    protected void rebuildTable() {
+        //System.out.println("RebuildTable: " + this);
+        CallbackType callbackType = mediator.getCurrentCallbackType();
+        List methods = new ArrayList();
+        CallbackDescriptor descriptor = null;
+        CallbackMap callbackMap = getCallbackMap();
+        if (callbackMap != null && callbackType != null) {
+            descriptor = callbackMap.getCallbackDescriptor(callbackType.getType());
+            for (Iterator j = descriptor.getCallbackMethods().iterator(); j.hasNext();) {
+                methods.add(j.next());
+            }
+        }
+
+        final CallbackDescriptorTableModel model = new CallbackDescriptorTableModel(
+                mediator,
+                this,
+                methods,
+                descriptor);
+
+        table.setModel(model);
+        table.setRowHeight(25);
+        table.setRowMargin(3);
+
+        TableColumn methodNameColumn =
+                table.getColumnModel().getColumn(CallbackDescriptorTableModel.METHOD_NAME);
+        methodNameColumn.setMinWidth(424);
+    }
+
+    /**
+     * class for renderig string values
+     */
+    class StringRenderer extends DefaultTableCellRenderer {
+
+        public Component getTableCellRendererComponent(
+                JTable table,
+                Object value,
+                boolean isSelected,
+                boolean hasFocus,
+                int row,
+                int column) {
+
+            // center cardinality column
+            int align = column == ObjRelationshipTableModel.REL_SEMANTICS
+                        ? JLabel.CENTER
+                        : JLabel.LEFT;
+            super.setHorizontalAlignment(align);
+
+            super.getTableCellRendererComponent(
+                    table,
+                    value,
+                    isSelected,
+                    hasFocus,
+                    row,
+                    column);
+
+            ObjRelationshipTableModel model = (ObjRelationshipTableModel) table
+                    .getModel();
+            ObjRelationship relationship = model.getRelationship(row);
+
+            if (relationship != null
+                && relationship.getSourceEntity() != model.getEntity()) {
+                setForeground(Color.GRAY);
+            } else {
+                setForeground(isSelected && !hasFocus
+                              ? table.getSelectionForeground()
+                              : table.getForeground());
+            }
+
+            return this;
+        }
+    }
+
+    /**
+     * processes change of callback method
+     * @param e event
+     */
+    public void callbackMethodChanged(CallbackMethodEvent e) {
+        table.select(e);
+    }
+
+    /**
+     * processes addition of new callback method - rebuilds table
+     * @param e event
+     */
+    public void callbackMethodAdded(CallbackMethodEvent e) {
+        rebuildTable();
+        table.select(e.getNewName());
+    }
+
+    /**
+     * processes removal of a callback method - removes a row from GUI
+     * @param e event
+     */
+    public void callbackMethodRemoved(CallbackMethodEvent e) {
+        CallbackDescriptorTableModel model = (CallbackDescriptorTableModel) table.getModel();
+        int ind = model.getObjectList().indexOf(e.getNewName());
+        model.removeRow(e.getNewName());
+        table.select(ind);
+    }
+
+    /**
+     * rebuilds table according to the newly selected callback type
+      * @param e event
+     */
+    public void callbackTypeSelected(CallbackTypeSelectionEvent e) {
+        rebuildTable();
+    }
+}
+
+



Mime
View raw message