private void addParticipant(String userId, String displayEmail, String name, String color) { DivElement rowElement = Elements.createDivElement(css.row()); DivElement swatchElement = Elements.createDivElement(css.swatch()); swatchElement.setAttribute("style", "background-color: " + color); rowElement.appendChild(swatchElement); SpanElement nameElement = Elements.createSpanElement(css.name()); nameElement.setTextContent(name); nameElement.setTitle(displayEmail); rowElement.appendChild(nameElement); getElement().appendChild(rowElement); rows.put(userId, rowElement); }
private void renderDocumentation( Element element, SignatureInfo signatureInfo, Optional<Integer> activeParameter) { if (signatureInfo.getDocumentation().isPresent()) { elemental.html.DivElement documentation = Elements.createDivElement(resources.css().documentation()); documentation.setTextContent(signatureInfo.getDocumentation().get()); element.appendChild(documentation); } if (signatureInfo.getParameters().isPresent() && activeParameter.isPresent() && signatureInfo.getParameters().get().size() > activeParameter.get()) { ParameterInfo parameterInfo = signatureInfo.getParameters().get().get(activeParameter.get()); if (parameterInfo.getDocumentation().isPresent()) { elemental.html.DivElement parameter = Elements.createDivElement(resources.css().documentationParameter()); SpanElement label = Elements.createSpanElement(resources.css().documentationParameter()); label.setTextContent(parameterInfo.getLabel()); SpanElement documentation = Elements.createSpanElement(resources.css().documentation()); documentation.setTextContent(parameterInfo.getDocumentation().get()); parameter.appendChild(label); parameter.appendChild(documentation); element.appendChild(parameter); } } }
/** Creates a paragraph tag and fills it with spans and anchor tags internally. */ private static void markupParagraph(Element parent, String text, String linkCssClass) { if (StringUtils.isNullOrWhitespace(text)) { // don't add any dom here return; } ParagraphElement myParagraph = createParagraphElement(); int index = 0; REGEXP_MARKUP.setLastIndex(0); SpanElement current = createSpanElement(); for (MatchResult match = REGEXP_MARKUP.exec(text); match != null; match = REGEXP_MARKUP.exec(text)) { current.setTextContent(text.substring(index, match.getIndex())); myParagraph.appendChild(current); current = createSpanElement(); /* * If our match is a \n we need to create a <br/> element to force a line break, otherwise we * matched an http/www link so let's make an anchor tag out of it. */ if (match.getGroup(0).equals("\n")) { myParagraph.appendChild(createBRElement()); } else { AnchorElement anchor = createAnchorElement(linkCssClass); anchor.setHref(match.getGroup(0)); anchor.setTarget("_blank"); anchor.setTextContent(match.getGroup(0)); myParagraph.appendChild(anchor); } index = match.getIndex() + match.getGroup(0).length(); } current.setTextContent(text.substring(index)); myParagraph.appendChild(current); parent.appendChild(myParagraph); }
@Override public void updatePresentation(@NotNull NodePresentation presentation) { SpanElement spanElement = Elements.createSpanElement(styles.styles().presentableTextContainer()); SpanElement lineNumberElement = Elements.createSpanElement(); lineNumberElement.setInnerHTML( String.valueOf(match.getMatchLineNumber() + 1) + ": "); spanElement.appendChild(lineNumberElement); SpanElement textElement = Elements.createSpanElement(); Region matchInLine = match.getMatchInLine(); String matchedLine = match.getMatchedLine(); if (matchedLine != null && matchInLine != null) { String startLine = matchedLine.substring(0, matchInLine.getOffset()); textElement.appendChild(Elements.createTextNode(startLine)); SpanElement highlightElement = Elements.createSpanElement(resources.css().searchMatch()); highlightElement.setInnerText( matchedLine.substring( matchInLine.getOffset(), matchInLine.getOffset() + matchInLine.getLength())); textElement.appendChild(highlightElement); textElement.appendChild( Elements.createTextNode( matchedLine.substring(matchInLine.getOffset() + matchInLine.getLength()))); } else { textElement.appendChild(Elements.createTextNode("Can't find sources")); } spanElement.appendChild(textElement); presentation.setPresentableIcon(resources.searchMatch()); presentation.setUserElement((Element) spanElement); }