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));
}
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());
}
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());
}
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());
}
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");
}
}
Aggregations