Example usage for com.google.gwt.event.logical.shared ValueChangeEvent fireIfNotEqual

List of usage examples for com.google.gwt.event.logical.shared ValueChangeEvent fireIfNotEqual

Introduction

In this page you can find the example usage for com.google.gwt.event.logical.shared ValueChangeEvent fireIfNotEqual.

Prototype

public static <T> void fireIfNotEqual(HasValueChangeHandlers<T> source, T oldValue, T newValue) 

Source Link

Document

Fires value change event if the old value is not equal to the new value.

Usage

From source file:com.arcbees.chosen.client.gwt.ChosenValueListBox.java

License:Apache License

private void setValue(T newValue, boolean fireEvents, boolean update) {
    Preconditions.checkState(isAccepted(newValue),
            "This value is not in the acceptable values " + "list of this component");

    if (Objects.equals(newValue, value)) {
        return;//from   ww  w  . j ava2 s.  c o m
    }

    T before = value;
    value = newValue;

    if (update) {
        updateChosenListBox();
    }

    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, before, value);
    }
}

From source file:com.dianaui.universal.core.client.ui.CheckBoxButton.java

License:Apache License

@Override
public void onBrowserEvent(Event event) {
    boolean oldValue = getValue();

    switch (DOM.eventGetType(event)) {
    case Event.ONCLICK:
        setValue(!getValue(), false);//w  w  w  .  ja  va2  s . c o  m

        ValueChangeEvent.fireIfNotEqual(CheckBoxButton.this, oldValue, getValue());
        break;
    default:
        super.onBrowserEvent(event);
        break;
    }
}

From source file:com.dianaui.universal.core.client.ui.gwt.RichTextArea.java

License:Apache License

@Override
public void setValue(String value, boolean fireEvents) {
    setHTML(value);//www  . ja v a  2s.com
    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, getHTML(), value);
    }
}

From source file:com.dianaui.universal.core.client.ui.gwt.SimpleRadioButton.java

License:Apache License

/**
 * Overridden to send ValueChangeEvents only when appropriate.
 *//*from   w w  w .  j  ava 2 s.  c o m*/
@Override
public void onBrowserEvent(Event event) {
    switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEUP:
    case Event.ONBLUR:
    case Event.ONKEYDOWN:
        // Note the old value for onValueChange purposes (in ONCLICK case)
        oldValue = getValue();
        break;

    case Event.ONCLICK:
        // Let our handlers hear about the click...
        super.onBrowserEvent(event);
        // ...and now maybe tell them about the change
        ValueChangeEvent.fireIfNotEqual(SimpleRadioButton.this, oldValue, getValue());
        return;
    }

    super.onBrowserEvent(event);
}

From source file:com.dianaui.universal.core.client.ui.Radio.java

License:Apache License

/**
 * Overridden to send ValueChangeEvents only when appropriate.
 *///from  ww  w . ja v a  2 s.c o m
@Override
public void onBrowserEvent(Event event) {
    switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEUP:
    case Event.ONBLUR:
    case Event.ONKEYDOWN:
        // Note the old value for onValueChange purposes (in ONCLICK case)
        oldValue = getValue();
        break;

    case Event.ONCLICK:
        EventTarget target = event.getEventTarget();
        if (Element.is(target) && labelElem.isOrHasChild(Element.as(target))) {

            // They clicked the label. Note our pre-click value, and
            // short circuit event routing so that other click handlers
            // don't hear about it
            oldValue = getValue();
            return;
        }

        // It's not the label. Let our handlers hear about the
        // click...
        super.onBrowserEvent(event);
        // ...and now maybe tell them about the change
        ValueChangeEvent.fireIfNotEqual(Radio.this, oldValue, getValue());
        return;
    }

    super.onBrowserEvent(event);
}

From source file:com.dianaui.universal.core.client.ui.RadioButton.java

License:Apache License

@Override
public void onBrowserEvent(Event event) {
    boolean oldValue = getValue();

    switch (DOM.eventGetType(event)) {
    case Event.ONCLICK:
        setValue(!getValue(), false);//from w  w  w  .  j a  v a  2s .  co m

        if (getParent() != null && getParent() instanceof ButtonGroup) {
            ButtonGroup group = (ButtonGroup) getParent();
            for (int i = 0; i < ((ButtonGroup) getParent()).getWidgetCount(); i++) {
                if (group.getWidget(i) instanceof RadioButton && group.getWidget(i) != this) {
                    ((RadioButton) group.getWidget(i)).setValue(false, false);
                }
            }
        }
        ValueChangeEvent.fireIfNotEqual(RadioButton.this, oldValue, getValue());
        break;
    default:
        super.onBrowserEvent(event);
        break;
    }
}

From source file:com.dianaui.universal.core.client.ui.TabContent.java

License:Apache License

public void selectTab(final int index) {
    for (int i = 0; i < getWidgetCount(); i++) {
        final TabPane tab = (TabPane) getWidget(i);

        if (tab.isActive()) {
            tab.setActive(false);//w w w.jav  a 2s . c om
        }
    }

    ((TabPane) getWidget(index)).setActive(true);

    ValueChangeEvent.fireIfNotEqual(this, selected, index);

    this.selected = index;
}

From source file:com.gafactory.core.client.ui.widgets.ValueListBoxSelect.java

License:Apache License

public void setValue(T value, boolean fireEvents) {
    if (value == this.value || (this.value != null && this.value.equals(value))) {
        return;//from w ww . j  a  v a  2  s.com
    }

    T before = this.value;
    this.value = value;
    updateListBox();

    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, before, value);
    }
}

From source file:com.github.gwt.user.client.ui.DateTimeBox.java

License:Apache License

@Override
public void setValue(Date value, boolean fireEvents) {
    Date oldValue = box.getDate();
    box.setDate(value);//from   w  ww .j a  v a2s . c om
    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, oldValue, value);
    }
}

From source file:com.github.gwtbootstrap.client.ui.RadioButton.java

License:Apache License

/**
 * Overridden to send ValueChangeEvents only when appropriate.
 *///www  .  ja va  2  s. c  o  m
@Override
public void onBrowserEvent(Event event) {

    switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEUP:
    case Event.ONBLUR:
    case Event.ONKEYDOWN:
        // Note the old value for onValueChange purposes (in ONCLICK case)
        oldValue = getValue();
        break;

    case Event.ONCLICK:
        EventTarget target = event.getEventTarget();

        if (Element.is(target) && !Element.as(target).getTagName().toUpperCase().equals("INPUT")
                && asLabel().isOrHasChild(Element.as(target))) {
            GWT.log("test");
            // They clicked the label. Note our pre-click value, and
            // short circuit event routing so that other click handlers
            // don't hear about it
            oldValue = getValue();
            return;
        }

        // It's not the label. Let our handlers hear about the
        // click...
        super.onBrowserEvent(event);
        // ...and now maybe tell them about the change
        ValueChangeEvent.fireIfNotEqual(RadioButton.this, oldValue, getValue());
        return;
    }
    super.onBrowserEvent(event);
}