Search in sources :

Example 16 with SpanElement

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);
}
Also used : SpanElement(elemental.html.SpanElement) ParagraphElement(elemental.html.ParagraphElement) AnchorElement(elemental.html.AnchorElement) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Example 17 with SpanElement

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("&nbsp;");
    root.appendChild(spanElement);
    return root;
}
Also used : SpanElement(elemental.html.SpanElement) SVGResource(org.vectomatic.dom.svg.ui.SVGResource) DivElement(elemental.html.DivElement) DivElement(elemental.html.DivElement) TreeNodeElement(org.eclipse.che.ide.ui.tree.TreeNodeElement) Element(elemental.dom.Element) SpanElement(elemental.html.SpanElement) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 18 with SpanElement

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("&nbsp;");
    root.appendChild(spanElement);
    return root;
}
Also used : SpanElement(elemental.html.SpanElement) SVGResource(org.vectomatic.dom.svg.ui.SVGResource) DivElement(elemental.html.DivElement) DivElement(elemental.html.DivElement) TreeNodeElement(org.eclipse.che.ide.ui.tree.TreeNodeElement) Element(elemental.dom.Element) SpanElement(elemental.html.SpanElement) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Example 19 with SpanElement

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;
}
Also used : SpanElement(elemental.html.SpanElement)

Example 20 with SpanElement

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) + ":&nbsp;&nbsp;&nbsp;");
    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);
}
Also used : SpanElement(elemental.html.SpanElement) Region(org.eclipse.che.ide.ext.java.shared.dto.Region)

Aggregations

SpanElement (elemental.html.SpanElement)21 Element (elemental.dom.Element)7 Event (elemental.events.Event)6 EventListener (elemental.events.EventListener)6 SVGImage (org.vectomatic.dom.svg.ui.SVGImage)5 DivElement (elemental.html.DivElement)4 TreeNodeElement (org.eclipse.che.ide.ui.tree.TreeNodeElement)4 Node (elemental.dom.Node)3 CustomEvent (elemental.events.CustomEvent)2 Completion (org.eclipse.che.ide.api.editor.codeassist.Completion)2 CompletionProposal (org.eclipse.che.ide.api.editor.codeassist.CompletionProposal)2 LinearRange (org.eclipse.che.ide.api.editor.text.LinearRange)2 SVGResource (org.vectomatic.dom.svg.ui.SVGResource)2 Scheduler (com.google.gwt.core.client.Scheduler)1 DivElement (com.google.gwt.dom.client.DivElement)1 Style (com.google.gwt.dom.client.Style)1 KeyCodes (com.google.gwt.event.dom.client.KeyCodes)1 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 Timer (com.google.gwt.user.client.Timer)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1