Author: ruschein
Date: 2010-08-16 13:29:27 -0700 (Mon, 16 Aug 2010)
New Revision: 21395

Modified:
   
core3/work-api/trunk/src/main/java/org/cytoscape/work/AbstractTunableInterceptor.java
Log:
Added support for intercepting @ProvidesGUI-annotated methods.

Modified: 
core3/work-api/trunk/src/main/java/org/cytoscape/work/AbstractTunableInterceptor.java
===================================================================
--- 
core3/work-api/trunk/src/main/java/org/cytoscape/work/AbstractTunableInterceptor.java
       2010-08-16 09:22:06 UTC (rev 21394)
+++ 
core3/work-api/trunk/src/main/java/org/cytoscape/work/AbstractTunableInterceptor.java
       2010-08-16 20:29:27 UTC (rev 21395)
@@ -36,6 +36,8 @@
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+import javax.swing.JPanel;
+
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -207,8 +209,8 @@
                                                ex.printStackTrace();
                                        }
                                } else if 
(method.isAnnotationPresent(ProvidesGUI.class)) {
-                                       if (method.getReturnType() != 
void.class)
-                                               logger.error(method.getName() + 
" annotated with @ProvidesGUI must return void!");
+                                       if 
(!isJPanelOrJPanelDescendent(method.getReturnType()))
+                                               logger.error(method.getName() + 
" annotated with @ProvidesGUI must return JPanel!");
                                        else if 
(method.getParameterTypes().length != 0)
                                                logger.error(method.getName() + 
" annotated with @ProvidesGUI must take 0 arguments!");
                                        else {
@@ -224,6 +226,17 @@
                }
        }
 
+       private boolean isJPanelOrJPanelDescendent(final Class c) {
+               Class c0 = c;
+               do {
+                       if (c0 == JPanel.class)
+                               return true;
+                       c0 = c0.getSuperclass();
+               } while (c0 != Object.class);
+
+               return false;
+       }
+
        private boolean isValidGetter(final Method getterCandidate) {
                // Make sure we're not returning "void":
                try {

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to