Example usage for com.google.gwt.event.shared GwtEvent getSource

List of usage examples for com.google.gwt.event.shared GwtEvent getSource

Introduction

In this page you can find the example usage for com.google.gwt.event.shared GwtEvent getSource.

Prototype

@Override
    public Object getSource() 

Source Link

Usage

From source file:com.google.gerrit.client.ui.OnEditEnabler.java

License:Apache License

private void on(final GwtEvent<?> e) {
    if (widget.isEnabled() || !(e.getSource() instanceof FocusWidget)
            || !((FocusWidget) e.getSource()).isEnabled()) {
        if (e.getSource() instanceof ValueBoxBase) {
            final TextBoxBase box = ((TextBoxBase) e.getSource());
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                @Override//from   w w w .  j a v a  2s .co m
                public void execute() {
                    if (box.getValue().trim().length() == 0) {
                        widget.setEnabled(false);
                    }
                }
            });
        }
        return;
    }

    if (e.getSource() instanceof TextBoxBase) {
        onTextBoxBase((TextBoxBase) e.getSource());
    } else {
        // For many widgets, we can assume that a change is an edit. If
        // a widget does not work that way, it should be special cased
        // above.
        widget.setEnabled(true);
    }
}

From source file:com.google.gerrit.client.ui.TextBoxChangeListener.java

License:Apache License

private void on(final GwtEvent<?> e) {
    final TextBoxBase tb = (TextBoxBase) e.getSource();

    if (!tb.getText().equals(oldText)) {
        onTextChanged(tb.getText());/*from   ww  w .  j  a va  2 s  .c  o  m*/
        oldText = tb.getText();
    } else {
        // The text appears to not always get updated until the handlers complete.
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            @Override
            public void execute() {
                if (!tb.getText().equals(oldText)) {
                    onTextChanged(tb.getText());
                    oldText = tb.getText();
                }
            }
        });
    }
}

From source file:com.googlecode.simplegwt.style.client.ui.HoverStyler.java

License:Apache License

/**
 * Casts the event source to a <code>UIObject</code>.
 * // w  ww  .ja  v a 2  s .c  o m
 * @param event
 * @return the event source
 */
private UIObject getUIObjectFromEvent(final GwtEvent<?> event) {
    final Object source = event.getSource();
    assert (source instanceof Widget) : "Source must be a Widget";
    final UIObject uiObject = (Widget) source;
    return uiObject;
}

From source file:com.googlesource.gerrit.plugins.emoticons.client.OnEditEnabler.java

License:Apache License

private void on(GwtEvent<?> e) {
    if (widget.isEnabled() || !(e.getSource() instanceof FocusWidget)
            || !((FocusWidget) e.getSource()).isEnabled()) {
        if (e.getSource() instanceof ValueBoxBase) {
            final TextBoxBase box = ((TextBoxBase) e.getSource());
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                @Override//from  w ww .ja v  a2 s .co m
                public void execute() {
                    if (box.getValue().trim().equals(originalValue)) {
                        widget.setEnabled(false);
                    }
                }
            });
        }
        return;
    }

    if (e.getSource() instanceof TextBoxBase) {
        onTextBoxBase((TextBoxBase) e.getSource());
    } else {
        // For many widgets, we can assume that a change is an edit. If
        // a widget does not work that way, it should be special cased
        // above.
        widget.setEnabled(true);
    }
}

From source file:com.lushprojects.circuitjs1.client.Editable.java

License:Open Source License

public void itemStateChanged(GwtEvent e) {
    Object src = e.getSource();
    int i;//from  www. j  a  v a2  s . c o  m
    boolean changed = false;
    for (i = 0; i != einfocount; i++) {
        EditInfo ei = einfos[i];
        if (ei.choice == src || ei.checkbox == src || ei.button == src) {

            // if we're pressing a button, make sure to apply changes first
            if (ei.button == src)
                apply();

            elm.setEditValue(i, ei);
            if (ei.newDialog)
                changed = true;
            cframe.needAnalyze();
        }
    }
    if (changed) {
        clearDialog();
        buildDialog();
    }
}

From source file:com.lushprojects.circuitjs1.client.gui.EditDialog.java

License:Open Source License

public void itemStateChanged(GwtEvent e) {
    Object src = e.getSource();
    int i;/*from   ww  w . j a va2 s .  c  o  m*/
    boolean changed = false;
    for (i = 0; i != einfocount; i++) {
        EditInfo ei = einfos[i];
        if (ei.choice == src || ei.checkbox == src) {
            elm.setEditValue(i, ei);
            if (ei.newDialog)
                changed = true;
            cframe.needAnalyze();
        }
    }
    if (changed) {
        //   apply();
        //         setVisible(false);
        //         cframe.editDialog = new EditDialog(elm, cframe);
        //         cframe.editDialog.show();
        clearDialog();
        buildDialog();
    }
}

From source file:com.qualogy.qafe.gwt.client.component.CellRendererHelper.java

License:Apache License

private static void handleSetModifiedForValueChangeEvent(final HasDataGridMethods parentWidget,
        final DataContainerGVO rowValue, final ColumnDefinition<DataContainerGVO, String> columnDef,
        final UIObject uiObject, GwtEvent event) {
    Object value = null;//w  w w.j  av a 2  s  .  c  o m

    // TODO
    if (event instanceof ValueChangeEvent) {
        ValueChangeEvent valueChangeEvent = (ValueChangeEvent) event;
        value = valueChangeEvent.getValue();
    }

    Object source = event.getSource();
    if (source instanceof CheckBox) {
        CheckBox checkBox = (CheckBox) source;
        if ((Boolean) value) {
            String attributeValue = DOM.getElementAttribute(checkBox.getElement(),
                    CheckBoxGVO.CHECKED_VALUE_ATTRIBUTE_TAG);
            if (attributeValue != null && attributeValue.length() > 0) {
                value = attributeValue;
            }
        } else {
            String attributeValue = DOM.getElementAttribute(checkBox.getElement(),
                    CheckBoxGVO.UNCHECKED_VALUE_ATTRIBUTE_TAG);
            if (attributeValue != null && attributeValue.length() > 0) {
                value = attributeValue;
            }
        }
    } else if (source instanceof QTextField) {
        /**
         * When database column type is NUMBER(5,2) type which is accepting decimal values, If we pass string type with decimal value to the jdbc template it is giving exception.
         * So the type of the textfield should be considered.
         * This is now applicable only for textfield, same issue can come in any inputfield. But we dont have an option to set type to other components now.
         */
        String type = DOM.getElementAttribute(uiObject.getElement(), TextFieldGVO.REGEXPTYPE);
        QTextField textField = (QTextField) source;
        if (TextFieldGVO.TYPE_DOUBLE.equals(type)) {
            value = new Double(value.toString());
        } else if (TextFieldGVO.TYPE_INTEGER.equals(type)) {
            try {
                value = new Integer(value.toString());
            } catch (Exception e) {
                value = new Double(value.toString());
            }
        }
    }
    if (value == null) {
        if (source instanceof HasText) {
            HasText hasText = (HasText) source;
            value = hasText.getText();
        } else if (source instanceof HasData) {
            HasData hasData = (HasData) source;
            value = hasData.getData();
        }
    }
    handleSetModified(parentWidget, rowValue, columnDef, uiObject, value);
}

From source file:org.openremote.web.console.event.press.PressEvent.java

License:Open Source License

public PressEvent(GwtEvent<? extends EventHandler> sourceEvent) {
    time = new Date().getTime();
    source = (Widget) sourceEvent.getSource();
}