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