@Override public String toString() { return getDefinitionString(); }
/** * Returns whether a parameter is already defined with a specific name. * * @param name The name. * @return Whether a parameter is defined with that name. */ private boolean isParamDefined(String name) { for (int i=0; i<getParamCount(); i++) { Parameter param = getParam(i); if (name.equals(param.getName())) { return true; } } return false; }
public TemplateCompletion(CompletionProvider provider, String inputText, String definitionString, String template, String shortDescription, String summary) { super(provider); this.inputText = inputText; this.definitionString = definitionString; this.shortDescription = shortDescription; this.summary = summary; pieces = new ArrayList<TemplatePiece>(3); params = new ArrayList<Parameter>(3); parse(template); }
@Override protected void prepareForTemplateCompletion(JList list, TemplateCompletion tc, int index, boolean selected, boolean hasFocus) { StringBuilder sb = new StringBuilder(PREFIXO_HTML); sb.append(tc.getDefinitionString()); String descricao = tc.getShortDescription(); if (descricao != null) { sb.append(" - "); if (!selected) { sb.append("<font color='").append(corTipo).append("'>"); } sb.append(descricao); if (!selected) { sb.append("</font>"); } } setText(sb.toString()); }
/** * Prepares this renderer to display a template completion. * * @param list The list of choices being rendered. * @param tc The completion to render. * @param index The index into <code>list</code> being rendered. * @param selected Whether the item is selected. * @param hasFocus Whether the item has focus. */ protected void prepareForTemplateCompletion(JList list, TemplateCompletion tc, int index, boolean selected, boolean hasFocus) { StringBuilder sb = new StringBuilder(PREFIX); sb.append(tc.getInputText()); String definition = tc.getShortDescription(); if (definition!=null) { sb.append(" - "); if (!selected) { sb.append("<font color='").append(typeColor).append("'>"); } sb.append(definition); if (!selected) { sb.append("</font>"); } } setText(sb.toString()); }
for (int i=0; i<pieces.size(); i++) { TemplatePiece piece = pieces.get(i); String text = getPieceText(i, leadingWS); if (piece instanceof Text) { if (replaceTabsWithSpaces) { start = possiblyReplaceTabsWithSpaces(sb, text, tc, start); if (selStart==minPos && selStart==selEnd && getParamCount()==0) { if (defaultEndOffs>-1) { // ${cursor} specified selStart = selEnd = defaultEndOffs;
switch (next) { case '$': // "$$" => escaped single dollar sign addTemplatePiece(new TemplatePiece.Text( template.substring(lastOffs, offs+1))); lastOffs = offs + 2; int closingCurly = template.indexOf('}', offs+2); if (closingCurly>-1) { addTemplatePiece(new TemplatePiece.Text( template.substring(lastOffs, offs))); String varName = template.substring(offs+2, closingCurly); if (!"cursor".equals(varName) && isParamDefined(varName)) { addTemplatePiece(new TemplatePiece.ParamCopy(varName)); addTemplatePiece(new TemplatePiece.Param(varName)); addTemplatePiece(new TemplatePiece.Text(text));
textComponent.replaceSelection(Character.toString(p .getParameterListStart())); TemplateCompletion tc = new TemplateCompletion(p, null, null, template); pc = tc;