Search in sources :

Example 81 with Widget

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

the class MaterialCollection method setActive.

@Override
public void setActive(int index, boolean value) {
    this.index = index;
    Widget activeWidget = getActive();
    if (activeWidget != null) {
        if (index <= getWidgetCount()) {
            if (index != 0) {
                clearActiveClass(this);
                if (activeWidget instanceof MaterialCollectionItem) {
                    ((MaterialCollectionItem) activeWidget).setActive(value);
                }
            } else {
                throw new IllegalArgumentException("The active index must be a one-base index to mark as active.");
            }
        }
    }
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) MaterialWidget(gwt.material.design.client.base.MaterialWidget)

Example 82 with Widget

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

the class MaterialCollectionItem method onLoad.

@Override
protected void onLoad() {
    super.onLoad();
    HandlerRegistration handlerRegistration = addClickHandler(event -> {
        // been clicked to avoid duplicate events.
        if (Element.as(event.getNativeEvent().getEventTarget()) != getElement()) {
            if (getType() == CollectionType.CHECKBOX) {
                event.stopPropagation();
                event.preventDefault();
            }
        }
        for (Widget w : MaterialCollectionItem.this) {
            if (w instanceof MaterialCollectionSecondary) {
                for (Widget a : (MaterialCollectionSecondary) w) {
                    if (a instanceof HasValue) {
                        try {
                            @SuppressWarnings("unchecked") HasValue<Boolean> cb = (HasValue<Boolean>) a;
                            if (cb.getValue()) {
                                cb.setValue(false);
                            } else {
                                cb.setValue(true);
                            }
                        } catch (ClassCastException ex) {
                        // Ignore non-boolean has value handlers.
                        }
                    }
                }
            }
        }
    });
    registerHandler(handlerRegistration);
    JsMaterialElement.initDismissableCollection();
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) Widget(com.google.gwt.user.client.ui.Widget) HasValue(com.google.gwt.user.client.ui.HasValue)

Example 83 with Widget

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

the class MaterialDropDown method registerDropdownItemHandlers.

protected void registerDropdownItemHandlers() {
    getChildren().forEach(widget -> {
        if (widget instanceof ListItem) {
            ListItem item = (ListItem) widget;
            if (item.getWidgetCount() > 0) {
                if (item.getWidget(0) instanceof MaterialWidget) {
                    MaterialWidget child = (MaterialWidget) item.getWidget(0);
                    registerHandler(child.addDomHandler(event -> {
                        SelectionEvent.fire(MaterialDropDown.this, child);
                    }, ClickEvent.getType()));
                }
            }
        }
    });
}
Also used : CssName(gwt.material.design.client.constants.CssName) DomEvent(com.google.gwt.event.dom.client.DomEvent) ListItem(gwt.material.design.client.ui.html.ListItem) DOM(com.google.gwt.user.client.DOM) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) SelectionEvent(com.google.gwt.event.logical.shared.SelectionEvent) HasSelectionHandlers(com.google.gwt.event.logical.shared.HasSelectionHandlers) HasEnabled(com.google.gwt.user.client.ui.HasEnabled) GWT(com.google.gwt.core.client.GWT) DOMHelper(gwt.material.design.client.base.helper.DOMHelper) JsDropdownOptions(gwt.material.design.client.js.JsDropdownOptions) HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) SelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler) UnorderedList(gwt.material.design.client.ui.html.UnorderedList) Widget(com.google.gwt.user.client.ui.Widget) List(java.util.List) Style(com.google.gwt.dom.client.Style) UIObject(com.google.gwt.user.client.ui.UIObject) Element(com.google.gwt.dom.client.Element) gwt.material.design.client.base(gwt.material.design.client.base) JsMaterialElement.$(gwt.material.design.client.js.JsMaterialElement.$) UiConstructor(com.google.gwt.uibinder.client.UiConstructor) Alignment(gwt.material.design.client.constants.Alignment) ListItem(gwt.material.design.client.ui.html.ListItem)

Example 84 with Widget

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

the class MaterialDropDown method load.

@Override
public void load() {
    Widget parent = getParent();
    if (parent instanceof HasActivates) {
        String uid = DOM.createUniqueId();
        ((HasActivates) parent).setActivates(uid);
        setId(uid);
        activatorElement = parent.getElement();
    } else if (activatorElement == null) {
        activatorElement = DOMHelper.getElementByAttribute("data-activates", activator);
        if (activatorElement == null) {
            GWT.log("There is no activator element with id: '" + activator + "' in the DOM, " + "cannot instantiate MaterialDropDown without a data-activates.", new IllegalStateException());
        }
    }
    $(activatorElement).dropdown(options);
}
Also used : Widget(com.google.gwt.user.client.ui.Widget)

Example 85 with Widget

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

the class MaterialCollapsibleBody method add.

@Override
public void add(final Widget child) {
    if (child instanceof UnorderedList) {
        for (Widget w : (UnorderedList) child) {
            if (w instanceof ListItem) {
                w.getElement().getStyle().setDisplay(Style.Display.BLOCK);
                provideActiveClickHandler(w);
            }
        }
    } else if (child instanceof ListItem) {
        child.getElement().getStyle().setDisplay(Style.Display.BLOCK);
        provideActiveClickHandler(child);
    }
    super.add(child);
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) MaterialWidget(gwt.material.design.client.base.MaterialWidget) UnorderedList(gwt.material.design.client.ui.html.UnorderedList) ListItem(gwt.material.design.client.ui.html.ListItem)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)194 Test (org.junit.Test)22 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)16 IsWidget (com.google.gwt.user.client.ui.IsWidget)16 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)15 HTML (com.google.gwt.user.client.ui.HTML)10 ArrayList (java.util.ArrayList)10 IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)10 Element (com.google.gwt.dom.client.Element)9 MaterialWidget (gwt.material.design.client.base.MaterialWidget)9 Label (com.google.gwt.user.client.ui.Label)8 ListItem (gwt.material.design.client.ui.html.ListItem)8 ListBox (org.gwtbootstrap3.client.ui.ListBox)8 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)7 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)7 Command (com.google.gwt.user.client.Command)7 FileItem (org.pentaho.mantle.client.solutionbrowser.filelist.FileItem)7 Image (com.google.gwt.user.client.ui.Image)6 CubaFileUploadWidget (com.haulmont.cuba.web.toolkit.ui.client.jqueryfileupload.CubaFileUploadWidget)6 Timer (com.google.gwt.user.client.Timer)5