1 7 package org.ejtools.beans; 8 9 import java.beans.PropertyEditor ; 10 import java.beans.PropertyEditorManager ; 11 import java.util.Arrays ; 12 import java.util.Vector ; 13 14 22 public abstract class CustomPropertyEditorManager extends PropertyEditorManager 23 { 24 25 public final static String EDITORS_PACKAGE = "org.ejtools.adwt.editor"; 26 27 28 34 public static synchronized PropertyEditor findEditor(Class clazz) 35 { 36 PropertyEditor result = PropertyEditorManager.findEditor(clazz); 37 38 if (result == null) 41 { 42 Class [] interfaces = clazz.getInterfaces(); 44 for (int i = 0; i < interfaces.length; i++) 45 { 46 Class current = interfaces[i]; 47 result = CustomPropertyEditorManager.findEditor(current); 48 if (result != null) 49 { 50 PropertyEditorManager.registerEditor(clazz, result.getClass()); 51 break; 52 } 53 } 54 } 55 56 return result; 57 } 58 59 60 static 61 { 62 String [] paths = PropertyEditorManager.getEditorSearchPath(); 63 Vector newPaths = new Vector (); 64 newPaths.addAll(Arrays.asList(paths)); 65 if (!newPaths.contains(EDITORS_PACKAGE)) 66 { 67 newPaths.add(EDITORS_PACKAGE); 68 } 69 PropertyEditorManager.setEditorSearchPath((String []) newPaths.toArray(new String [0])); 70 } 71 } 72 | Popular Tags |