cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r592665 - in /cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler: action/ editor/
Date Wed, 07 Nov 2007 09:22:51 GMT
Author: aadamchik
Date: Wed Nov  7 01:22:50 2007
New Revision: 592665

URL: http://svn.apache.org/viewvc?rev=592665&view=rev
Log:
CAY-900 Create CayenneModeler Swing UI for managing callbacks and lifecycle listeners
(final cleanup - patch#4)

Modified:
    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/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/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/ObjEntityCallbackListenersTab.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackMethodsTab.java

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java?rev=592665&r1=592664&r2=592665&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/AbstractCreateCallbackMethodAction.java
Wed Nov  7 01:22:50 2007
@@ -67,12 +67,21 @@
      */
     public final void performAction(ActionEvent e) {
         CallbackType callbackType = getProjectController().getCurrentCallbackType();
-        getCallbackMap().getCallbackDescriptor(callbackType.getType()).addCallbackMethod(NEW_CALLBACK_METHOD);
+
+        //generate methodName
+        int counter = 1;
+        String methodName;
+        do {
+            methodName = NEW_CALLBACK_METHOD + counter;
+            counter++;
+        } while(getCallbackMap().getCallbackDescriptor(callbackType.getType()).getCallbackMethods().contains(methodName));
+
+        getCallbackMap().getCallbackDescriptor(callbackType.getType()).addCallbackMethod(methodName);
 
         CallbackMethodEvent ce = new CallbackMethodEvent(
                 e.getSource(),
                 null,
-                NEW_CALLBACK_METHOD,
+                methodName,
                 MapEvent.ADD
         );
 

Modified: 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=592665&r1=592664&r2=592665&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackListenersTab.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackListenersTab.java
Wed Nov  7 01:22:50 2007
@@ -113,6 +113,7 @@
                     public void componentShown(ComponentEvent e) {
                         rebuildListenerClassCombo(null);
                         mediator.setCurrentCallbackType((CallbackType)callbackTypeCombo.getSelectedItem());
+                        updateCallbackTypeCounters();
                         rebuildTable();
                     }
                 }
@@ -131,6 +132,7 @@
                             else {
                                 //just celeection changed
                                 mediator.setCurrentListenerClass((String)listenerClassCombo.getSelectedItem());
+                                updateCallbackTypeCounters();
                                 rebuildTable();
                             }
                         }

Modified: 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=592665&r1=592664&r2=592665&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/AbstractCallbackMethodsTab.java
Wed Nov  7 01:22:50 2007
@@ -197,12 +197,14 @@
 
                     public void callbackMethodAdded(CallbackMethodEvent e) {
                         if (isVisible()) {
+                            updateCallbackTypeCounters();
                             rebuildTable();
                         }
                     }
 
                     public void callbackMethodRemoved(CallbackMethodEvent e) {
                         if (isVisible()) {
+                            updateCallbackTypeCounters();
                             rebuildTable();
                         }
                     }
@@ -214,6 +216,7 @@
                     public void itemStateChanged(ItemEvent e) {
                         if (e.getStateChange() == ItemEvent.SELECTED) {
                             mediator.setCurrentCallbackType((CallbackType)callbackTypeCombo.getSelectedItem());
+                            updateCallbackTypeCounters();
                             rebuildTable();
                         }
                     }
@@ -230,6 +233,24 @@
                 }
             }
         });
+    }
+
+    protected void updateCallbackTypeCounters() {
+        CallbackMap map = getCallbackMap();
+        
+        for (int i = 0; i < callbackTypeCombo.getItemCount(); i++) {
+            CallbackType type = (CallbackType) callbackTypeCombo.getItemAt(i);
+
+            if (map == null) {
+                type.setCounter(0);
+            }
+            else {
+                CallbackDescriptor callbackDescriptor = map.getCallbackDescriptor(type
+                        .getType());
+                type.setCounter(callbackDescriptor.getCallbackMethods().size());
+            }
+        }
+        callbackTypeCombo.repaint();
     }
 
 

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java?rev=592665&r1=592664&r2=592665&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/CallbackType.java
Wed Nov  7 01:22:50 2007
@@ -39,6 +39,11 @@
     private String name;
 
     /**
+     * methods counter
+     */
+    private int counter;
+
+    /**
      * constructor
      * @param type type id
      * @param name name
@@ -46,6 +51,7 @@
     public CallbackType(int type, String name) {
         this.type = type;
         this.name = name;
+        this.counter = 0;
     }
 
     /**
@@ -63,10 +69,33 @@
     }
 
     /**
-     * @return callback name
+     * @return number of callback methods of this type.
+     */
+    public int getCounter() {
+        return counter;
+    }
+
+    /**
+     * Method to specify counter value
+     * @param counter new coutner value
+     */
+    public void setCounter(int counter) {
+        this.counter = counter;
+    }
+
+    /**
+     * @return a human readable label representing for this callback. 
      */
     public String toString() {
-        return name;
+        if (counter <= 0) {
+            return name;
+        }
+        else if (counter == 1) {
+            return name + " (1 method)";
+        }
+        else {
+            return name + " (" + counter + " methods)";
+        }
     }
 
     public boolean equals(Object o) {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapCallbackListenersTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapCallbackListenersTab.java?rev=592665&r1=592664&r2=592665&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapCallbackListenersTab.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapCallbackListenersTab.java
Wed Nov  7 01:22:50 2007
@@ -77,6 +77,7 @@
                     public void currentDataMapChanged(DataMapDisplayEvent e) {
                         if (isVisible()) {
                             rebuildListenerClassCombo(null);
+                            updateCallbackTypeCounters();
                             mediator.setCurrentCallbackType((CallbackType)callbackTypeCombo.getSelectedItem());
                             rebuildTable();
                         }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackListenersTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackListenersTab.java?rev=592665&r1=592664&r2=592665&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackListenersTab.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackListenersTab.java
Wed Nov  7 01:22:50 2007
@@ -67,6 +67,7 @@
                     public void currentObjEntityChanged(EntityDisplayEvent e) {
                         if (ObjEntityCallbackListenersTab.this.isVisible()) {
                             rebuildListenerClassCombo(null);
+                            updateCallbackTypeCounters();
                             mediator.setCurrentCallbackType((CallbackType)callbackTypeCombo.getSelectedItem());
                             rebuildTable();
                         }

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackMethodsTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackMethodsTab.java?rev=592665&r1=592664&r2=592665&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackMethodsTab.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityCallbackMethodsTab.java
Wed Nov  7 01:22:50 2007
@@ -53,6 +53,7 @@
                 new ComponentAdapter() {
                     public void componentShown(ComponentEvent e) {
                         mediator.setCurrentCallbackType((CallbackType)callbackTypeCombo.getSelectedItem());
+                        updateCallbackTypeCounters();
                         rebuildTable();
                     }
                 }
@@ -63,6 +64,7 @@
                     public void currentObjEntityChanged(EntityDisplayEvent e) {
                         if (ObjEntityCallbackMethodsTab.this.isVisible()) {
                             mediator.setCurrentCallbackType((CallbackType)callbackTypeCombo.getSelectedItem());
+                            updateCallbackTypeCounters();
                             rebuildTable();
                         }
                     }



Mime
View raw message