com.google.gwt.dom.client.SpanElement Java Examples

The following examples show how to use com.google.gwt.dom.client.SpanElement. 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: DiffManager.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Create a diff annotation element
 * @param type The type of change it will be annotating
 * @return The newly created element
 */
public Element createElement(DiffType type) {
  SpanElement element = Document.get().createSpanElement();
  element.setPropertyObject(DIFF_KEY, type);
  NodeManager.setTransparentBackref(element, this);

  // HACK(danilatos): Demo looms, no time for learning how to use resource bundle etc.
  // or adding accessors to stylebase
  switch (type) {
    case INSERT:
      NodeManager.setTransparency(element, Skip.SHALLOW);
      break;
    case DELETE:
      NodeManager.setTransparency(element, Skip.DEEP);
      break;
  }

  styleElement(element, type);

  elements.add(element);

  return element;
}
 
Example #2
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected boolean isCubaTableClickableCellText(Event event) {
    Element eventTarget = event.getEventTarget().cast();
    Element elementTdOrTr = getElementTdOrTr(eventTarget);

    if (elementTdOrTr != null
            && TableCellElement.TAG_TD.equalsIgnoreCase(elementTdOrTr.getTagName())
            && !elementTdOrTr.hasClassName(CUBA_TABLE_CLICKABLE_TEXT_STYLE)) {
        // found <td>

        if (SpanElement.TAG.equalsIgnoreCase(eventTarget.getTagName())
                && eventTarget.hasClassName(CUBA_TABLE_CLICKABLE_CELL_STYLE)) {
            // found <span class="c-table-clickable-cell">
            return true;
        }
    }
    return false;
}
 
Example #3
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 #4
Source File: DiffManager.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Create a diff annotation element
 * @param type The type of change it will be annotating
 * @return The newly created element
 */
public Element createElement(DiffType type, String author) {
  SpanElement element = Document.get().createSpanElement();
  element.setPropertyObject(DIFF_KEY, type);
  element.setPropertyObject(AUTHOR_KEY, author);
  NodeManager.setTransparentBackref(element, this);

  // HACK(danilatos): Demo looms, no time for learning how to use resource bundle etc.
  // or adding accessors to stylebase
  switch (type) {
    case INSERT:
      NodeManager.setTransparency(element, Skip.SHALLOW);
      break;
    case DELETE:
      NodeManager.setTransparency(element, Skip.DEEP);
      break;
  }

  styleElement(element, type, author, 0, 0);

  elements.add(element);

  return element;
}
 
Example #5
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 #6
Source File: PerspectivesExplorerView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addPerspective(String name, Command onClicked) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.getStyle().setCursor(Style.Cursor.POINTER);
    anchor.getStyle().setColor("black");
    anchor.getStyle().setProperty("fontSize", "larger");
    anchor.setInnerText(name);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onClicked.execute();
        }
    });

    SpanElement icon = Document.get().createSpanElement();
    icon.getStyle().setMarginRight(10, Style.Unit.PX);
    icon.setClassName("pficon-virtual-machine");
    icon.getStyle().setProperty("fontSize", "larger");

    DivElement gi = createItemDiv(new Element[] {icon, anchor});
    perspectivesDiv.appendChild((Node) gi);
}
 
Example #7
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 #8
Source File: CheckBox.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  InputElement inputElem = Document.get().createCheckInputElement();
  inputElem.setClassName(CheckConstants.css.check());

  // Wrap in non-editable span- Firefox does not fire events for checkboxes
  // inside contentEditable region.
  SpanElement nonEditableSpan = Document.get().createSpanElement();
  DomHelper.setContentEditable(nonEditableSpan, false, false);
  nonEditableSpan.appendChild(inputElem);

  return nonEditableSpan;
}
 
Example #9
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);
	}
}
 
Example #10
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 #11
Source File: NavTreeWidgetView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
protected void addItem(String iconClass, String id, String name, String description, Command onClicked) {
    Element nameEl = onClicked != null ? Document.get().createAnchorElement() : Document.get().createSpanElement();
    nameEl.setInnerText(name);
    nameEl.setClassName(onClicked != null ? "uf-navtree-widget-non-clicked" : "uf-navtree-widget-non-clickable");
    if (description != null && !description.equals(name)) {
        nameEl.setTitle(description);
    }

    SpanElement iconSpan = Document.get().createSpanElement();
    iconSpan.setClassName("uf-navtree-widget-icon " + iconClass);

    DivElement div = Document.get().createDivElement();
    div.appendChild(iconSpan);
    div.appendChild(nameEl);

    navWidget.appendChild((Node) div);
    itemMap.put(id, nameEl);

    if (onClicked != null) {
        Event.sinkEvents(nameEl, Event.ONCLICK);
        Event.setEventListener(nameEl, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    }
}
 
Example #12
Source File: CheckBox.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  InputElement inputElem = Document.get().createCheckInputElement();
  inputElem.setClassName(CheckConstants.css.check());

  // Wrap in non-editable span- Firefox does not fire events for checkboxes
  // inside contentEditable region.
  SpanElement nonEditableSpan = Document.get().createSpanElement();
  DomHelper.setContentEditable(nonEditableSpan, false, false);
  nonEditableSpan.appendChild(inputElem);

  return nonEditableSpan;
}
 
Example #13
Source File: DocumentTitle.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Instantiates a new document title widget.
 */
public DocumentTitle() {
	super(SpanElement.TAG);
	endContruct();
}
 
Example #14
Source File: TestInlineDoodad.java    From swellrt with Apache License 2.0 4 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  SpanElement domElement = Document.get().createSpanElement();
  return element.setAutoAppendContainer(domElement);
}
 
Example #15
Source File: Text.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Text() {
	super(SpanElement.TAG);
	this.span = SpanElement.as(this.getElement());
}
 
Example #16
Source File: Text.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Text(Text source) {
	super(source);
	this.span = SpanElement.as(this.getElement());
	this.span.setInnerText(source.text);
}
 
Example #17
Source File: CubaSideMenuWidget.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected SpanElement createBadgeElement() {
    SpanElement badgeElement = Document.get().createSpanElement();
    badgeElement.setClassName(getStylePrimaryName() + "-badge");
    return badgeElement;
}
 
Example #18
Source File: CubaSideMenuWidget.java    From cuba with Apache License 2.0 4 votes vote down vote up
public MenuItemWidget(CubaSideMenuWidget menu, String id, Icon icon, String styleName,
                      String caption, boolean captionAsHtml) {
    this.menu = menu;
    this.id = id;
    this.icon = icon;
    this.caption = caption;

    setElement(Document.get().createDivElement());

    setStylePrimaryName(menu.getStylePrimaryName() + "-item");
    addStyleDependentName("action");

    if (styleName != null) {
        for (String style : styleName.split(" ")) {
            if (!style.isEmpty()) {
                addStyleName(style);
            }
        }
    }

    SpanElement wrapElement = Document.get().createSpanElement();
    wrapElement.setClassName(getStylePrimaryName() + "-wrap");

    if (icon != null) {
        wrapElement.appendChild(icon.getElement());
    }

    captionElement = createCaptionElement(caption, captionAsHtml);
    wrapElement.appendChild(captionElement);

    badgeElement = createBadgeElement();

    getElement().appendChild(wrapElement);

    addDomHandler(this, ClickEvent.getType());

    addAttachHandler(event -> {
        if (isAttached() && isRootItem()) {
            addThumbnail();
        }
    });
}
 
Example #19
Source File: TestInlineDoodad.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  SpanElement domElement = Document.get().createSpanElement();
  return element.setAutoAppendContainer(domElement);
}