Search in sources :

Example 1 with HasWidgets

use of com.google.gwt.user.client.ui.HasWidgets in project gwt-material by GwtMaterialDesign.

the class MaterialCollapsibleBody method checkActiveState.

/**
 * 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);
        }
    }
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) MaterialWidget(gwt.material.design.client.base.MaterialWidget) ListItem(gwt.material.design.client.ui.html.ListItem) HasWidgets(com.google.gwt.user.client.ui.HasWidgets)

Aggregations

HasWidgets (com.google.gwt.user.client.ui.HasWidgets)1 Widget (com.google.gwt.user.client.ui.Widget)1 MaterialWidget (gwt.material.design.client.base.MaterialWidget)1 ListItem (gwt.material.design.client.ui.html.ListItem)1