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 CHECKBOX implements ActiveEditorDrop { 32 33 public static final String VALUE_DEFAULT = "ON"; 35 private String name = ""; 36 private String value = VALUE_DEFAULT; 37 private boolean selected = false; 38 private boolean disabled = false; 39 40 public CHECKBOX() { 41 } 42 43 public boolean handleTransfer(JTextComponent targetComponent) { 44 45 CHECKBOXCustomizer c = new CHECKBOXCustomizer(this); 46 boolean accept = c.showDialog(); 47 if (accept) { 48 String body = createBody(); 49 try { 50 HTMLPaletteUtilities.insert(body, targetComponent); 51 } catch (BadLocationException ble) { 52 accept = false; 53 } 54 } 55 56 return accept; 57 } 58 59 private String createBody() { 60 61 String strName = " name=\"" + name + "\""; 63 String strValue = " value=\"" + value + "\""; 65 String strSelected = (selected ? " checked=\"checked\"" : ""); 67 String strDisabled = (disabled ? " disabled=\"disabled\"" : ""); 69 String inputBody = "<input type=\"checkbox\"" + strName + strValue + strSelected + strDisabled + " />"; 71 return inputBody; 72 } 73 74 public String getName() { 75 return name; 76 } 77 78 public void setName(String name) { 79 this.name = name; 80 } 81 82 public String getValue() { 83 return value; 84 } 85 86 public void setValue(String value) { 87 this.value = value; 88 } 89 90 public boolean isSelected() { 91 return selected; 92 } 93 94 public void setSelected(boolean selected) { 95 this.selected = selected; 96 } 97 98 public boolean isDisabled() { 99 return disabled; 100 } 101 102 public void setDisabled(boolean disabled) { 103 this.disabled = disabled; 104 } 105 106 } 107 | Popular Tags |