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:org.opencms.ade.galleries.client.CmsGalleryController.java

License:Open Source License

/**
 * Remove the type from the search object.<p>
 * /* www .  ja v  a  2s  . co m*/
 * @param resourceType the resource type as id
 */
public void removeType(String resourceType) {

    m_searchObject.removeType(resourceType);
    m_searchObjectChanged = true;
    ValueChangeEvent.fire(this, m_searchObject);
}

From source file:org.opencms.ade.galleries.client.CmsGalleryController.java

License:Open Source License

/**
 * Sets if the search should include expired or unreleased resources.<p>
 * //from  w w w  .j  a  v  a  2s  .co  m
 * @param includeExpired if the search should include expired or unreleased resources
 */
public void setIncludeExpired(boolean includeExpired) {

    m_searchObject.setIncludeExpired(includeExpired);
    m_searchObjectChanged = true;
    ValueChangeEvent.fire(this, m_searchObject);
}

From source file:org.opencms.ade.galleries.client.preview.CmsImageFormatHandler.java

License:Open Source License

/** 
 * Helper method for firing a 'value changed' event.<p>
 */
protected void fireValueChangedEvent() {

    ValueChangeEvent.fire(this, m_croppingParam);
}

From source file:org.opencms.ade.galleries.client.preview.ui.CmsCroppingDialog.java

License:Open Source License

/**
 * Handles the click event for ok button. Sets the selected cropping parameters.<p>
 * //from  w w  w.  ja v a 2  s  .co m
 * @param event the click event
 */
@UiHandler("m_okButton")
protected void onOk(ClickEvent event) {

    if (!((m_croppingParam.getTargetWidth() > 0) && (m_croppingParam.getTargetHeight() > 0))) {
        if (m_croppingParam.getTargetWidth() > 0) {
            m_croppingParam.setTargetHeight(
                    (int) Math.floor((1.00 * m_croppingParam.getTargetWidth() * m_croppingParam.getCropHeight())
                            / m_croppingParam.getCropWidth()));
        } else if (m_croppingParam.getTargetHeight() > 0) {
            m_croppingParam.setTargetWidth(
                    (int) Math.floor((1.00 * m_croppingParam.getTargetHeight() * m_croppingParam.getCropWidth())
                            / m_croppingParam.getCropHeight()));
        } else {
            m_croppingParam.setTargetHeight(m_croppingParam.getCropHeight());
            m_croppingParam.setTargetWidth(m_croppingParam.getCropWidth());
        }
    }
    ValueChangeEvent.fire(this, m_croppingParam);
    hide();
}

From source file:org.opencms.ade.galleries.client.preview.ui.CmsImageFormatsForm.java

License:Open Source License

/**
 * @see com.google.gwt.event.dom.client.KeyPressHandler#onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent)
 *///w w  w.jav a2s.  co m
public void onKeyPress(KeyPressEvent event) {

    //preventing any input but numbers
    char key = event.getCharCode();
    int code = event.getNativeEvent().getKeyCode();
    if (((key >= '0') && (key <= '9')) || (code == KeyCodes.KEY_BACKSPACE) || (code == KeyCodes.KEY_DELETE)) {
        // the value of the input box will probably have changed, so fire an event after the input has been processed
        final CmsTextBox source = (CmsTextBox) event.getSource();
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

            public void execute() {

                ValueChangeEvent.fire(source, source.getText());
            }
        });
        return;
    }
    if ((code == KeyCodes.KEY_TAB) || (code == KeyCodes.KEY_LEFT) || (code == KeyCodes.KEY_RIGHT)
            || (code == KeyCodes.KEY_ENTER)) {
        return;
    }
    // prevent all others
    event.stopPropagation();
    event.preventDefault();
}

From source file:org.opencms.ade.galleries.client.preview.ui.CmsPropertyForm.java

License:Open Source License

/**
 * The constructor.<p>//from  w  w w. j  a  va 2s  .c  o  m
 * 
 * @param id the id of the property from
 * @param width the property from width
 * @param value the property value
 * @param textMetricsKey the key identifying the text metrics to use 
 */
