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);
}
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;
}
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;
}
Aggregations