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 BUTTON implements ActiveEditorDrop { 32 33 public static final String TYPE_SUBMIT = "submit"; public static final String TYPE_RESET = "reset"; public static final String TYPE_BUTTON = "button"; 37 private String value = ""; 38 private String type = TYPE_SUBMIT; 39 private boolean disabled = false; 40 private String name = ""; 41 42 public BUTTON() { 43 } 44 45 public boolean handleTransfer(JTextComponent targetComponent) { 46 47 BUTTONCustomizer c = new BUTTONCustomizer(this); 48 boolean accept = c.showDialog(); 49 if (accept) { 50 String body = createBody(); 51 try { 52 HTMLPaletteUtilities.insert(body, targetComponent); 53 } catch (BadLocationException ble) { 54 accept = false; 55 } 56 } 57 58 return accept; 59 } 60 61 private String createBody() { 62 63 String strType = " type=\"" + type + "\""; 65 String strValue = " value=\"" + value + "\""; 67 String strName = ""; 68 if (name.length() > 0) 69 strName = " name=\"" + name + "\""; 71 String strDisabled = (disabled ? " disabled=\"disabled\"" : ""); 73 String inputBody = "<input" + strType + strValue + strName + strDisabled + " />"; 75 return inputBody; 76 } 77 78 public String getValue() { 79 return value; 80 } 81 82 public void setValue(String value) { 83 this.value = value; 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 boolean isDisabled() { 95 return disabled; 96 } 97 98 public void setDisabled(boolean disabled) { 99 this.disabled = disabled; 100 } 101 102 public String getName() { 103 return name; 104 } 105 106 public void setName(String name) { 107 this.name = name; 108 } 109 110 } 111 | Popular Tags |