Author: kylem
Date: Mon Dec  6 15:16:53 2004
New Revision: 110049

URL: http://svn.apache.org/viewcvs?view=rev&rev=110049
Log:
Incremental changes to support a clean inheritance model for Control interfaces.

Modified:
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java
   
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java?view=diff&rev=110049&p1=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java&r1=110048&p2=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java&r2=110049
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
 (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptControlInterface.java
 Mon Dec  6 15:16:53 2004
@@ -378,7 +378,7 @@
     /**
      * Returns the list of AptEventSet declared directly by this 
AptControlInterface
      */
-    public ArrayList<AptEventSet> getEventSets() { return _eventSets; }
+    public Collection<AptEventSet> getEventSets() { return _eventSets; }
 
     /**
      * Returns the AptEventSet with the specified name

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java?view=diff&rev=110049&p1=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java&r1=110048&p2=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java&r2=110049
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java
 (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/AptEventSet.java
 Mon Dec  6 15:16:53 2004
@@ -19,6 +19,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 
 import com.sun.mirror.apt.AnnotationProcessorEnvironment;
 import com.sun.mirror.declaration.InterfaceDeclaration;
@@ -50,14 +51,50 @@
         _eventSet = eventSet;
         _env = env;
 
-        //
-        // TODO: Identify any super interface for this event set
-        //
-
+        _superEventSet = initSuperEventSet();
         _events = initEvents();
     }
 
     /**
+     * Checks to see if this EventSet extends on declared on a parent control 
interface.  If
+     * found it will return the parent EventSet, or return null if not found. 
+     */
+    public AptEventSet initSuperEventSet()
+    {
+        // This will be common, so short circuit quickly
+        AptControlInterface superControl = _controlIntf.getSuperClass(); 
+        if (superControl == null)
+            return null;
+
+        // Compute a hash set containing the qualified names of all super 
interfaces
+        HashSet<String> extendNames = new HashSet<String>();
+        for (InterfaceType superType: _eventSet.getSuperinterfaces())
+        {
+            InterfaceDeclaration superDecl = superType.getDeclaration();
+            if (superDecl != null)
+                extendNames.add(superDecl.getQualifiedName());
+        }
+
+        // Starting with the parent of the ControlInterface declaring this 
EventSet, look
+        // for a parent interface that declares ones of these super interfaces 
as an event
+        // set
+        while (superControl != null)
+        {
+            Collection<AptEventSet> superEventSets = 
superControl.getEventSets();
+            for (AptEventSet superEventSet : superEventSets)
+            {
+                if (extendNames.contains(superEventSet.getName()))
+                    return superEventSet;
+            }
+
+            superControl = superControl.getSuperClass();
+        }
+
+        // Nothing found, so no super event set
+        return null;
+    }
+
+    /**
      * Initializes the list of Events associated with this EventSet
      */
     protected AptMethodSet<AptEvent> initEvents()
@@ -76,7 +113,12 @@
         {
             InterfaceDeclaration intfDecl = intfList.get(i);
 
-            // TODO: Ignore the superinterface (if any) and continue here
+            //
+            // Don't add events that are derived from a super event set.
+            //
+            if (_superEventSet != null &&
+                _superEventSet.getName().equals(intfDecl.getQualifiedName()))
+                continue;
 
             //
             // Add all declared methods on the current interface
@@ -152,10 +194,16 @@
     public String getNotifierExtends()
     {
         //
-        // TODO: Add a model for how one event set can extend another
-        // return superClass().getNotifierClass();
+        // All EventNotifiers are rooted from a common utility class, so if 
there is no
+        // super event set, then extend the utility notifier class.
+        //
+        if (_superEventSet == null)
+            return "org.apache.beehive.controls.runtime.bean.EventNotifier";
+
+        //
+        // Otherwise, a generated notifier will extend the notifier of any 
parent event set
         //
-        return "extends 
org.apache.beehive.controls.runtime.bean.EventNotifier";
+        return _superEventSet.getNotifierClass();
     }
 
     /**
@@ -197,6 +245,7 @@
 
     private AnnotationProcessorEnvironment  _env;
     private InterfaceDeclaration            _eventSet;
+    private AptEventSet                     _superEventSet;
     private AptControlInterface             _controlIntf;
     private AptMethodSet<AptEvent>          _events;
 }

Modified: 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
Url: 
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm?view=diff&rev=110049&p1=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm&r1=110048&p2=incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm&r2=110049
==============================================================================
--- 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
   (original)
+++ 
incubator/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/ControlBean.vm
   Mon Dec  6 15:16:53 2004
@@ -322,7 +322,7 @@
      * This inner class implements a simple proxy to deliver 
$eventSet.shortName events 
      * back to a register listener.
      */
-    protected class $eventSet.notifierClass $eventSet.notifierExtends
+    protected class $eventSet.notifierClass extends $eventSet.notifierExtends
         implements $eventSet.shortName, java.io.Serializable
     {
         #foreach ($eventMethod in $eventSet.events)

Reply via email to