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

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

Introduction

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

Prototype

public static <T> void fire(HasValueChangeHandlers<T> source, T value) 

Source Link

Document

Fires a value change event on all registered handlers in the handler manager.

Usage

From source file:ar.com.kyol.jet.client.wrappers.DateBoxWrapper.java

License:Open Source License

/**
 * Instantiates a new date box wrapper./*from   www .j ava2  s .co  m*/
 *
 * @param date the date
 * @param objSetter the obj setter
 * @param dateBox the date box
 * @param useValueAsString the use value as string
 */
public DateBoxWrapper(Date date, ObjectSetter objSetter, final DateBox dateBox, boolean useValueAsString) {
    super(useValueAsString);
    this.dateBox = dateBox;
    this.date = date;
    this.objSetter = objSetter;
    dateBox.setValue(this.date);
    String format = "dd/MM/yyyy";
    if (objSetter.getFormat() != null && !objSetter.getFormat().equals("")) {
        format = objSetter.getFormat();
    }
    dateBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat(format)));

    dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() {

        @Override
        @SuppressWarnings("rawtypes")
        public void onValueChange(ValueChangeEvent<Date> arg0) {
            if (DateBoxWrapper.this.date == null) {
                ClassType cType = TypeOracle.Instance
                        .getClassType(DateBoxWrapper.this.objSetter.getObj().getClass());
                DateBoxWrapper.this.date = new Date();
                cType.invoke(DateBoxWrapper.this.objSetter.getObj(), DateBoxWrapper.this.objSetter.getSetter(),
                        new Object[] { DateBoxWrapper.this.date });
            }

            if (DateBoxWrapper.this.dateBox.getValue() != null) {
                DateBoxWrapper.this.date.setTime(DateBoxWrapper.this.dateBox.getValue().getTime());
            } else {
                DateBoxWrapper.this.date = null;
                ClassType cType = TypeOracle.Instance
                        .getClassType(DateBoxWrapper.this.objSetter.getObj().getClass());
                cType.invoke(DateBoxWrapper.this.objSetter.getObj(), DateBoxWrapper.this.objSetter.getSetter(),
                        new Object[] { DateBoxWrapper.this.date });
            }
        }
    });

    //gwt issue 4084 (Fixed in version 2.5)
    dateBox.getTextBox().addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            if ("".equals(event.getValue()) || null == event.getValue()) {
                ValueChangeEvent.fire(dateBox, null);
            }
        }
    });
    initWidget(dateBox);
}

From source file:at.ac.fhcampuswien.atom.client.gui.attributes.components.slider.SliderBar.java

License:Apache License

/**
 * Set the current value and optionally fire the onValueChange event.
 * /*from  w w  w  .jav a2 s . co  m*/
 * @param curValue the current value
 * @param fireEvent fire the onValue change event if true
 */
public void setCurrentValue(double curValue, boolean fireEvent) {
    // Confine the value to the range
    this.curValue = Math.max(minValue, Math.min(maxValue, curValue));
    double remainder = (this.curValue - minValue) % stepSize;
    this.curValue -= remainder;

    // Go to next step if more than halfway there
    if ((remainder > (stepSize / 2)) && ((this.curValue + stepSize) <= maxValue)) {
        this.curValue += stepSize;
    }

    // Redraw the knob
    drawKnob();

    // Fire the ValueChangeEvent
    if (fireEvent) {
        ValueChangeEvent.fire(this, this.curValue);
    }
}

From source file:bufferings.ktr.wjr.client.ui.widget.WjrTreeItem.java

License:Apache License

/**
 * Sets the check box value.//from   www. j  a va 2s.co  m
 * 
 * @param checked
 *          True if checked, false if not.
 * @param fireEvent
 *          True if you want to fire {@link ValueChangeEvent}, false if not.
 */
public void setChecked(boolean checked, boolean fireEvent) {
    checkBox.setValue(checked);
    if (fireEvent) {
        propagateCheckBoxValueToChildren(this, checked);
        propagateCheckBoxValueToParent(this);
        ValueChangeEvent.fire(this, this);
    }
}

From source file:bufferings.ktr.wjr.client.ui.widget.WjrTreeItem.java

License:Apache License

/**
 * Handles check box value change event.
 * /* ww  w. j a va 2s  . c o  m*/
 * @param event
 *          The event information.
 */
@UiHandler("checkBox")
protected void handleCheckBoxValueChange(ValueChangeEvent<Boolean> event) {
    boolean value = event.getValue();
    propagateCheckBoxValueToChildren(this, value);
    propagateCheckBoxValueToParent(this);
    ValueChangeEvent.fire(this, this);
}

