Java Code Examples for com.google.gwt.user.client.DOM#createSpan()

The following examples show how to use com.google.gwt.user.client.DOM#createSpan() . 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: CubaLabelConnector.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void updateContextHelp(CubaLabelWidget widget) {
    if (isContextHelpIconEnabled(getState())) {
        widget.contextHelpIcon = DOM.createSpan();
        widget.contextHelpIcon.setInnerHTML("?");
        widget.contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME);

        if (hasContextHelpIconListeners(getState())) {
            widget.contextHelpIcon.addClassName(CONTEXT_HELP_CLICKABLE_CLASSNAME);
        }

        Roles.getTextboxRole().setAriaHiddenState(widget.contextHelpIcon, true);

        widget.getElement().appendChild(widget.contextHelpIcon);

        widget.contextHelpClickHandler =
                this::contextHelpIconClick;
    }
}
 
Example 2
Source File: FlowForm.java    From unitime with Apache License 2.0 6 votes vote down vote up
public int addRow(Widget header, Widget... widgets) {
	if (header.getElement().getId() == null || header.getElement().getId().isEmpty())
		header.getElement().setId(DOM.createUniqueId());
	P head = new P(DOM.createSpan(), "header-cell");
	head.add(header);
	add(head);
	for (Widget widget: widgets) {
		P body = new P(DOM.createSpan(), "content-cell");
		add(body);
		if (widget instanceof UniTimeTable) {
			ScrollPanel scroll = new ScrollPanel(widget);
			scroll.addStyleName("scroll");
			body.add(scroll);
		} else {
			body.add(widget);
		}
	}
	if (widgets.length > 0) {
		if (widgets[0] instanceof UniTimeWidget)
			Roles.getTextboxRole().setAriaLabelledbyProperty(((UniTimeWidget)widgets[0]).getWidget().getElement(), Id.of(header.getElement()));
		else
			Roles.getTextboxRole().setAriaLabelledbyProperty(widgets[0].getElement(), Id.of(header.getElement()));			
	}
	return getWidgetCount() - widgets.length;
}
 
Example 3
Source File: CubaCheckBoxConnector.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    getWidget().captionManagedByLayout = getState().captionManagedByLayout;

    super.onStateChanged(stateChangeEvent);

    if (!getWidget().captionManagedByLayout
            && isContextHelpIconEnabled(getState())) {
        if (getWidget().contextHelpIcon == null) {
            getWidget().contextHelpIcon = DOM.createSpan();
            getWidget().contextHelpIcon.setInnerHTML("?");
            getWidget().contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME);

            if (hasContextHelpIconListeners(getState())) {
                getWidget().contextHelpIcon.addClassName(CONTEXT_HELP_CLICKABLE_CLASSNAME);
            }

            Roles.getTextboxRole().setAriaHiddenState(getWidget().contextHelpIcon, true);

            getWidget().getElement().appendChild(getWidget().contextHelpIcon);
            DOM.sinkEvents(getWidget().contextHelpIcon, VTooltip.TOOLTIP_EVENTS | Event.ONCLICK);
        } else {
            getWidget().contextHelpIcon.getStyle().clearDisplay();
        }
    } else if (getWidget().contextHelpIcon != null) {
        getWidget().contextHelpIcon.getStyle()
                .setDisplay(Style.Display.NONE);

        getWidget().setAriaInvalid(false);
    }

    if (stateChangeEvent.hasPropertyChanged("readOnly")) {
        getWidget().setReadOnly(getState().readOnly);
    }
}
 
Example 4
Source File: FlowForm.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected int addBottomRow(Widget widget, boolean printable) {
	P row = new P(DOM.createSpan(), "row-cell", "unitime-MainTableBottomHeader", "unitime-TopLine");
	if (!printable)
		row.addStyleName("unitime-NoPrint");
	removeStyleName("unitime-NotPrintableBottomLine");
	row.add(widget);
	add(row);
	return getWidgetCount() - 1;
}
 
Example 5
Source File: CourseFinderClasses.java    From unitime with Apache License 2.0 5 votes vote down vote up
public RoomsOrInstructors(List<String> list, String delimiter) {
	super("itemize");
	if (list != null)
		for (Iterator<String> i = list.iterator(); i.hasNext(); ) {
			P p = new P(DOM.createSpan(), "item");
			p.setText(i.next() + (i.hasNext() ? delimiter : ""));
			add(p);
		}
}
 
Example 6
Source File: DomTextEditor.java    From jetpad-projectional-open-source with Apache License 2.0 5 votes vote down vote up
public DomTextEditor(Element root) {
  myRoot = root;

  Style rootStyle = myRoot.getStyle();
  rootStyle.setPosition(Style.Position.RELATIVE);

  myTextContainer = DOM.createSpan();
  Style textStyle = myTextContainer.getStyle();
  textStyle.setZIndex(10);
  textStyle.setWhiteSpace(Style.WhiteSpace.NOWRAP);
  myRoot.appendChild(myTextContainer);

  Element caretDiv = DOM.createDiv();
  Style caretStyle = caretDiv.getStyle();
  caretStyle.setPosition(Style.Position.ABSOLUTE);
  caretStyle.setZIndex(10);
  myRoot.appendChild(caretDiv);
  myCaretDiv = caretDiv;

  Element selectionDiv = DOM.createDiv();
  Style selectionStyle = selectionDiv.getStyle();
  selectionStyle.setPosition(Style.Position.ABSOLUTE);
  selectionStyle.setZIndex(1);
  myRoot.appendChild(selectionDiv);
  mySelectionDiv = selectionDiv;

  update();
  updateCaretVisibility();
  updateSelectionVisibility();
  updateCaretAndSelection();
}
 
