Exemplo n.º 1
0
    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();
        }
      }
    }
Exemplo n.º 2
0
    /**
     * 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;
    }