From source file:cc.alcina.framework.gwt.client.widget.complex.SliderBar.java

License:Apache License

/**
 * Set the current value and optionally fire the onValueChange event.
 *
 * @param curValue// w w w. j av a  2 s  .  c  o  m
 *            the current value
 * @param fireEvent
 *            fire the onValue change event if true
 */
public void setCurrentValue(double curValue, boolean fireEvent) {
    // Confine the value to the range
    this.curValue = Math.max(minValue, Math.min(maxValue, curValue));
    double remainder = (this.curValue - minValue) % stepSize;
    this.curValue -= remainder;
    // Go to next step if more than halfway there
    if ((remainder > (stepSize / 2)) && ((this.curValue + stepSize) <= maxValue)) {
        this.curValue += stepSize;
    }
    // Redraw the knob
    drawKnob();
    // Fire the onValueChange event
    if (fireEvent) {
        ValueChangeEvent.fire(this, curValue);
    }
}

From source file:com.alkacon.acacia.client.UndoRedoHandler.java

License:Open Source License

/**
 * Fires a value change event to indicate the undo/redo state has changed.<p>
 *//* w ww.  j a va 2  s .  c  o  m*/
private void fireStateChange() {

    ValueChangeEvent.fire(this, new UndoRedoState(hasUndo(), hasRedo()));
}

From source file:com.alkacon.acacia.client.ValidationHandler.java

License:Open Source License

/**
 * Displays the given error messages within the form.<p>
 * //from   www  .ja v a2s. co m
 * @param entityId the entity id
 * @param validationResult the validationResult
 */
public void displayValidation(String entityId, ValidationResult validationResult) {

    if (m_formTabPanel != null) {
        AttributeHandler.clearErrorStyles(m_formTabPanel);
    }
    if (validationResult.hasWarnings(entityId)) {
        for (Entry<String[], String> warning : validationResult.getWarnings(entityId).entrySet()) {
            String[] pathElements = warning.getKey();
            // check if there are no errors for this attribute
            if (!validationResult.hasErrors(entityId)
                    || !validationResult.getErrors(entityId).containsKey(pathElements)) {
                AttributeHandler handler = m_rootHandler.getHandlerByPath(pathElements);
                if (handler != null) {
                    String attributeName = pathElements[pathElements.length - 1];
                    handler.setWarningMessage(ContentDefinition.extractIndex(attributeName), warning.getValue(),
                            m_formTabPanel);
                }
            }
        }
    }
    if (validationResult.hasErrors(entityId)) {
        for (Entry<String[], String> error : validationResult.getErrors(entityId).entrySet()) {
            String[] pathElements = error.getKey();
            AttributeHandler handler = m_rootHandler.getHandlerByPath(pathElements);
            if (handler != null) {
                String attributeName = pathElements[pathElements.length - 1];
                handler.setErrorMessage(ContentDefinition.extractIndex(attributeName), error.getValue(),
                        m_formTabPanel);
            }
        }
        m_validationContext.addInvalidEntity(entityId);
    } else {
        m_validationContext.addValidEntity(entityId);
    }
    ValueChangeEvent.fire(this, m_validationContext);
    m_validating = false;
}

From source file:com.alkacon.acacia.client.widgets.A_EditWidget.java

License:Open Source License

/**
 * Fires the value change event, if the value has changed.<p>
 * //from www.ja  v a 2 s . co m
 * @param force <code>true</code> to force firing the event, not regarding an actually changed value 
 */
protected void fireValueChange(boolean force) {

    String currentValue = getValue();
    if (force || !currentValue.equals(m_previousValue)) {
        m_previousValue = currentValue;
        ValueChangeEvent.fire(this, currentValue);
    }
}

From source file:com.alkacon.forms.client.widgets.A_EditWidget.java

License:Open Source License

/**
 * Fires the value change event, if the value has changed.<p>
 *//* w w  w .  j ava2 s.c o m*/
protected void fireValueChange() {

    String currentValue = getValue();
    if (!currentValue.equals(m_previousValue)) {
        m_previousValue = currentValue;
    }
    ValueChangeEvent.fire(this, currentValue);
}

From source file:com.alkacon.geranium.client.ui.AreaSelectPanel.java

License:Open Source License

/**
 * Fires the value change event.<p>
 * /*from ww  w.  ja  v  a 2 s .  com*/
 * @param alwaysFire <code>true</code> to always fire the change event, ignoring the fire all flag 
 */
private void fireChangeEvent(boolean alwaysFire) {

    if (alwaysFire || m_isFireAll) {
        ValueChangeEvent.fire(this, m_currentSelection);
    }
}