Example 7
Source File: TreeTable.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ItemWidget(int level) {
  this.image = DOM.createSpan();
  this.label = DOM.createSpan();

  Element div = DOM.createDiv();
  div.appendChild(this.image);
  div.appendChild(this.label);

  div.getStyle().setPropertyPx("marginLeft", level * 16);
  image.getStyle().setProperty("verticalAlign", "bottom");

  setElement(div);
}
 
Example 8
Source File: CubaGroupBoxConnector.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    super.onStateChanged(stateChangeEvent);

    CubaGroupBoxWidget widget = getWidget();

    if (!widgetInitialized) {
        widget.init();
        if (!getState().showAsPanel) {
            LayoutManager layoutManager = getLayoutManager();
            layoutManager.registerDependency(this, widget.captionStartDeco);
            layoutManager.registerDependency(this, widget.captionEndDeco);
            layoutManager.registerDependency(this, widget.captionTextNode);
        }

        widgetInitialized = true;
    }

    widget.setCollapsable(getState().collapsable);
    widget.setExpanded(getState().expanded);
    widget.setShowAsPanel(getState().showAsPanel);
    if (!getState().showAsPanel) {
        widget.setOuterMargin(new MarginInfo(getState().outerMarginsBitmask));
    }

    if (stateChangeEvent.hasPropertyChanged("caption")) {
        updateCaptionNodeWidth(widget);
    }

    if (isContextHelpIconEnabled(getState())) {
        if (getWidget().contextHelpIcon == null) {
            getWidget().contextHelpIcon = DOM.createSpan();
            getWidget().contextHelpIcon.setInnerHTML("?");
            getWidget().contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME);

            if (hasContextHelpIconListeners(getState())) {
                getWidget().contextHelpIcon.addClassName(CONTEXT_HELP_CLICKABLE_CLASSNAME);
            }

            Roles.getTextboxRole().setAriaHiddenState(getWidget().contextHelpIcon, true);

            getWidget().captionNode.appendChild(getWidget().contextHelpIcon);
            DOM.sinkEvents(getWidget().contextHelpIcon, VTooltip.TOOLTIP_EVENTS | Event.ONCLICK);

            getWidget().contextHelpClickHandler = this::contextHelpIconClick;
        } else {
            getWidget().contextHelpIcon.getStyle().clearDisplay();

            updateCaptionNodeWidth(widget);
        }
    } else if (getWidget().contextHelpIcon != null) {
        getWidget().contextHelpIcon.getStyle().setDisplay(Style.Display.NONE);

        updateCaptionNodeWidth(widget);
    }

    if (getState().requiredIndicatorVisible) {
        if (getWidget().requiredIcon == null) {
            getWidget().requiredIcon = DOM.createSpan();
            getWidget().requiredIcon.setInnerHTML("*");
            getWidget().requiredIcon.setClassName(REQUIRED_INDICATOR_CLASSNAME);

            // The star should not be read by the screen reader, as it is
            // purely visual. Required state is set at the element level for
            // the screen reader.
            Roles.getTextboxRole().setAriaHiddenState(getWidget().requiredIcon, true);

            getWidget().captionNode.appendChild(getWidget().requiredIcon);
            DOM.sinkEvents(getWidget().requiredIcon, VTooltip.TOOLTIP_EVENTS);
        } else {
            getWidget().requiredIcon.getStyle().clearDisplay();

            updateCaptionNodeWidth(widget);
        }
    } else if (getWidget().requiredIcon != null) {
        getWidget().requiredIcon.getStyle().setDisplay(Style.Display.NONE);

        updateCaptionNodeWidth(widget);
    }
}
 
Example 9
Source File: BaseCheckBox.java    From gwt-material with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a check box with no label.
 */
public BaseCheckBox() {
    this(DOM.createSpan());
}
 
Example 10
Source File: AriaStatus.java    From unitime with Apache License 2.0 4 votes vote down vote up
public AriaStatus(boolean assertive) {
	this(DOM.createSpan(), assertive);
}
 
Example 11
Source File: FlowForm.java    From unitime with Apache License 2.0 4 votes vote down vote up
public int addHeaderRow(Widget widget) {
	P row = new P(DOM.createSpan(), "row-cell", "unitime-MainTableHeader");
	row.add(widget);
	add(row);
	return getWidgetCount() - 1;
}
 
Example 12
Source File: FlowForm.java    From unitime with Apache License 2.0 4 votes vote down vote up
public int addRow(Widget widget) {
	P row = new P(DOM.createSpan(), "row-cell");
	row.add(widget);
	add(row);
	return getWidgetCount() - 1;
}