Java Code Examples for com.google.gwt.event.logical.shared.ValueChangeEvent#fireIfNotEqual()

The following examples show how to use com.google.gwt.event.logical.shared.ValueChangeEvent#fireIfNotEqual() . 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: MaterialListValueBox.java    From gwt-material with Apache License 2.0 6 votes vote down vote up
@Override
public void setValue(T value, boolean fireEvents) {
    if (value == null) {
        reset();

        if (fireEvents) {
            ValueChangeEvent.fire(this, null);
        }
    } else {
        int index = values.indexOf(value);
        if (index < 0 && value instanceof String) {
            index = getIndexByString((String) value);
        }

        if (index > -1) {
            T before = getValue();
            setSelectedIndexInternal(index);

            if (fireEvents) {
                ValueChangeEvent.fireIfNotEqual(this, before, value);
            }
        }
    }
}
 
Example 2
Source File: InputSelect.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setSelection(T selection, boolean fireEvents) {
	T oldValue = this.selectedItem;
	NavLink currentSelection = InputSelect.this.getItemsLinks().get(this.selectedItem);
	if (currentSelection != null) {
		currentSelection.setActive(false);
	}
	NavLink newSelection = InputSelect.this.getItemsLinks().get(selection);
	if (newSelection != null) {
		newSelection.setActive(true);
	}
	this.selectedItem = selection;
	this.scrollToSelected();
	if (fireEvents) {
		ValueChangeEvent.fireIfNotEqual(InputSelect.this, oldValue, selection);
	}
}
 
Example 3
Source File: SliderBase.java    From gwtbootstrap3-extras with Apache License 2.0 6 votes vote down vote up
@Override
public void setValue(final T value, final boolean fireEvents) {

    T oldValue = fireEvents ? getValue() : null;

    if (isAttached()) {
        setValue(getElement(), value);
    } else {
        String attrVal = (value == null) ? null : value.toString();
        attributeMixin.setAttribute(SliderOption.VALUE.getDataAttribute(), attrVal);
    }

    if (fireEvents) {
        T newValue = getValue();
        ValueChangeEvent.fireIfNotEqual(this, oldValue, newValue);
    }
}
 
Example 4
Source File: MaterialImage.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
@Override
public void setValue(String value, boolean fireEvents) {
    String oldValue = getUrl();
    getImageMixin().setUrl(value);

    if(fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, oldValue, value);
    }
}
 
Example 5
Source File: InputDatePicker.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setValue(Date value, boolean fireEvents) {
	if (fireEvents) {
		ValueChangeEvent.fireIfNotEqual(this, this.value, value);
		this.setFocus(true);
	}
	if (value == null) {
		this.value = null;
		this.cursor = new Date(this.today.getTime());
	} else {
		this.value = new Date(value.getTime());
		this.cursor = new Date(value.getTime());
	}
	this.redraw();
}
 
Example 6
Source File: InputSwitch.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setSelection(T selection, boolean fireEvents) {
	T oldValue = this.selectedItem;
	InputSwitch.this.resetSlider(selection);
	this.selectedItem = selection;
	if (fireEvents) {
		ValueChangeEvent.fireIfNotEqual(InputSwitch.this, oldValue, selection);
	}
}
 
Example 7
Source File: InputSlider.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void moveHandleToIndex(int index, boolean fireEvent) {
	T oldValue = this.getValue();

	int newIndex = Math.min(InputSlider.this.items.size() - 1, Math.max(0, index));
	this.valueIndex = newIndex;
	double position = newIndex * 100d / (InputSlider.this.items.size() - 1d);
	this.setLeftPct(position);

	if (fireEvent) {
		ValueChangeEvent.fireIfNotEqual(InputSlider.this, oldValue, this.getValue());
	}
}
 
Example 8
Source File: InputRadio.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setSelection(T selection, boolean fireEvents) {
	T oldValue = this.selectedItem;
	RadioContainer newSelection = InputRadio.this.itemsContainer.get(selection);
	if (newSelection != null) {
		newSelection.select();
	}
	this.selectedItem = selection;
	if (fireEvents) {
		ValueChangeEvent.fireIfNotEqual(InputRadio.this, oldValue, selection);
	}
}
 
Example 9
Source File: InputSuggest.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void handleSuggestionSelected(IsWidget textInput, Oracle.Suggestion<T> suggestion) {
	TextBox input = (TextBox) textInput;
	T value = suggestion.getValue();
	String replacementString = getRenderer().render(value);
	input.setText(replacementString);
	input.setCursorPos(replacementString.length());

	T oldValue = InputSuggest.this.currentValue;
	InputSuggest.this.currentValue = value;
	ValueChangeEvent.fireIfNotEqual(InputSuggest.this, oldValue, value);
}
 
Example 10
Source File: SelectBase.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
@Override
public void setValue(final T value, final boolean fireEvents) {

    T oldValue = fireEvents ? getValue() : null;

    setSelectedValue(value);

    if (fireEvents) {
        T newValue = getValue();
        ValueChangeEvent.fireIfNotEqual(this, oldValue, newValue);
    }
}
 
Example 11
Source File: ToggleSwitchBase.java    From gwtbootstrap3-extras with Apache License 2.0 5 votes vote down vote up
@Override
public void setValue(final Boolean value, final boolean fireEvents) {
    Boolean oldValue = getValue();
    if (isAttached()) {
        switchState(getElement(), value, true);
    } else {
        element.setChecked(value);
    }
    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(ToggleSwitchBase.this, oldValue, value);
    }
}
 
Example 12
Source File: InputWidget.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
private void fireValueChangeHandler(String value) {
    ValueChangeEvent.fireIfNotEqual(this, lastValue, value);
    lastValue = value;
}