Java Code Examples for com.google.gwt.user.client.ui.Widget#asWidgetOrNull()

The following examples show how to use com.google.gwt.user.client.ui.Widget#asWidgetOrNull() . These examples are extracted from open source projects. 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
private void addIfNotNull(Editor e, int size, int offset, boolean wrap) {
	if (e instanceof IsWidget) {
		boolean wrapInCol = wrap;
		wrapInCol &= this.type == Layout.HORIZONTAL;

		Widget toAdd = Widget.asWidgetOrNull((IsWidget) e);
		if (wrapInCol) {
			GridColumn column = new GridColumn();
			column.add(toAdd);
			column.setSize(size);
			column.setOffset(offset);
			toAdd = column;
		}
		if (this.type == Layout.HORIZONTAL) {
			if (size > 0) {
				StyleUtils.addStyle(toAdd, new GridColumn.SizeStyle(GridColumn.PREFIX_SIZE_MD, size));
			}
			if (offset > 0) {
				StyleUtils.addStyle(toAdd, new GridColumn.OffsetStyle(GridColumn.PREFIX_OFFSET_MD, offset));
			}
		}
		this.append(toAdd);
	}
}
 
Example 2
@Override
public void setWidget(IsWidget w) {
    Widget asWidget = Widget.asWidgetOrNull(w);
    if (asWidget instanceof Canvas) {
        ClientUtils.setMembers(display, (Canvas) asWidget);
    } else if (asWidget == null) {
        display.removeMembers(display.getMembers());
    } else {
        throw new IllegalStateException("Unsupported widget: " + asWidget.getClass());
    }
}
 
Example 3
@Override
public void setWidget(IsWidget w) {
    Widget asWidget = Widget.asWidgetOrNull(w);
    if (asWidget instanceof Canvas) {
        ClientUtils.setMembers(display, (Canvas) asWidget);
    } else if (asWidget == null) {
        display.removeMembers(display.getMembers());
    } else {
        throw new IllegalStateException("Unsupported widget: " + asWidget.getClass());
    }
}