Search in sources :

Example 1 with InputElement

use of elemental.html.InputElement in project che by eclipse.

the class TreeNodeMutator method enterMutation.

/**
     * Replaces the nodes text label with an input box to allow the user to
     * rename the node.
     */
public void enterMutation(TreeNodeElement<D> node, MutationAction<D> callback) {
    // If we are already mutating, return.
    if (isMutating()) {
        return;
    }
    Element element = callback.getElementForMutation(node);
    if (element == null) {
        return;
    }
    String oldLabel = element.getTextContent();
    callback.onBeforeMutation(node);
    // Make a temporary text input box to grab user input, and place it inside
    // the label element.
    InputElement input = Elements.createInputElement();
    if (css != null) {
        input.setClassName(css.nodeNameInput());
    }
    input.setType("text");
    input.setValue(oldLabel);
    // Wipe the content from the element.
    element.setTextContent("");
    // Attach the temporary input box.
    element.appendChild(input);
    input.focus();
    input.select();
    // If we hit enter, commit the action.
    input.addEventListener(Event.KEYUP, keyListener, false);
    // If we lose focus, commit the action.
    input.addEventListener(Event.BLUR, blurListener, false);
    state = new State<D>(node, callback, input, oldLabel);
}
Also used : Element(elemental.dom.Element) InputElement(elemental.html.InputElement) InputElement(elemental.html.InputElement)

Example 2 with InputElement

use of elemental.html.InputElement in project che by eclipse.

the class Elements method createInputElement.

public static InputElement createInputElement(String... classNames) {
    InputElement elem = getDocument().createInputElement();
    addClassesToElement(elem, classNames);
    return elem;
}
Also used : InputElement(elemental.html.InputElement)

Example 3 with InputElement

use of elemental.html.InputElement in project che by eclipse.

the class Elements method createInputTextElement.

public static InputElement createInputTextElement(String... classNames) {
    InputElement elem = getDocument().createInputElement();
    addClassesToElement(elem, classNames);
    elem.setType("text");
    return elem;
}
Also used : InputElement(elemental.html.InputElement)

Aggregations

InputElement (elemental.html.InputElement)3 Element (elemental.dom.Element)1