public void onEditorExit(EditorExitEvent event) { event.isCancelled(); event.getEditCompletionEvent(); if (!alreadyDiscarded) { if (checkInput(event)) { String newName = event.getNewValue() != null ? event.getNewValue().toString() : null; TreeNode renamedNode = (TreeNode) event.getRecord(); ActionRegistry.RENAME_FOLDER.get(RenameFolderAction.class).setRenamedNode(renamedNode); ActionRegistry.RENAME_FOLDER.get(RenameFolderAction.class).setNewName(newName); ActionRegistry.RENAME_FOLDER.execute(); } } }
/** * Is new name empty or the same as before? * * @param event * @return */ private boolean checkInput(EditorExitEvent event) { // only completion event ENTER is accepted if (!EditCompletionEvent.ENTER.equals(event.getEditCompletionEvent())) { return false; } String newName = event.getNewValue() != null ? event.getNewValue().toString() : null; String oldName = ((TreeNode) event.getRecord()).getName(); if (!GWTUtil.hasText(newName) || newName.equalsIgnoreCase(oldName)) { this.alreadyDiscarded = true; tree.discardAllEdits(); return false; } return true; }