1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.editors; 26 27 import java.awt.Color ; 28 import java.awt.Component ; 29 import java.awt.Graphics ; 30 import java.awt.Rectangle ; 31 import java.awt.FontMetrics ; 32 33 import javax.swing.JPanel ; 34 35 import java.beans.PropertyEditorSupport ; 36 37 import org.openide.explorer.propertysheet.ExPropertyEditor; 38 import org.openide.explorer.propertysheet.PropertyEnv; 39 40 import org.netbeans.modules.j2ee.sun.dd.api.web.WebProperty; 41 42 43 45 49 public class DummyPropertyEditor extends PropertyEditorSupport implements ExPropertyEditor { 50 51 private WebProperty curValue; 52 53 public DummyPropertyEditor() { 54 curValue = null; 55 } 56 57 public DummyPropertyEditor(WebProperty object) { 58 curValue = object; 59 } 60 61 public String getAsText() { 62 return null; 63 } 64 65 public void setAsText(String text) { 66 throw new IllegalArgumentException (); 67 } 68 69 public void setValue(Object value) { 70 if(value == null) { 71 curValue = null; 72 return; 73 } 74 75 if(value instanceof WebProperty) { 76 curValue = (WebProperty) value; 77 } else if(curValue != null) { 78 curValue.setDescription(value.toString()); 79 } 80 } 81 82 public Object getValue () { 83 return curValue; 84 } 85 86 public String getJavaInitializationString() { 87 return getAsText(); 88 } 89 90 public String [] getTags() { 91 return null; 92 } 93 94 public Component getInPlaceCustomEditor() { 95 return null; 96 } 97 98 public boolean hasInPlaceCustomEditor() { 99 return false; 100 } 101 102 protected String getPaintableString() { 103 if(curValue == null) { 104 return "(null)"; 105 } else { 106 return curValue.toString(); 107 } 108 } 109 110 public boolean isPaintable() { 111 return true; 112 } 113 114 public void paintValue(Graphics gfx, Rectangle box) { 115 FontMetrics fm = gfx.getFontMetrics(); 116 gfx.setColor(Color.red); 117 gfx.drawString(getPaintableString(), 4, (box.height - fm.getHeight()) / 2 + 1 + fm.getMaxAscent()); 118 } 119 120 public boolean supportsCustomEditor() { 121 return true; 122 } 123 124 public Component getCustomEditor () { 125 return new JPanel (); 127 } 128 129 132 private PropertyEnv myPropertyEnv = null; 133 134 public void attachEnv(PropertyEnv env) { 135 myPropertyEnv = env; 136 } 137 } 138 | Popular Tags |