Search in sources :

Example 1 with FocusWidget

use of com.google.gwt.user.client.ui.FocusWidget in project gerrit by GerritCodeReview.

the class OnEditEnabler method on.

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
                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);
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ValueBoxBase(com.google.gwt.user.client.ui.ValueBoxBase) FocusWidget(com.google.gwt.user.client.ui.FocusWidget) TextBoxBase(com.google.gwt.user.client.ui.TextBoxBase)

Example 2 with FocusWidget

use of com.google.gwt.user.client.ui.FocusWidget in project che by eclipse.

the class BaseView method setContentWidget.

/**
     * Sets content widget.
     *
     * @param widget
     *         content widget
     */
public final void setContentWidget(Widget widget) {
    container.add(widget);
    for (FocusWidget focusWidget : UIUtil.getFocusableChildren(widget)) {
        focusWidget.addBlurHandler(blurHandler);
    }
    focusView();
}
Also used : FocusWidget(com.google.gwt.user.client.ui.FocusWidget)

Aggregations

FocusWidget (com.google.gwt.user.client.ui.FocusWidget)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 TextBoxBase (com.google.gwt.user.client.ui.TextBoxBase)1 ValueBoxBase (com.google.gwt.user.client.ui.ValueBoxBase)1