use of elemental.html.SpanElement in project che by eclipse.
the class Elements method markupParagraph.
/** 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);
}
use of elemental.html.SpanElement in project che by eclipse.
the class ProcessTreeRenderer method createTerminalElement.
private SpanElement createTerminalElement(ProcessTreeNode node) {
SpanElement root = Elements.createSpanElement(resources.getCss().commandTreeNode());
root.appendChild(createCloseElement(node));
SVGResource icon = node.getTitleIcon();
if (icon != null) {
SpanElement iconElement = Elements.createSpanElement(resources.getCss().processIcon());
root.appendChild(iconElement);
DivElement divElement = Elements.createDivElement(resources.getCss().processIconPanel());
iconElement.appendChild(divElement);
divElement.appendChild((Node) new SVGImage(icon).getElement());
}
Element nameElement = Elements.createSpanElement();
nameElement.setTextContent(node.getName());
Tooltip.create(nameElement, BOTTOM, MIDDLE, node.getName());
root.appendChild(nameElement);
Element spanElement = Elements.createSpanElement();
spanElement.setInnerHTML(" ");
root.appendChild(spanElement);
return root;
}
use of elemental.html.SpanElement in project che by eclipse.
the class ProcessTreeRenderer method createCommandElement.
private SpanElement createCommandElement(ProcessTreeNode node) {
SpanElement root = Elements.createSpanElement(resources.getCss().commandTreeNode());
root.setAttribute("running", "" + node.isRunning());
root.appendChild(createCloseElement(node));
root.appendChild(createStopProcessElement(node));
SVGResource icon = node.getTitleIcon();
if (icon != null) {
SpanElement iconElement = Elements.createSpanElement(resources.getCss().processIcon());
root.appendChild(iconElement);
DivElement divElement = Elements.createDivElement(resources.getCss().processIconPanel());
iconElement.appendChild(divElement);
divElement.appendChild((Node) new SVGImage(icon).getElement());
DivElement badgeElement = Elements.createDivElement(resources.getCss().processBadge());
divElement.appendChild(badgeElement);
}
Element nameElement = Elements.createSpanElement();
nameElement.setTextContent(node.getName());
Tooltip.create(nameElement, BOTTOM, MIDDLE, node.getName());
root.appendChild(nameElement);
Element spanElement = Elements.createSpanElement();
spanElement.setInnerHTML(" ");
root.appendChild(spanElement);
return root;
}
use of elemental.html.SpanElement in project che by eclipse.
the class ProcessTreeRenderer method renderNodeContents.
@Override
public SpanElement renderNodeContents(ProcessTreeNode node) {
SpanElement treeNode;
switch(node.getType()) {
case MACHINE_NODE:
treeNode = createMachineElement(node);
break;
case COMMAND_NODE:
treeNode = createCommandElement(node);
break;
case TERMINAL_NODE:
treeNode = createTerminalElement(node);
break;
default:
treeNode = Elements.createSpanElement();
}
Elements.addClassName(resources.getCss().processTreeNode(), treeNode);
return treeNode;
}
use of elemental.html.SpanElement in project che by eclipse.
the class MatchNode method updatePresentation.
@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);
}
Aggregations