com.google.gwt.user.client.ui.HasWidgets Java Examples

The following examples show how to use com.google.gwt.user.client.ui.HasWidgets. 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: QuestionFieldGroup.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
protected void lookForChildren(Widget parent) {
    Widget result = parent;
    if (parent instanceof Composite) {
        Composite composite = (Composite) parent;
        result = composite.asWidget();
    }

    if (result instanceof HasWidgets) {
        for (Widget widget : ((HasWidgets) result)) {
            if (widget instanceof QuestionItem) {
                ((QuestionItem) widget).setAllowBlank(false);
                questions.add((QuestionItem) widget);
            } else {
                lookForChildren(widget);
            }
        }
    }
}
 
Example #2
Source File: MaterialCollapsibleBody.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if this child holds the current active state.
 * If the child is or contains the active state it is applied.
 */
protected void checkActiveState(Widget child) {
    // Check if this widget has a valid href
    String href = child.getElement().getAttribute("href");
    String url = Window.Location.getHref();
    int pos = url.indexOf("#");
    String location = pos >= 0 ? url.substring(pos, url.length()) : "";

    if (!href.isEmpty() && location.startsWith(href)) {
        ListItem li = findListItemParent(child);
        if (li != null) {
            makeActive(li);
        }
    } else if (child instanceof HasWidgets) {
        // Recursive check
        for (Widget w : (HasWidgets) child) {
            checkActiveState(w);
        }
    }
}
 
Example #3
Source File: VPopupButton.java    From cuba with Apache License 2.0 6 votes vote down vote up
private void checkForRTE(Widget popupComponentWidget2) {
    if (popupComponentWidget2 instanceof VRichTextArea) {
        ComponentConnector rtaConnector = Util
                .findConnectorFor(popupComponentWidget2);
        if (rtaConnector != null) {
            rtaConnector.flush();
        }
    } else if (popupComponentWidget2 instanceof Grid) {
        // Grid implements HasWidgets but iterator() throws
        // UnsupportedOperationException so don't do anything
        // in case of Grid.
    } else if (popupComponentWidget2 instanceof HasWidgets) {
        HasWidgets hw = (HasWidgets) popupComponentWidget2;
        Iterator<Widget> iterator = hw.iterator();
        while (iterator.hasNext()) {
            checkForRTE(iterator.next());
        }
    }
}
 
Example #4
Source File: DefaultDirtyValidator.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
/**
 * Will check all components that extends to {@link HasValue} and
 * registers a {@link com.google.gwt.event.logical.shared.ValueChangeEvent}.
 * Once value has been changed then we mark that our content wrapping it is dirty.
 */
protected void detectDirtyFields(Widget parent) {
    if (parent instanceof HasWidgets) {
        for (Widget widget : (HasWidgets) parent) {
            if (widget instanceof HasValue) {
                HasValue valueWidget = (HasValue) widget;
                registrations.add(valueWidget.addValueChangeHandler(event -> {
                    if (valueWidget.getValue() != null && ! valueWidget.getValue().equals("")) {
                        setDirty(true);
                    }
                }));
            } else {
                if (propagateToChildren) {
                    detectDirtyFields(widget);
                }
            }
        }
    }
}
 
Example #5
Source File: DefaultErrorHandler.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
/**
 * Find the sibling {@link MaterialHelpBlock}.
 *
 * @param widget the {@link Widget} to search.
 * @return the found {@link MaterialHelpBlock} of null if not found.
 */
protected MaterialHelpBlock findHelpBlock(Widget widget) {
    if (widget != null) {
        if (widget instanceof MaterialHelpBlock) {
            return (MaterialHelpBlock) widget;
        }
        // Try and find the MaterialHelpBlock in the children of the given widget.
        if (widget instanceof HasWidgets) {
            for (Widget w : (HasWidgets) widget) {
                if (w instanceof MaterialHelpBlock) {
                    return (MaterialHelpBlock) w;
                }
            }
        }
        // Try and find the MaterialHelpBlock in the parent of widget.
        return findHelpBlock(widget.getParent());
    }
    return null;
}
 
Example #6
Source File: MonitorPresenter.java    From EasyML with Apache License 2.0 5 votes vote down vote up
@Override
public void go(final HasWidgets container) {
	bind();
	container.clear();
	container.add(view.asWidget());
	init();
}
 
