1 26 27 package org.objectweb.util.explorer.plugin.java.reflect.swing; 28 29 import java.lang.reflect.Method ; 30 import java.lang.reflect.Modifier ; 31 32 import javax.swing.Icon ; 33 import javax.swing.ImageIcon ; 34 35 import org.objectweb.util.explorer.api.IconProvider; 36 import org.objectweb.util.explorer.core.common.lib.ClassResolver; 37 38 46 public class MethodIconProvider 47 implements IconProvider { 48 49 55 56 protected static Icon publicMethod_, publicAbstractMethod_, publicStaticMethod_, publicFinalMethod_, publicStaticFinalMethod_; 57 58 59 protected static Icon protectedMethod_, protectedAbstractMethod_, protectedStaticMethod_, protectedFinalMethod_, protectedStaticFinalMethod_; 60 61 62 protected static Icon packageMethod_, packageAbstractMethod_, packageStaticMethod_, packageFinalMethod_, packageStaticFinalMethod_; 63 64 65 protected static Icon privateMethod_, privateFinalMethod_; 66 67 73 76 public MethodIconProvider(){ 77 publicMethod_ = new ImageIcon (ClassResolver.getResource("publicMethod.png")); 78 publicAbstractMethod_ = new ImageIcon (ClassResolver.getResource("publicAbstractMethod.png")); 79 publicStaticMethod_ = new ImageIcon (ClassResolver.getResource("publicStaticMethod.png")); 80 publicFinalMethod_ = new ImageIcon (ClassResolver.getResource("publicFinalMethod.png")); 81 publicStaticFinalMethod_ = new ImageIcon (ClassResolver.getResource("publicStaticFinalMethod.png")); 82 protectedMethod_ = new ImageIcon (ClassResolver.getResource("protectedMethod.png")); 83 protectedAbstractMethod_ = new ImageIcon (ClassResolver.getResource("protectedAbstractMethod.png")); 84 protectedStaticMethod_ = new ImageIcon (ClassResolver.getResource("protectedStaticMethod.png")); 85 protectedFinalMethod_ = new ImageIcon (ClassResolver.getResource("protectedFinalMethod.png")); 86 protectedStaticFinalMethod_ = new ImageIcon (ClassResolver.getResource("protectedStaticFinalMethod.png")); 87 privateMethod_ = new ImageIcon (ClassResolver.getResource("privateMethod.png")); 88 privateFinalMethod_ = new ImageIcon (ClassResolver.getResource("privateFinalMethod.png")); 89 packageMethod_ = new ImageIcon (ClassResolver.getResource("packageMethod.png")); 90 packageAbstractMethod_ = new ImageIcon (ClassResolver.getResource("packageAbstractMethod.png")); 91 packageStaticMethod_ = new ImageIcon (ClassResolver.getResource("packageStaticMethod.png")); 92 packageFinalMethod_ = new ImageIcon (ClassResolver.getResource("packageFinalMethod.png")); 93 packageStaticFinalMethod_ = new ImageIcon (ClassResolver.getResource("packageStaticFinalMethod.png")); 94 } 95 96 102 108 111 public Object 112 newIcon(Object object){ 113 Method method_ = (Method )object; 114 int modifier = method_.getModifiers(); 115 if (Modifier.isPrivate(modifier)){ 116 if (Modifier.isFinal(modifier)) 117 return privateFinalMethod_; 118 else 119 return privateMethod_; 120 } else if (Modifier.isProtected(modifier)){ 121 if (Modifier.isAbstract(modifier)) 122 return protectedAbstractMethod_; 123 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 124 return protectedStaticFinalMethod_; 125 else if (Modifier.isStatic(modifier)) 126 return protectedStaticMethod_; 127 else if (Modifier.isFinal(modifier)) 128 return protectedFinalMethod_; 129 else 130 return protectedMethod_; 131 } else if (Modifier.isPublic(modifier)){ 132 if (Modifier.isAbstract(modifier)) 133 return publicAbstractMethod_; 134 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 135 return publicStaticFinalMethod_; 136 else if (Modifier.isStatic(modifier)) 137 return publicStaticMethod_; 138 else if (Modifier.isFinal(modifier)) 139 return publicFinalMethod_; 140 else 141 return publicMethod_; 142 } else if (!Modifier.isPrivate(modifier) && !Modifier.isProtected(modifier) && !Modifier.isPublic(modifier)){ 143 if (Modifier.isAbstract(modifier)) 144 return packageAbstractMethod_; 145 else if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 146 return packageStaticFinalMethod_; 147 else if (Modifier.isStatic(modifier)) 148 return packageStaticMethod_; 149 else if (Modifier.isFinal(modifier)) 150 return packageFinalMethod_; 151 else 152 return packageMethod_; 153 } else { 154 return null; 155 } 156 } 157 158 } | Popular Tags |