1 19 20 package org.netbeans.lib.editor.codetemplates; 21 22 import javax.swing.text.BadLocationException ; 23 import javax.swing.text.Document ; 24 import javax.swing.text.JTextComponent ; 25 import org.netbeans.lib.editor.codetemplates.api.CodeTemplate; 26 27 28 34 35 final class CodeTemplateAbbrevExpander implements AbbrevExpander { 36 37 public boolean expand(JTextComponent component, int abbrevStartOffset, CharSequence abbrev) { 38 Document doc = component.getDocument(); 39 CodeTemplateManagerOperation op = CodeTemplateManagerOperation.get(doc); 40 op.waitLoaded(); 41 CodeTemplate ct = op.findByAbbreviation(abbrev.toString()); 42 if (ct != null) { 43 try { 44 doc.remove(abbrevStartOffset, abbrev.length()); 46 } catch (BadLocationException ble) { 47 } 48 ct.insert(component); 49 return true; 50 } 51 return false; 52 } 53 54 } 55 | Popular Tags |