Example #7
Source File: Modal.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Widget getContainerWidget() {
	if (containerWidget == null) {
		if (getParent() instanceof HasWidgets) {
			containerWidget = this;
		} else if (getParent() instanceof Composite) {
			containerWidget = getParent();
		}
	}
	return containerWidget;
}
 
Example #8
Source File: MaterialCollapsible.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
protected void clearActiveClass(HasWidgets widget) {
    super.clearActiveClass(widget);

    for (Widget child : widget) {
        if (child instanceof MaterialCollapsibleBody) {
            ((MaterialCollapsibleBody) child).setDisplay(Display.NONE);
        }
    }
}
 
Example #9
Source File: ResetFieldMixin.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
protected void reset(Widget parent) {
    if (parent instanceof HasWidgets) {
        for (Widget child : (HasWidgets) parent) {
            if (child instanceof AbstractValueWidget) {
                ((AbstractValueWidget) child).reset();
            }
            else if (propagateToChildren) {
                reset(child);
            }
        }
    }
}
 
Example #10
Source File: StatusDisplayMixin.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public void updateStatusDisplay(StatusType statusType) {
    if (displayType == StatusDisplayType.HOVERABLE) {

        if (!statusIcon.getElement().hasClassName(CssName.STATUS_ICON)) {
            statusIcon.addStyleName(CssName.STATUS_ICON);
        }

        if (statusType == StatusType.ERROR) {
            statusIcon.setIconType(IconType.ERROR);
            statusIcon.setIconColor(Color.RED);
        } else {
            statusIcon.setIconType(IconType.CHECK_CIRCLE);
            statusIcon.setIconColor(Color.GREEN);
        }

        if (uiObject instanceof HasWidgets && uiObject instanceof MaterialWidget) {
            if (container != null && container instanceof MaterialWidget) {
                ((MaterialWidget) container).insert(statusIcon, 0);
            } else {
                ((HasWidgets) uiObject).add(statusIcon);
            }

            registerHandlers();
        }
    } else {
        resetStatusDisplay();
    }
}
 
Example #11
Source File: DOMHelper.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
public static Widget getChildWidgetById(HasWidgets parent, String id) {
    if (parent != null) {
        for (Widget child : parent) {
            if (child.getElement().getId().equals(id)) {
                return child;
            }
        }
    }
    return null;
}
 
Example #12
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void recursiveAddFocusHandler(final Widget w, final Widget topWidget) {
    if (w instanceof HasWidgets) {
        for (Widget child : (HasWidgets) w) {
            recursiveAddFocusHandler(child, topWidget);
        }
    }

    if (w instanceof HasFocusHandlers) {
        ((HasFocusHandlers) w).addFocusHandler(e ->
                handleFocusAndClickEvents(e, topWidget));
    }
}
 
Example #13
Source File: AccountPresenter.java    From EasyML with Apache License 2.0 5 votes vote down vote up
@Override
public void go(HasWidgets container) {
	bind();
	container.clear();
	container.add(accountView.asWidget());
	init();
}
 
Example #14
Source File: AppController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public void go(final HasWidgets container) {
	logger.info("app view going...");
	this.container = container;

	if ("".equals(History.getToken())) {
		History.newItem("monitor");
	} else {
		History.fireCurrentHistoryState();
	}
}
 
Example #15
Source File: AdminPresenter.java    From EasyML with Apache License 2.0 4 votes vote down vote up
@Override
public void go(HasWidgets container) {
	container.clear();
	container.add(adminView.asWidget());
	init();
}
 
Example #16
Source File: BitcoinJSONViewer.java    From bitcoin-transaction-explorer with MIT License 4 votes vote down vote up
private void drawString(final HasWidgets container, final String stringValue) {
  container.add(new HTML(nl2br(SafeHtmlUtils.fromString(stringValue))));
}
 
Example #17
Source File: ContactsPresenter.java    From gwteventbinder with Apache License 2.0 4 votes vote down vote up
void setView(HasWidgets view) {
  this.view = view;
}
 
Example #18
Source File: TableWidget.java    From cuba with Apache License 2.0 votes vote down vote up
HasWidgets getRenderedRowByKey(String key); 
Example #19
Source File: Presenter.java    From EasyML with Apache License 2.0 votes vote down vote up
void go(final HasWidgets container);