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 UL implements ActiveEditorDrop { 32 33 public static final int ITEM_COUNT_DEFAULT = 2; 34 35 public static final String DEFAULT = "default"; public static final String DISC = "disc"; public static final String CIRCLE = "circle"; public static final String SQUARE = "square"; 40 private String type = DEFAULT; 41 private int count = ITEM_COUNT_DEFAULT; 42 43 public UL() { 44 } 45 46 public boolean handleTransfer(JTextComponent targetComponent) { 47 48 ULCustomizer c = new ULCustomizer(this); 49 boolean accept = c.showDialog(); 50 if (accept) { 51 String body = createBody(); 52 try { 53 HTMLPaletteUtilities.insert(body, targetComponent); 54 } catch (BadLocationException ble) { 55 accept = false; 56 } 57 } 58 59 return accept; 60 } 61 62 private String createBody() { 63 64 StringBuffer sb = new StringBuffer (); 65 for (int i = 0; i < count; i++) 66 sb.append("<li></li>\n"); 68 String strType = ""; 69 if (!type.equals(DEFAULT)) 70 strType = " type=\"" + type + "\""; 72 String oList = "<ul" + strType + ">\n" + sb.toString() + "</ul>\n"; 74 return oList; 75 } 76 77 public String getType() { 78 return type; 79 } 80 81 public void setType(String type) { 82 this.type = type; 83 } 84 85 public int getCount() { 86 return count; 87 } 88 89 public void setCount(int count) { 90 this.count = count; 91 } 92 93 } 94 | Popular Tags |