1 26 27 package org.objectweb.util.explorer.plugin.java.reflect.swing; 28 29 import java.lang.reflect.Field ; 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 FieldIconProvider 47 implements IconProvider { 48 49 55 56 protected static Icon publicField_, publicStaticField_, publicFinalField_, publicStaticFinalField_; 57 58 59 protected static Icon protectedField_, protectedStaticField_, protectedFinalField_, protectedStaticFinalField_; 60 61 62 protected static Icon packageField_, packageStaticField_, packageFinalField_, packageStaticFinalField_; 63 64 65 protected static Icon privateField_, privateFinalField_; 66 67 73 76 public FieldIconProvider(){ 77 publicField_ = new ImageIcon (ClassResolver.getResource("publicField.png")); 78 publicStaticField_ = new ImageIcon (ClassResolver.getResource("publicStaticField.png")); 79 publicFinalField_ = new ImageIcon (ClassResolver.getResource("publicFinalField.png")); 80 publicStaticFinalField_ = new ImageIcon (ClassResolver.getResource("publicStaticFinalField.png")); 81 protectedField_ = new ImageIcon (ClassResolver.getResource("protectedField.png")); 82 protectedStaticField_ = new ImageIcon (ClassResolver.getResource("protectedStaticField.png")); 83 protectedFinalField_ = new ImageIcon (ClassResolver.getResource("protectedFinalField.png")); 84 protectedStaticFinalField_ = new ImageIcon (ClassResolver.getResource("protectedStaticFinalField.png")); 85 privateField_ = new ImageIcon (ClassResolver.getResource("privateField.png")); 86 privateFinalField_ = new ImageIcon (ClassResolver.getResource("privateFinalField.png")); 87 packageField_ = new ImageIcon (ClassResolver.getResource("packageField.png")); 88 packageStaticField_ = new ImageIcon (ClassResolver.getResource("packageStaticField.png")); 89 packageFinalField_ = new ImageIcon (ClassResolver.getResource("packageFinalField.png")); 90 packageStaticFinalField_ = new ImageIcon (ClassResolver.getResource("packageStaticFinalField.png")); 91 } 92 93 99 105 108 public Object 109 newIcon(Object object){ 110 Field field_ = (Field )object; 111 int modifier = field_.getModifiers(); 112 if (Modifier.isPrivate(modifier)){ 113 if (Modifier.isFinal(modifier)) 114 return privateFinalField_; 115 else 116 return privateField_; 117 } else if (Modifier.isProtected(modifier)){ 118 if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 119 return protectedStaticFinalField_; 120 else if (Modifier.isStatic(modifier)) 121 return protectedStaticField_; 122 else if (Modifier.isFinal(modifier)) 123 return protectedFinalField_; 124 else 125 return protectedField_; 126 } else if (Modifier.isPublic(modifier)){ 127 if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 128 return publicStaticFinalField_; 129 else if (Modifier.isStatic(modifier)) 130 return publicStaticField_; 131 else if (Modifier.isFinal(modifier)) 132 return publicFinalField_; 133 else 134 return publicField_; 135 } else if (!Modifier.isPrivate(modifier) && !Modifier.isProtected(modifier) && !Modifier.isPublic(modifier)) { 136 if (Modifier.isStatic(modifier) && Modifier.isFinal(modifier)) 137 return packageStaticFinalField_; 138 else if (Modifier.isStatic(modifier)) 139 return packageStaticField_; 140 else if (Modifier.isFinal(modifier)) 141 return packageFinalField_; 142 else 143 return packageField_; 144 } else { 145 return null; 146 } 147 } 148 149 } | Popular Tags |