Example usage for com.google.gwt.dom.client InputElement focus

List of usage examples for com.google.gwt.dom.client InputElement focus

Introduction

In this page you can find the example usage for com.google.gwt.dom.client InputElement focus.

Prototype

@Override
    public void focus() 

Source Link

Usage

From source file:cc.alcina.framework.gwt.client.cell.EditTextCell.java

License:Apache License

/**
 * Convert the cell to edit mode./*from   w w  w.  ja va2 s .c  o  m*/
 *
 * @param context
 *            the {@link Context} of the cell
 * @param parent
 *            the parent element
 * @param value
 *            the current value
 */
protected void edit(Context context, Element parent, String value) {
    setValue(context, parent, value);
    InputElement input = getInputElement(parent);
    input.focus();
    input.select();
}

From source file:com.google.code.tree.client.CustomEditTextCell.java

License:Apache License

/**
 * Convert the cell to edit mode.// ww  w . j a va2 s.  c  om
 * 
 * @param context
 *            the {@link Context} of the cell
 * @param parent
 *            the parent element
 * @param value
 *            the current value
 */
protected void edit(Context context, Element parent, UpdatableTreeNode value) {
    setValue(context, parent, value);
    InputElement input = getInputElement(parent);
    input.focus();
    input.select();
}

From source file:com.google.collide.client.ui.popup.CenterPanel.java

License:Open Source License

/**
 * Displays the {@link CenterPanel} popup. The popup will animate into view.
 *
 * @param selectAndFocusElement an {@link InputElement} to select and focus on when the panel is
 *        shown. If null, no element will be given focus
 *///from   w  w  w  . j  a  va2s  .c  om
public void show(@Nullable final InputElement selectAndFocusElement) {
    if (isShowing) {
        return;
    }
    isShowing = true;

    // Attach the popup to the body.
    final JsElement popup = getView().popup.cast();
    if (popup.getParentElement() == null) {
        // Hide the popup so it can enter its initial state without flickering.
        popup.getStyle().setVisibility("hidden");
        Elements.getBody().appendChild(popup);
    }

    // Start the animation after the element is attached.
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            // The popup may have been hidden before this timer executes.
            if (isShowing) {
                popup.getStyle().removeProperty("visibility");
                getView().setShowing(true);
                if (selectAndFocusElement != null) {
                    selectAndFocusElement.select();
                    selectAndFocusElement.focus();
                }
            }
        }
    });
}

From source file:com.ocado.rangeui.client.gui.component.grid.column.EditNumberCell.java

/**
 * Convert the cell to edit mode.//from   ww w .j av  a 2  s.  c  om
 *
 * @param context the {@link Context} of the cell
 * @param parent the parent element
 * @param value the current value
 */
protected void edit(Context context, Element parent, Number value) {
    setValue(context, parent, value);
    InputElement input = getInputElement(parent);
    input.focus();
    input.select();
}

From source file:com.sencha.gxt.cell.core.client.form.CheckBoxCell.java

License:sencha.com license

private void updateCheckBoxValue(Element parent, NativeEvent event, Boolean value,
        ValueUpdater<Boolean> valueUpdater) {
    // if disabled, return immediately
    if (isDisabled()) {
        event.preventDefault();//from  w  ww.  ja  v a 2s .c o m
        event.stopPropagation();
        return;
    }

    String eventType = event.getType();

    // on macs and chrome windows, the checkboxes blur on click which causes issues with inline editing as edit
    // is cancelled
    if ((GXT.isChrome() || GXT.isMac()) && "mousedown".equals(eventType)) {
        ignoreNextBlur = true;
    }

    final Element target = event.getEventTarget().cast();
    final InputElement input = getInputElement(parent);
    Boolean checked = input.isChecked();

    boolean label = "LABEL".equals(target.getTagName());
    boolean enterPressed = "keydown".equals(eventType) && event.getKeyCode() == KeyCodes.KEY_ENTER;

    // TODO this should be changed to remove reference to known subclass
    boolean radio = this instanceof RadioCell;

    if (label || enterPressed) {
        event.preventDefault();

        if (checked && radio) {
            return;
        }

        // input will NOT have been updated for label clicks
        checked = !checked;
        input.setChecked(checked);

    } else if (radio && value) {
        // no action required if value is already true and this is a radio
        return;
    }

    if (valueUpdater != null && checked != value) {
        valueUpdater.update(checked);
    }

    if (ignoreNextBlur) {
        ignoreNextBlur = false;
        input.focus();
    }
}

From source file:com.tasktop.c2c.server.common.profile.web.client.TextBoxCell.java

License:Open Source License

@Override
public boolean resetFocus(Context context, Element parent, String value) {
    InputElement input = getInputElement(parent);
    input.focus();
    return true;/*from w  w  w.j av a 2s  . c o m*/
}

From source file:de.swm.commons.mobile.client.widgets.date.DatePopup.java

License:Apache License

/**
 * Renders the date box for devices where native date input field is not avalilable.
 *
 * @param givenDate/*from  w ww  .  j ava 2  s  .c  o  m*/
 * @param dateStyle
 */
private void renderIOS5DateBox(final Date givenDate, final DateStyle dateStyle) {

    final InputElement dateInput = createNumberInputElement(dateStyle.getHtmlInputType());

    dateInput.focus();
    dateTextBox = TextBox.wrap(dateInput);
    dateTextBox.setSize("95%", "40px");

    dateTextBox.setValue(dateCalc.formatToRfc3339(givenDate, dateStyle, true));
    // TODO: on value change, call clearRelativeTime() (special handling necessary)

    HorizontalPanel dateInputPanel = new HorizontalPanel();
    dateInputPanel.addStyleName(SWMMobile.getTheme().getMGWTCssBundle().getPopupsCss().dateInputPanel());
    dateInputPanel.add(dateTextBox);
    mainPanel.add(dateInputPanel);

    Widget commandPanel = createCommandPanel(new ClickHandler() {
        /**
         * {@inheritDoc}
         */
        @Override
        public void onClick(ClickEvent event) {
            hide();
            selectionHandler.dateSelected(dateCalc.parseRfc3339(dateTextBox.getText().trim(), dateStyle, true));
        }

    });
    mainPanel.add(commandPanel);

    dateTextBox.setFocus(true);
}

From source file:io.pelle.mango.client.gwt.modules.dictionary.controls.EditTextCellWithValidation.java

License:Open Source License

private void focus(Element parent) {
    InputElement input = getInputElement(parent);

    input.focus();
    input.select();
}

From source file:io.pelle.mango.client.gwt.modules.dictionary.controls.table.SuggestCellControl.java

License:Open Source License

private void setFocus(final Element parent) {
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override//  w  w  w  .  ja  v a 2 s  . c  o m
        public void execute() {
            InputElement input = getInputElement(parent);
            input.focus();
            input.select();
        }
    });
}

From source file:stroom.dashboard.client.table.FieldEditTextCell.java

License:Apache License

/**
 * Convert the cell to edit mode.//  ww w. ja  v a  2 s  .co m
 *
 * @param context
 *            the {@link Context} of the cell
 * @param parent
 *            the parent element
 * @param value
 *            the current value
 */
protected void edit(final Context context, final Element parent, final String value) {
    setValue(context, parent, value);
    final InputElement input = getInputElement(parent);
    input.focus();
    input.select();
}