1 19 20 package org.netbeans.lib.editor.codetemplates.spi; 21 import java.util.Iterator ; 22 import java.util.List ; 23 import javax.swing.text.JTextComponent ; 24 import org.netbeans.lib.editor.codetemplates.CodeTemplateInsertHandler; 25 import org.netbeans.lib.editor.codetemplates.CodeTemplateParameterImpl; 26 import org.netbeans.lib.editor.codetemplates.CodeTemplateSpiPackageAccessor; 27 import org.netbeans.lib.editor.codetemplates.api.CodeTemplate; 28 29 58 public final class CodeTemplateInsertRequest { 59 60 static { 61 CodeTemplateSpiPackageAccessor.register(new SpiAccessor()); 62 } 63 64 private final CodeTemplateInsertHandler handler; 65 66 CodeTemplateInsertRequest(CodeTemplateInsertHandler handler) { 67 this.handler = handler; 68 } 69 70 73 public CodeTemplate getCodeTemplate() { 74 return handler.getCodeTemplate(); 75 } 76 77 81 public JTextComponent getComponent() { 82 return handler.getComponent(); 83 } 84 85 94 public List getMasterParameters() { 95 return handler.getMasterParameters(); 96 } 97 98 105 public CodeTemplateParameter getMasterParameter(String name) { 106 for (Iterator it = getMasterParameters().iterator(); it.hasNext();) { 107 CodeTemplateParameter master = (CodeTemplateParameter)it.next(); 108 if (name.equals(master.getName())) { 109 return master; 110 } 111 } 112 return null; 113 } 114 115 123 public List getAllParameters() { 124 return handler.getAllParameters(); 125 } 126 127 141 public boolean isInserted() { 142 return handler.isInserted(); 143 } 144 145 155 public boolean isReleased() { 156 return handler.isReleased(); 157 } 158 159 167 public String getParametrizedText() { 168 return handler.getParametrizedText(); 169 } 170 171 183 public void setParametrizedText(String parametrizedText) { 184 handler.setParametrizedText(parametrizedText); 185 } 186 187 197 public String getInsertText() { 198 return handler.getInsertText(); 199 } 200 201 210 public int getInsertTextOffset() { 211 return handler.getInsertOffset(); 212 } 213 214 private static final class SpiAccessor extends CodeTemplateSpiPackageAccessor { 215 216 public CodeTemplateInsertRequest createInsertRequest(CodeTemplateInsertHandler handler) { 217 return new CodeTemplateInsertRequest(handler); 218 } 219 220 public CodeTemplateParameter createParameter(CodeTemplateParameterImpl impl) { 221 return new CodeTemplateParameter(impl); 222 } 223 224 public CodeTemplateParameterImpl getImpl(CodeTemplateParameter parameter) { 225 return parameter.getImpl(); 226 } 227 228 } 229 230 } 231 | Popular Tags |