1 19 20 package org.netbeans.beaninfo.editors; 21 22 import java.beans.*; 23 import java.text.MessageFormat ; 24 import org.netbeans.core.UIExceptions; 25 import org.openide.explorer.propertysheet.ExPropertyEditor; 26 import org.openide.explorer.propertysheet.PropertyEnv; 27 import org.openide.util.NbBundle; 28 29 35 public abstract class WrappersEditor implements ExPropertyEditor { 36 37 protected PropertyEditor pe = null; 38 39 public WrappersEditor(Class type) { 40 super(); 41 pe = PropertyEditorManager.findEditor(type); 42 } 43 44 public void setValue(Object newValue) throws IllegalArgumentException { 45 pe.setValue(newValue); 46 } 47 48 public Object getValue() { 49 return pe.getValue(); 50 } 51 52 public boolean isPaintable() { 53 return pe.isPaintable(); 54 } 55 56 public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) { 57 pe.paintValue(gfx, box); 58 } 59 60 public String getAsText () { 61 if ( pe.getValue() == null ) 62 return "null"; return pe.getAsText(); 64 } 65 66 public void setAsText(String text) throws IllegalArgumentException { 67 if ( "null".equals( text ) ) return; 69 try { 70 pe.setAsText(text); 71 } catch (Exception e) { 72 IllegalArgumentException iae = new IllegalArgumentException (e.getMessage()); 74 String msg = e.getLocalizedMessage(); 75 if (msg == null || e.getMessage().equals(msg)) { 76 msg = MessageFormat.format( 77 NbBundle.getMessage( 78 WrappersEditor.class, "FMT_EXC_GENERIC_BAD_VALUE"), text); } 80 UIExceptions.annotateUser(iae, iae.getMessage(), msg, e, 81 new java.util.Date ()); 82 throw iae; 83 } 84 } 85 86 public String [] getTags() { 87 return pe.getTags(); 88 } 89 90 public java.awt.Component getCustomEditor() { 91 return pe.getCustomEditor(); 92 } 93 94 public boolean supportsCustomEditor() { 95 return pe.supportsCustomEditor(); 96 } 97 98 public synchronized void addPropertyChangeListener(PropertyChangeListener listener) { 99 pe.addPropertyChangeListener(listener); 100 } 101 102 public synchronized void removePropertyChangeListener(PropertyChangeListener listener) { 103 pe.removePropertyChangeListener(listener); 104 } 105 106 public void attachEnv(PropertyEnv env) { 107 if (pe instanceof ExPropertyEditor) { 110 ((ExPropertyEditor) pe).attachEnv (env); 111 } 112 } 113 } 114 | Popular Tags |