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() . 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: FormGroup.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
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
Source File: DigitalObjectChildrenEditor.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@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
Source File: EditorWorkFlow.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@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());
    }
}