1 19 20 package org.netbeans.modules.html.palette.items; 21 import javax.swing.text.BadLocationException ; 22 import javax.swing.text.JTextComponent ; 23 import org.netbeans.modules.html.palette.HTMLPaletteUtilities; 24 import org.openide.text.ActiveEditorDrop; 25 26 27 31 public class INPUT implements ActiveEditorDrop { 32 33 public static final String TYPE_TEXT = "text"; public static final String TYPE_PASS = "password"; public static final String TYPE_HIDDEN = "hidden"; public static final String STATE_DISABLED = "disabled"; public static final String STATE_READONLY = "readonly"; 39 private String name = ""; 40 private String value = ""; 41 private String type = TYPE_TEXT; 42 private boolean disabled = false; 43 private boolean hidden = false; 44 private boolean readonly = false; 45 private String width = ""; 46 47 public INPUT() { 48 } 49 50 public boolean handleTransfer(JTextComponent targetComponent) { 51 52 INPUTCustomizer c = new INPUTCustomizer(this); 53 boolean accept = c.showDialog(); 54 if (accept) { 55 String body = createBody(); 56 try { 57 HTMLPaletteUtilities.insert(body, targetComponent); 58 } catch (BadLocationException ble) { 59 accept = false; 60 } 61 } 62 63 return accept; 64 } 65 66 private String createBody() { 67 68 String strType = " type=\"" + type + "\""; 70 String strName = " name=\"" + name + "\""; 72 String strValue = " value=\"" + value + "\""; 74 String strReadOnly = (readonly ? " readonly=\"readonly\"" : ""); String strDisabled = (disabled ? " disabled=\"disabled\"" : ""); 77 String strWidth = ""; 78 if (width.length() > 0) 79 strWidth = " size=\"" + width + "\""; 81 String inputBody = "<input" + strType + strName + strValue + strWidth + strReadOnly + strDisabled + " />"; 83 return inputBody; 84 } 85 86 public String getType() { 87 return type; 88 } 89 90 public void setType(String type) { 91 this.type = type; 92 } 93 94 public String getName() { 95 return name; 96 } 97 98 public void setName(String name) { 99 this.name = name; 100 } 101 102 public String getValue() { 103 return value; 104 } 105 106 public void setValue(String value) { 107 this.value = value; 108 } 109 110 public boolean isDisabled() { 111 return disabled; 112 } 113 114 public void setDisabled(boolean disabled) { 115 this.disabled = disabled; 116 } 117 118 public boolean isHidden() { 119 return hidden; 120 } 121 122 public void setHidden(boolean hidden) { 123 this.hidden = hidden; 124 } 125 126 public String getWidth() { 127 return width; 128 } 129 130 public void setWidth(String width) { 131 this.width = width; 132 } 133 134 public boolean isReadonly() { 135 return readonly; 136 } 137 138 public void setReadonly(boolean readonly) { 139 this.readonly = readonly; 140 } 141 142 } 143 | Popular Tags |