harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r557462 - in /harmony/enhanced/classlib/trunk/modules/beans: META-INF/MANIFEST.MF src/main/java/java/beans/StandardBeanInfo.java src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
Date Thu, 19 Jul 2007 02:27:43 GMT
Author: tonywu
Date: Wed Jul 18 19:27:42 2007
New Revision: 557462

URL: http://svn.apache.org/viewvc?view=rev&rev=557462
Log:
new feature for getIcon

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF?view=diff&rev=557462&r1=557461&r2=557462
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/META-INF/MANIFEST.MF Wed Jul 18 19:27:42
2007
@@ -16,6 +16,7 @@
  java.awt.dnd,
  java.awt.event;resolution:=optional,
  java.awt.font,
+ java.awt.image,
  java.io,
  java.lang,
  java.lang.reflect,

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java?view=diff&rev=557462&r1=557461&r2=557462
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/StandardBeanInfo.java
Wed Jul 18 19:27:42 2007
@@ -17,6 +17,9 @@
 
 package java.beans;
 
+import static java.beans.Introspector.decapitalize;
+
+import java.awt.Image;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
@@ -28,8 +31,6 @@
 import java.util.Iterator;
 import java.util.TooManyListenersException;
 
-import static java.beans.Introspector.decapitalize;
-
 class StandardBeanInfo extends SimpleBeanInfo {
     
 
@@ -71,15 +72,12 @@
 
     private static PropertyComparator comparator = new PropertyComparator();
 
-    StandardBeanInfo(Class beanClass) {
-        super();
-        this.beanClass = beanClass;
-
-    }
+	private Image[] icon = new Image[4];
     
     StandardBeanInfo(Class beanClass,
             BeanInfo explicitBeanInfo) throws IntrospectionException {
-        this(beanClass);
+		assert (beanClass != null);
+		this.beanClass = beanClass;
         /*--------------------------------------------------------------------------------------
          * There are 3 aspects of BeanInfo that must be supplied:
          * a) PropertyDescriptors
@@ -105,6 +103,9 @@
             this.defaultEventIndex = explicitBeanInfo.getDefaultEventIndex();
             this.defaultPropertyIndex = explicitBeanInfo.getDefaultPropertyIndex();
             additionalBeanInfo = explicitBeanInfo.getAdditionalBeanInfo();
+			for (int i = 0; i < 4; i++) {
+				icon[i] = explicitBeanInfo.getIcon(i + 1);
+			}
             
             if (events != null)
                 explicitEvents = true;
@@ -166,6 +167,9 @@
         return this.defaultPropertyIndex;
     }
     
+	public Image getIcon(int iconKind) {
+		return icon[iconKind - 1];
+	}
     
     void mergeBeanInfo(BeanInfo superBeanInfo, boolean force) throws IntrospectionException{
         if(force){

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java?view=diff&rev=557462&r1=557461&r2=557462
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
Wed Jul 18 19:27:42 2007
@@ -17,6 +17,8 @@
 
 package org.apache.harmony.beans.tests.java.beans;
 
+import java.awt.Image;
+import java.awt.image.BufferedImage;
 import java.beans.BeanDescriptor;
 import java.beans.BeanInfo;
 import java.beans.EventSetDescriptor;
@@ -2050,5 +2052,118 @@
         public void setName(int i) {
             a = i;
         }
+    }
+    static class MockBaseClassForPorperties {
+        int a = 0;
+
+        int b = 1;
+    }
+
+    static class MockSubClassForPorperties extends MockBaseClassForPorperties {
+        int a = 2;
+
+        int b = 3;
+
+        int c = 3;
+
+        public int getName() {
+            return a;
+        }
+
+        public void setName(int i) {
+            a = i;
+        }
+    }
+
+    public void testGetIcon() throws IntrospectionException {
+        Class<MockSubClassForPorperties> beanClass = MockSubClassForPorperties.class;
+        BeanInfo info = Introspector.getBeanInfo(beanClass);
+        assertNotNull(info.getIcon(BeanInfo.ICON_COLOR_16x16));
+    }
+
+    public static class MockBaseClassForPorpertiesBeanInfo extends
+            SimpleBeanInfo {
+
+        @Override
+        public MethodDescriptor[] getMethodDescriptors() {
+            MethodDescriptor md = null;
+            try {
+                Class<MockSubClassForPorperties> clz = MockSubClassForPorperties.class;
+                Method m = clz.getMethod("getName", new Class[] {});
+                md = new MethodDescriptor(m);
+            } catch (Exception e) {
+
+            }
+            return new MethodDescriptor[] { md };
+        }
+
+        @Override
+        public PropertyDescriptor[] getPropertyDescriptors() {
+            PropertyDescriptor[] pds = new PropertyDescriptor[2];
+            Class<MockSubClassForPorperties> clazz = MockSubClassForPorperties.class;
+            try {
+                Method getter = clazz.getMethod("getName");
+                Method setter = clazz.getMethod("setName", Integer.TYPE);
+                pds[0] = new PropertyDescriptor("a", getter, setter);
+                pds[0].setConstrained(true);
+                pds[0].setBound(true);
+                pds[0].setExpert(true);
+                pds[0].setHidden(true);
+                pds[1] = new PropertyDescriptor("b", getter, setter);
+            } catch (IntrospectionException e) {
+                e.printStackTrace();
+            } catch (SecurityException e) {
+                e.printStackTrace();
+            } catch (NoSuchMethodException e) {
+                e.printStackTrace();
+            }
+
+            return pds;
+        }
+
+        public Image getIcon(int iconKind) {
+            return null;
+        }
+    }
+
+    public static class MockSubClassForPorpertiesBeanInfo extends
+            SimpleBeanInfo {
+
+        @Override
+        public MethodDescriptor[] getMethodDescriptors() {
+            MethodDescriptor md = null;
+            try {
+                Class<MockSubClassForPorperties> clz = MockSubClassForPorperties.class;
+                Method m = clz.getMethod("getName", new Class[] {});
+                md = new MethodDescriptor(m);
+            } catch (Exception e) {
+
+            }
+            return new MethodDescriptor[] { md };
+        }
+
+        @Override
+        public PropertyDescriptor[] getPropertyDescriptors() {
+            PropertyDescriptor[] pds = new PropertyDescriptor[2];
+            Class<MockSubClassForPorperties> clazz = MockSubClassForPorperties.class;
+            try {
+                Method getter = clazz.getMethod("getName");
+                Method setter = clazz.getMethod("setName", Integer.TYPE);
+                pds[0] = new PropertyDescriptor("a", getter, setter);
+                pds[1] = new PropertyDescriptor("b", getter, setter);
+            } catch (IntrospectionException e) {
+                e.printStackTrace();
+            } catch (SecurityException e) {
+                e.printStackTrace();
+            } catch (NoSuchMethodException e) {
+                e.printStackTrace();
+            }
+            return pds;
+        }
+
+        public Image getIcon(int iconKind) {
+            return new BufferedImage(16, 16, 1);
+        }
+
     }
 }



Mime
View raw message