private MarkupTagCompletion createMarkupTagCompletion() { MarkupTagCompletion mc = new MarkupTagCompletion(provider, name); if (desc.length()>0) { mc.setDescription(desc.toString()); desc.setLength(0); } mc.setAttributes(params); mc.setDefinedIn(definedIn); return mc; }
/** * {@inheritDoc} */ @Override public String getReplacementText() { return getName(); }
/** * {@inheritDoc} */ @Override public String getSummary() { StringBuilder sb = new StringBuilder(); addDefinitionString(sb); possiblyAddDescription(sb); addAttributes(sb); possiblyAddDefinedIn(sb); return sb.toString(); }
/** * Constructor. */ public HtmlCompletionProvider() { initCompletions(); tagToAttrs = new HashMap<String, List<AttributeCompletion>>(); for (Completion comp : completions) { MarkupTagCompletion c = (MarkupTagCompletion)comp; String tag = c.getName(); List<AttributeCompletion> attrs = new ArrayList<AttributeCompletion>(); tagToAttrs.put(tag.toLowerCase(), attrs); for (int j=0; j<c.getAttributeCount(); j++) { Parameter param = c.getAttribute(j); attrs.add(new AttributeCompletion(this, param)); } } setAutoActivationRules(false, "<"); }
/** * Adds HTML describing the attributes of this tag to a buffer. * * @param sb The buffer to append to. */ protected void addAttributes(StringBuilder sb) { // TODO: Localize me. int attrCount = getAttributeCount(); if (attrCount>0) { sb.append("<b>Attributes:</b><br>"); sb.append("<center><table width='90%'><tr><td>"); for (int i=0; i<attrCount; i++) { Parameter attr = getAttribute(i); sb.append(" <b>"); sb.append(attr.getName()!=null ? attr.getName() : attr.getType()); sb.append("</b> "); String desc = attr.getDescription(); if (desc!=null) { sb.append(desc); } sb.append("<br>"); } sb.append("</td></tr></table></center><br><br>"); } }
/** * Overridden to include JSP-specific tags in addition to the standard * HTML tags. * * @return The list of tags. */ @Override protected List<Completion> getTagCompletions() { List<Completion> completions = new ArrayList<Completion>( super.getTagCompletions()); for (Map.Entry<String, TldFile> entry : prefixToTld.entrySet()) { String prefix = entry.getKey(); TldFile tld = entry.getValue(); for (int j=0; j<tld.getElementCount(); j++) { TldElement elem = tld.getElement(j); MarkupTagCompletion mtc = new MarkupTagCompletion(this, prefix + ":" + elem.getName()); mtc.setDescription(elem.getDescription()); completions.add(mtc); } } Collections.sort(completions); return completions; }
/** * Creates a <code>Completion</code> of the proper type and adds it * to the completions list. * * @param word The text of the completion. * @param desiredType The completion type we're collecting. */ private void addCompletionImpl(String word, int desiredType) { Completion c; if (desiredType==TokenTypes.MARKUP_TAG_NAME) { c = new MarkupTagCompletion(this, word); } else { ParameterizedCompletion.Parameter param = new ParameterizedCompletion.Parameter(null, word); c = new AttributeCompletion(this, param); } completions.add(c); }
/** * Prepares this renderer to display a markup tag completion. * * @param list The list of choices being rendered. * @param mc 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 prepareForMarkupTagCompletion(JList list, MarkupTagCompletion mc, int index, boolean selected, boolean hasFocus) { StringBuilder sb = new StringBuilder(PREFIX); sb.append(mc.getName()); setText(sb.toString()); }