Java Code Examples for com.google.gwt.dom.client.SpanElement#setInnerText()

The following examples show how to use com.google.gwt.dom.client.SpanElement#setInnerText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SourceCodeEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void declareVariable(String var, String description) {

    SpanElement span = Document.get().createSpanElement();
    span.setInnerText(var);

    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setTitle(description);
    anchor.appendChild(span);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);

    variablesMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onVariableSelected(var);
        }
    });
}
 
Example 2
Source File: CodeLineImpl.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void redraw() {
	this.getElement().removeAllChildren();
	for (Token<?> token : this.tokenList) {
		if (token.getContent() != null && token.getContent() instanceof CssRendererTokenContent
			&& ((CssRendererTokenContent) token.getContent()).getCssStyle() != null) {
			SpanElement spanElement = Document.get().createSpanElement();
			spanElement.addClassName(((CssRendererTokenContent) token.getContent()).getCssStyle());
			spanElement.setInnerText(token.getText());
			this.getElement().appendChild(spanElement);
		} else {
			Text textElement = Document.get().createTextNode(token.getText());
			this.getElement().appendChild(textElement);
		}
	}
}
 
Example 3
Source File: CubaSideMenuWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected SpanElement createCaptionElement(String caption, boolean captionAsHtml) {
    SpanElement captionElement = Document.get().createSpanElement();
    captionElement.setClassName(getStylePrimaryName() + "-caption");
    if (caption != null) {
        if (captionAsHtml) {
            captionElement.setInnerHTML(caption);
        } else {
            captionElement.setInnerText(caption);
        }
    }
    return captionElement;
}
 
Example 4
Source File: PerspectivesExplorerView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
@Override
public void showEmpty(String message) {
    SpanElement span = Document.get().createSpanElement();
    span.setInnerText(message);
    DivElement gi = createItemDiv(new Element[] {span});
    perspectivesDiv.appendChild((Node) gi);
}
 
Example 5
Source File: OutputProgressBar.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setValue(T value) {
	this.value = value;
	double val = 0;
	if (value == null) {
		val = this.min;
	} else {
		val = value.doubleValue();
	}
	if (val > this.max) {
		val = this.max;
	} else if (val < this.min) {
		val = this.min;
	}

	this.progressBarElement.setAttribute(OutputProgressBar.ATT_ARIA_VALUE, value + "");
	double percent = 100 * (val - this.min) / (this.max - this.min);
	this.progressBarElement.getStyle().setProperty("width", percent, Unit.PCT);

	NumberFormat formatter = NumberFormat.getFormat("#.##");

	String stringToDisplay = this.format;
	stringToDisplay = RegExp.compile("\\{0\\}").replace(stringToDisplay, formatter.format(val));
	stringToDisplay = RegExp.compile("\\{1\\}").replace(stringToDisplay, formatter.format(percent));
	stringToDisplay = RegExp.compile("\\{2\\}").replace(stringToDisplay, formatter.format(this.min));
	stringToDisplay = RegExp.compile("\\{3\\}").replace(stringToDisplay, formatter.format(this.max));

	this.progressBarElement.removeAllChildren();
	if (this.displayValue) {
		this.progressBarElement.setInnerText(stringToDisplay);
	} else {
		SpanElement reader = Document.get().createSpanElement();
		reader.setInnerText(stringToDisplay);
		reader.addClassName("sr-only");
		this.progressBarElement.appendChild(reader);
	}
}