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:org.kie.workbench.common.stunner.forms.client.fields.assigneeEditor.AssigneeEditorWidgetViewImpl.java

License:Apache License

@Override
public void setValue(String value, boolean fireEvents) {
    String oldValue = sAssignees;

    sAssignees = value;//ww  w.ja  v  a 2  s .c o m

    // TODO: get names from server
    if (names == null) {
        names = new ArrayList<String>(Arrays.asList("user1", "user2", "user3", "user4", "user5"));
        presenter.setNames(names);
    }

    initView();

    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, oldValue, sAssignees);
    }
}

From source file:org.kie.workbench.common.stunner.forms.client.fields.assignmentsEditor.AssignmentsEditorWidget.java

License:Apache License

@Override
public void setValue(String value, boolean fireEvents) {
    String oldValue = assignmentsInfo;

    assignmentsInfo = value;/*from www  . ja va 2 s . c om*/

    initTextBox();

    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, oldValue, assignmentsInfo);
    }
}

From source file:org.kie.workbench.common.stunner.forms.client.fields.variablesEditor.VariablesEditorWidgetViewImpl.java

License:Apache License

@Override
public void setValue(String value, boolean fireEvents) {
    String oldValue = sVariables;

    sVariables = value;//  ww w  .ja va  2  s.  c o  m

    // TODO: get DataTypes from server
    if (dataTypes == null) {
        dataTypes = new ArrayList<String>(Arrays.asList("Boolean", "Float", "Integer", "Object", "String"));
        dataTypeDisplayNames = new ArrayList<String>(
                Arrays.asList("Boolean", "Float", "Integer", "Object", "String"));
        presenter.setDataTypes(dataTypes, dataTypeDisplayNames);
    }

    initView();

    if (fireEvents) {
        ValueChangeEvent.fireIfNotEqual(this, oldValue, sVariables);
    }
}

From source file:org.komodo.web.client.panels.vdb.property.panel.AbstractPropertiesPanel.java

License:Open Source License

protected void updateProperty(final String propertyName, final Object newValue) {
    ///*from  www.  j  a va 2s  .c  o  m*/
    // TODO
    // When updating the name (which is part of the path) need to consider
    // ramifications if the node being update is the root of the canvas
    //
    KObjectOperation operation = new KObjectOperation() {

        @Override
        public void execute(KomodoObjectBean kObject) {
            final HasValueChangeHandlers<KomodoObjectPropertyBean> source = AbstractPropertiesPanel.this;
            final KomodoObjectPropertyBean property = kObject.getProperty(propertyName);
            final KomodoObjectPropertyBean oldProperty = property.copy();

            KomodoRpcService.get().updateProperty(property, newValue,
                    new IRpcServiceInvocationHandler<KomodoObjectPropertyBean>() {
                        @Override
                        public void onReturn(final KomodoObjectPropertyBean result) {
                            property.setValue(result.getValue());
                            ValueChangeEvent.fireIfNotEqual(source, oldProperty, property);
                        }

                        @Override
                        public void onError(Throwable error) {
                            String msg = "Failed to update the property" + property.getName() + ": " //$NON-NLS-1$//$NON-NLS-2$
                                    + error.getMessage();
                            Window.alert(msg);
                            LOGGER.log(Level.SEVERE, msg, error);
                        }
                    });
        }
    };

    KObjectExecutor executor = new KObjectExecutor();
    executor.executeOperation(kObjectPath, operation);
}

From source file:org.komodo.web.client.widgets.CustomPropertiesTable.java

License:Open Source License

@UiHandler("addPropertyButton")
protected void onAddRowButtonClicked(ClickEvent event) {
    /*//from ww w . j av  a  2s  . c  om
     * Add a new property
     */
    final HasValueChangeHandlers<KomodoObjectPropertyBean> source = this;
    final String propertyName = newPropName.getText();
    if (propertyName.isEmpty())
        return;

    final String propertyValue = newPropValue.getText();
    if (propertyValue.isEmpty())
        return;

    // Avoid adding duplicate properties
    if (contains(newPropName.getText()))
        return;

    KomodoRpcService.get().addProperty(kObjectPath, propertyName, propertyValue,
            new IRpcServiceInvocationHandler<KomodoObjectBean>() {
                @Override
                public void onReturn(final KomodoObjectBean result) {
                    // Update the source komodo object to that from the server
                    if (LOGGER.isLoggable(Level.FINE))
                        LOGGER.fine("Adding property to komodo object: " + result.getPath()); //$NON-NLS-1$

                    if (LOGGER.isLoggable(Level.FINE))
                        LOGGER.fine("Firing value change event for added property"); //$NON-NLS-1$

                    ValueChangeEvent.fireIfNotEqual(source, null, result.getProperty(propertyName));

                    KomodoObjectPropertyBean property = result.getProperty(propertyName);
                    addProperty(property);
                }

                @Override
                public void onError(Throwable error) {
                    String msg = "Failed to add the property" + propertyName + ": " + error.getMessage(); //$NON-NLS-1$//$NON-NLS-2$
                    Window.alert(msg);
                    LOGGER.log(Level.SEVERE, msg, error);
                }
            });
}