public CmsPropertyForm(String id, int width, String value, String textMetricsKey) {

    m_id = id;
    m_originalValue = value;
    m_isChanged = false;
    m_parentWidth = width;
    m_parent = new FlowPanel();
    m_parent.getElement().getStyle().setWidth(m_parentWidth, Unit.PX);
    // set form label
    m_label = new CmsLabel(m_id);
    m_label.addStyleName(I_CmsLayoutBundle.INSTANCE.previewDialogCss().labelField());
    m_label.getElement().getStyle().setWidth(getLabelWidth(), Unit.PX);
    m_label.truncate(textMetricsKey, getLabelWidth());
    m_parent.add(m_label);

    // set form text box
    m_inputPanel = new FlowPanel();
    m_inputPanel.getElement().getStyle().setWidth(getInputWidth(), Unit.PX);
    m_inputPanel.addStyleName(I_CmsLayoutBundle.INSTANCE.previewDialogCss().inputField());
    m_textBox = new CmsTextBox();
    m_textBox.setFormValueAsString(m_originalValue);
    m_textBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        /**
         * @see com.google.gwt.event.logical.shared.ValueChangeHandler#onValueChange(ValueChangeEvent event)
         */
        public void onValueChange(ValueChangeEvent<String> event) {

            m_isChanged = true;
            m_textBox.setChangedStyle();
        }
    });
    m_textBox.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent event) {

            // make sure the value change event is fired on the first change inside the text box
            if (!isChanged()) {
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    public void execute() {

                        if (!isChanged()) {

                            if (((getValue() == null) && (m_originalValue != null))
                                    || (!getValue().equals(m_originalValue))) {
                                ValueChangeEvent.fire(m_textBox, getValue());
                            }
                        }
                    }
                });
            }
        }
    });
    m_inputPanel.add(m_textBox);
    m_parent.add(m_inputPanel);
    initWidget(m_parent);
}

From source file:org.opencms.ade.galleries.client.ui.CmsGalleryField.java

License:Open Source License

/**
 * Fires the value change event if the value has changed.<p>
 *
 * @param force <code>true</code> to force firing the event in any case
 *///  w w w.j  av a  2s .c  o  m
protected void fireChange(boolean force) {

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

From source file:org.opencms.ade.galleries.client.ui.CmsSearchTab.java

License:Open Source License

/**
 * Clears the search tab input.<p>
 *///  w  w  w.  j ava2  s  .c o  m
public void clearInput() {

    m_searchInput.setFormValueAsString("");
    ValueChangeEvent.fire(m_searchInput, "");
    m_dateCreatedStartDateBox.setValue(null, true);
    m_dateCreatedEndDateBox.setValue(null, true);
    m_dateModifiedStartDateBox.setValue(null, true);
    m_dateModifiedEndDateBox.setValue(null, true);
    m_includeExpiredCheckBox.setChecked(false);
    m_localeSelection.reset();
}

From source file:org.opencms.gwt.client.property.CmsSimplePropertyEditor.java

License:Open Source License

/**
 * Creates a string model which uses a field of a CmsClientProperty for storing its value.<p>
 *
 * @param id the structure id/*from www  .  j a v  a 2 s .  co m*/
 * @param propName the property id
 * @param isStructure if true, the structure value field should be used, else the resource value field
 *
 *
 * @return the new model object
 */
private I_CmsStringModel createStringModel(final CmsUUID id, final String propName, final boolean isStructure) {

    final CmsClientProperty property = m_properties.get(propName);

    return new I_CmsStringModel() {

        private boolean m_active;

        private EventBus m_eventBus = new SimpleEventBus();

        public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) {

            return m_eventBus.addHandler(ValueChangeEvent.getType(), handler);
        }

        /**
         * @see com.google.gwt.event.shared.HasHandlers#fireEvent(com.google.gwt.event.shared.GwtEvent)
         */
        public void fireEvent(GwtEvent<?> event) {

            m_eventBus.fireEvent(event);
        }

        public String getId() {

            return Joiner.on("/").join(id.toString(), propName, isStructure ? "S" : "R");
        }

        public String getValue() {

            if (isStructure) {
                return property.getStructureValue();
            } else {
                return property.getResourceValue();
            }
        }

        public void setValue(String value, boolean notify) {

            if (!m_active) {
                m_active = true;
                try {
                    String oldValue = getValue();
                    boolean changed = !Objects.equal(value, oldValue);
                    if (isStructure) {
                        property.setStructureValue(value);
                    } else {
                        property.setResourceValue(value);
                    }
                    if (notify && changed) {
                        ValueChangeEvent.fire(this, value);
                    }
                } finally {
                    m_active = false;
                }
            }
        }
    };
}

From source file:org.opencms.gwt.client.ui.CmsScrollBar.java

License:Open Source License

/**
 * @see com.google.gwt.user.client.ui.HasValue#setValue(java.lang.Object, boolean)
 *//*from  w w  w .j  a v a2  s.  co  m*/
public void setValue(Integer value, boolean fireEvents) {

    if (value != null) {
        m_currentValue = value.intValue();
    } else {
        m_currentValue = 0;
    }
    setKnobPosition(m_currentValue);
    // Fire the ValueChangeEvent
    if (fireEvents) {
        ValueChangeEvent.fire(this, Integer.valueOf(m_currentValue));
    }
}