Search in sources :

Example 1 with PreElement

use of com.google.gwt.dom.client.PreElement in project rstudio by rstudio.

the class DomUtilsTests method testCountLinesRecursive.

public void testCountLinesRecursive() {
    PreElement pre = Document.get().createPreElement();
    SpanElement s1 = Document.get().createSpanElement();
    s1.setInnerText("Line1\nLine2\n");
    pre.appendChild(s1);
    SpanElement s2 = Document.get().createSpanElement();
    s2.setInnerText("Line3\n");
    pre.appendChild(s2);
    Assert.assertEquals(3, DomUtils.countLines(pre, true));
}
Also used : SpanElement(com.google.gwt.dom.client.SpanElement) PreElement(com.google.gwt.dom.client.PreElement)

Example 2 with PreElement

use of com.google.gwt.dom.client.PreElement in project rstudio by rstudio.

the class VirtualConsoleTests method testFormFeed.

public void testFormFeed() {
    PreElement ele = Document.get().createPreElement();
    VirtualConsole vc = new VirtualConsole(ele);
    vc.submit("Sample1\n");
    vc.submit("Sample2\n");
    vc.submit("Sample3\f");
    vc.submit("Sample4");
    Assert.assertEquals("<span>Sample4</span>", ele.getInnerHTML());
}
Also used : VirtualConsole(org.rstudio.core.client.VirtualConsole) PreElement(com.google.gwt.dom.client.PreElement)

Example 3 with PreElement

use of com.google.gwt.dom.client.PreElement in project rstudio by rstudio.

the class VirtualConsoleTests method testSimpleColor.

public void testSimpleColor() {
    PreElement ele = Document.get().createPreElement();
    VirtualConsole vc = new VirtualConsole(ele);
    vc.submit("Error", "error");
    Assert.assertEquals("<span class=\"error\">Error</span>", ele.getInnerHTML());
}
Also used : VirtualConsole(org.rstudio.core.client.VirtualConsole) PreElement(com.google.gwt.dom.client.PreElement)

Example 4 with PreElement

use of com.google.gwt.dom.client.PreElement in project rstudio by rstudio.

the class VirtualConsoleTests method testColorOverwrite.

public void testColorOverwrite() {
    PreElement ele = Document.get().createPreElement();
    VirtualConsole vc = new VirtualConsole(ele);
    vc.submit("XXXX\r", "X");
    vc.submit("YY", "Y");
    Assert.assertEquals("<span class=\"Y\">YY</span>" + "<span class=\"X\">XX</span>", ele.getInnerHTML());
}
Also used : VirtualConsole(org.rstudio.core.client.VirtualConsole) PreElement(com.google.gwt.dom.client.PreElement)

Example 5 with PreElement

use of com.google.gwt.dom.client.PreElement in project cuba by cuba-platform.

the class CubaLabelConnector method onStateChanged.

@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    // CAUTION copied from superclass
    super.onStateChanged(stateChangeEvent);
    boolean sinkOnloads = false;
    Profiler.enter("LabelConnector.onStateChanged update content");
    switch(getState().contentMode) {
        case PREFORMATTED:
            PreElement preElement = Document.get().createPreElement();
            preElement.setInnerText(getState().text);
            // clear existing content
            getWidget().setHTML("");
            // add preformatted text to dom
            getWidget().getElement().appendChild(preElement);
            break;
        case TEXT:
            // clear existing content
            getWidget().setHTML("");
            // set multiline text if needed
            // Haulmont API
            String text = getState().text;
            if (text != null && text.contains("\n")) {
                text = WidgetUtil.escapeHTML(text).replace("\n", "<br/>");
                getWidget().setHTML(text);
            } else {
                getWidget().setText(text);
            }
            break;
        case HTML:
        case RAW:
            sinkOnloads = true;
        case XML:
            getWidget().setHTML(getState().text);
            break;
        default:
            getWidget().setText("");
            break;
    }
    // Haulmont API
    if ("".equals(getWidget().getText()) || getWidget().getText() == null) {
        getWidget().addStyleDependentName("empty");
    } else {
        getWidget().removeStyleDependentName("empty");
    }
    updateIcon();
    Profiler.leave("LabelConnector.onStateChanged update content");
    if (sinkOnloads) {
        Profiler.enter("LabelConnector.onStateChanged sinkOnloads");
        WidgetUtil.sinkOnloadForImages(getWidget().getElement());
        Profiler.leave("LabelConnector.onStateChanged sinkOnloads");
    }
}
Also used : PreElement(com.google.gwt.dom.client.PreElement)

Aggregations

PreElement (com.google.gwt.dom.client.PreElement)11 VirtualConsole (org.rstudio.core.client.VirtualConsole)6 Node (com.google.gwt.dom.client.Node)1 SpanElement (com.google.gwt.dom.client.SpanElement)1 MatchResult (com.google.gwt.regexp.shared.MatchResult)1 RegExp (com.google.gwt.regexp.shared.RegExp)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1