From source file:org.komodo.web.client.widgets.CustomPropertiesTable.java

License:Open Source License

private void removeTableRow(final int row) {
    Label nameLabel = (Label) propsTable.getWidget(row, 0);
    final String propertyName = nameLabel.getText();

    /*/* ww  w  .  ja v a  2s. c om*/
     * Delete the property
     */
    final HasValueChangeHandlers<KomodoObjectPropertyBean> source = this;
    KObjectOperation operation = new KObjectOperation() {

        @Override
        public void execute(KomodoObjectBean kObject) {

            final KomodoObjectPropertyBean property = kObject.getProperty(propertyName);
            if (property == null)
                return;

            KomodoRpcService.get().removeProperty(property,
                    new IRpcServiceInvocationHandler<KomodoObjectBean>() {
                        @Override
                        public void onReturn(final KomodoObjectBean result) {
                            // Update the source komodo object to that from the server
                            if (LOGGER.isLoggable(Level.FINE))
                                LOGGER.fine("Removed property from komodo object: " + result.getPath()); //$NON-NLS-1$s

                            if (LOGGER.isLoggable(Level.FINE))
                                LOGGER.fine("Firing value change event for removed property"); //$NON-NLS-1$

                            ValueChangeEvent.fireIfNotEqual(source, property, null);

                            // Remove the row in the misc table
                            if (LOGGER.isLoggable(Level.FINE))
                                LOGGER.fine("Removing row " + row + " from table"); //$NON-NLS-1$ //$NON-NLS-2$

                            propsTable.removeRow(row);
                        }

                        @Override
                        public void onError(Throwable error) {
                            String msg = "Failed to remove the property" + property.getName() + ": " //$NON-NLS-1$//$NON-NLS-2$
                                    + error.getMessage();
                            Window.alert(msg);
                            LOGGER.log(Level.SEVERE, msg, error);
                        }
                    });
        }
    };

    KObjectExecutor executor = new KObjectExecutor();
    executor.executeOperation(kObjectPath, operation);
}

From source file:org.kuali.student.common.ui.client.widgets.KSTextArea.java

License:Educational Community License

@Override
public void setText(String text) {
    String oldValue = super.getText();
    if (hasWatermark) {
        if (text == null || (text != null && text.isEmpty())) {
            super.setText(watermarkText);
            addStyleName("watermark-text");
            watermarkShowing = true;//from  ww  w .  j  a va2s. c  o  m
        } else {
            super.setText(text);
            removeStyleName("watermark-text");
            watermarkShowing = false;
        }
    } else {
        super.setText(text);
    }
    ValueChangeEvent.fireIfNotEqual(this, oldValue, text);
}

From source file:org.kuali.student.common.ui.client.widgets.KSTextBox.java

License:Educational Community License

@Override
public void setText(String text) {
    String oldValue = super.getText();
    if (hasWatermark) {
        if (text == null || (text != null && text.isEmpty())) {
            super.setText(watermarkText);
            addStyleName("watermark-text");
            watermarkShowing = true;//from   w  w  w .  j a  v a  2s  . c o  m
        } else {
            super.setText(text);
            removeStyleName("watermark-text");
            watermarkShowing = false;
        }
    } else {
        super.setText(text);
    }
    ValueChangeEvent.fireIfNotEqual(this, oldValue, text);

}

From source file:org.kuali.student.core.statement.ui.client.widgets.table.NodeWidget.java

License:Educational Community License

@Override
public void onPreviewNativeEvent(NativePreviewEvent pevent) {
    NativeEvent event = pevent.getNativeEvent();
    EventTarget target = event.getEventTarget();
    //   System.out.println(this.getElement().is(Element.as(target)));
    if (checkBox.getElement().isOrHasChild(Element.as(target))) {
        return;/*from w w  w  .java2  s .c om*/
    } else if (this.getElement().is(Element.as(target)) && Event.as(event).getTypeInt() == Event.ONMOUSEDOWN) {
        GWT.log("doing", null);
        boolean before = checkBox.getValue();
        checkBox.setValue(!before);
        ValueChangeEvent.fireIfNotEqual(checkBox, before, checkBox.getValue());
        //checkBox.setFocus(true);
        //        setFocus(true);

    }

}

From source file:org.obiba.opal.web.gwt.app.client.ui.NumericTextBox.java

License:Open Source License

@Override
public void setValue(String value, boolean fireEvents) {
    try {//ww  w .j  a va  2  s  . c o  m
        Number newValue = numberType.parseValue(value);
        if (newValue == null || maxConstrained && newValue.intValue() > max
                || minConstrained && newValue.intValue() < min) {
            return;
        }
        String prevText = getValue();
        setText(numberType.formatValue(newValue));
        if (fireEvents) {
            ValueChangeEvent.fireIfNotEqual(this, getValue(), prevText);
        }
    } catch (Exception ex) {
        // Do Nothing
    }
}