Search in sources :

Example 11 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project kie-wb-common by kiegroup.

the class ContainerListGroupItemTest method setup.

@Before
public void setup() throws Exception {
    text.clear();
    child = null;
    beforeIndex = -1;
    customGroupItem = new ContainerListGroupItem("item", command) {

        public void setText(final String value) {
            text.add(value);
        }

        public String getText() {
            return text.get(0);
        }

        public void insert(final Widget _child, final int _beforeIndex) {
            child = _child;
            beforeIndex = _beforeIndex;
        }

        public HandlerRegistration addClickHandler(final ClickHandler handler) {
            clickHandler = handler;
            return new HandlerRegistration() {

                @Override
                public void removeHandler() {
                }
            };
        }
    };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Widget(com.google.gwt.user.client.ui.Widget) Before(org.junit.Before)

Example 12 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project activityinfo by bedatadriven.

the class FilterPanelSet method ensureHandlers.

private HandlerManager ensureHandlers() {
    if (manager == null) {
        manager = new HandlerManager(this);
        myRegistrations = new ArrayList<HandlerRegistration>();
        for (FilterPanel panel : panels) {
            HandlerRegistration registration = panel.addValueChangeHandler(new ValueChangeHandler<Filter>() {

                @Override
                public void onValueChange(ValueChangeEvent<Filter> event) {
                    // or indicator (reports) is selected
                    if (event.getSource() instanceof ActivityFilterPanel || event.getSource() instanceof IndicatorFilterPanel) {
                        clearAttributeAndPartnerFilters();
                    }
                    Filter value = composeFilter(new Filter(), null);
                    Log.debug("FilterPanelSet: Filter changed = " + value);
                    ValueChangeEvent.fire(FilterPanelSet.this, value);
                }
            });
            myRegistrations.add(registration);
        }
    }
    return manager;
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) ActivityFilterPanel(org.activityinfo.ui.client.page.entry.ActivityFilterPanel) Filter(org.activityinfo.legacy.shared.command.Filter) HandlerManager(com.google.gwt.event.shared.HandlerManager) ActivityFilterPanel(org.activityinfo.ui.client.page.entry.ActivityFilterPanel)

Example 13 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project lienzo-core by ahome-it.

the class WiresLayoutContainer method add.

@Override
public WiresLayoutContainer add(final IPrimitive<?> child, final LayoutContainer.Layout layout) {
    if (null == child) {
        throw new NullPointerException("Child cannot be null.");
    }
    if (null == child.getID()) {
        child.setID(UUID.uuid());
    }
    addChild(child);
    if (null != layout) {
        final ChildEntry entry = new ChildEntry(child.getID(), layout);
        children.add(entry);
        for (final Attribute attribute : child.getTransformingAttributes()) {
            final HandlerRegistration reg = child.addAttributesChangedHandler(attribute, ShapeAttributesChangedHandler);
            registrations.put(new ObjectAttribute(child, attribute), reg);
            attrHandlerRegs.register(reg);
        }
        doPositionChild(child, true);
    }
    return this;
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) Attribute(com.ait.lienzo.client.core.Attribute)

Example 14 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration 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 15 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project ovirt-engine by oVirt.

the class BaseListModelSuggestBox method addValueChangeHandler.

@Override
public HandlerRegistration addValueChangeHandler(final ValueChangeHandler<T> handler) {
    HandlerRegistration handlerRegistration = asSuggestBox().addValueChangeHandler(event -> {
        try {
            T value = asEntity(event.getValue());
            handler.onValueChange(new ValueChangeEvent<T>(value) {
            });
        } catch (IllegalArgumentException e) {
        // ignore - the user entered an incorrect string. Just do not notify the listeners
        }
    });
    handlerRegistrations.add(handlerRegistration);
    return handlerRegistration;
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration)

Aggregations

HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)48 Test (org.junit.Test)7 MouseEvent (com.google.gwt.event.dom.client.MouseEvent)4 ViewEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent)4 NodeMouseEnterEvent (com.ait.lienzo.client.core.event.NodeMouseEnterEvent)2 NodeMouseEnterHandler (com.ait.lienzo.client.core.event.NodeMouseEnterHandler)2 NodeMouseExitEvent (com.ait.lienzo.client.core.event.NodeMouseExitEvent)2 NodeMouseExitHandler (com.ait.lienzo.client.core.event.NodeMouseExitHandler)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 Widget (com.google.gwt.user.client.ui.Widget)2 Map (java.util.Map)2 MouseDoubleClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent)2 MouseEnterEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseEnterEvent)2 CommandWithArg (org.rstudio.core.client.CommandWithArg)2 Mutable (org.rstudio.core.client.Mutable)2 Attribute (com.ait.lienzo.client.core.Attribute)1 AbstractNodeGestureEvent (com.ait.lienzo.client.core.event.AbstractNodeGestureEvent)1 NodeGestureChangeEvent (com.ait.lienzo.client.core.event.NodeGestureChangeEvent)1 NodeGestureChangeHandler (com.ait.lienzo.client.core.event.NodeGestureChangeHandler)1