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 FILESEL implements ActiveEditorDrop { 32 33 private String name = ""; 34 private String width = ""; 35 private boolean disabled = false; 36 37 public FILESEL() { 38 } 39 40 public boolean handleTransfer(JTextComponent targetComponent) { 41 42 FILESELCustomizer c = new FILESELCustomizer(this); 43 boolean accept = c.showDialog(); 44 if (accept) { 45 String body = createBody(); 46 try { 47 HTMLPaletteUtilities.insert(body, targetComponent); 48 } catch (BadLocationException ble) { 49 accept = false; 50 } 51 } 52 53 return accept; 54 } 55 56 private String createBody() { 57 58 String strName = " name=\"" + name + "\""; 60 String strWidth = ""; 61 if (width.length() > 0) 62 strWidth = " width=\"" + width + "\""; 64 String strDisabled = (disabled ? " disabled=\"disabled\"" : ""); 66 String fileselBody = "<input type=\"file\"" + strName + " value=\"\"" + strWidth + strDisabled + " />"; 68 return fileselBody; 69 } 70 71 public String getName() { 72 return name; 73 } 74 75 public void setName(String name) { 76 this.name = name; 77 } 78 79 public String getWidth() { 80 return width; 81 } 82 83 public void setWidth(String width) { 84 this.width = width; 85 } 86 87 public boolean isDisabled() { 88 return disabled; 89 } 90 91 public void setDisabled(boolean disabled) { 92 this.disabled = disabled; 93 } 94 95 } 96 | Popular Tags |