@Override
  public void onCreate() {
    final FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem();
    if (selection != null && selection.getFileInfo().isAllowsNewChildren()) {
      int level = getLevel(selection);
      if (level < Configuration.fileManagerMaxDepth) {
        textInputPresenter.show(
            "Create folder",
            "Folder name:",
            "",
            new ITextInputListener() {
              @Override
              public void onConfirm(final String directoryName) {
                final FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem();
                final String selectionPath = selection.getFileInfo().getFilePath();
                fileService.isDirectory(
                    Authentication.getInstance().getToken(),
                    selectionPath,
                    new RPCCallback<Boolean>() {
                      @Override
                      public void onResult(Boolean result) {
                        String newDirectoryParent = selectionPath;
                        if (!result) newDirectoryParent = getParent(selection);
                        if (newDirectoryParent != null) {
                          fileService.createDirectory(
                              Authentication.getInstance().getToken(),
                              newDirectoryParent,
                              directoryName,
                              false,
                              new RPCCallback<String>() {
                                @Override
                                public void onResult(String result) {
                                  fileTreePresenter.refresh(fileFilter);
                                }
                              });
                        }
                      }
                    });
              }

              @Override
              public void onCancel() {}
            });
      } else {
        messagePresenter.showMessage(
            "File Manager",
            "Only a directory depth of " + Configuration.fileManagerMaxDepth + " is allowed.");
      }
    } else {
      messagePresenter.showMessage("File Manager", "Please select a valid parent directory.");
    }
  }
  @Override
  public void onRename() {
    FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem();
    // don't allow rename of root node
    if (selection != null && !selection.getFileInfo().isSystemFile()) {
      textInputPresenter.show(
          "Rename",
          "New name",
          selection.getFileInfo().getName(),
          new ITextInputListener() {
            @Override
            public void onConfirm(final String newFileName) {
              final FileImageLabelTreeItem selection = fileTreePresenter.getSelectedItem();
              if (selection != null && !selection.getFileInfo().isSystemFile()) {
                fileService.renameFile(
                    Authentication.getInstance().getToken(),
                    selection.getFileInfo().getFilePath(),
                    newFileName,
                    new RPCCallback<Void>() {
                      @Override
                      public void onResult(Void result) {
                        fileTreePresenter.refresh(fileFilter);
                        selection.getFileInfo().setName(newFileName);
                      }
                    });
              }
            }

            @Override
            public void onCancel() {}
          });
    } else {
      messagePresenter.showMessage(
          "File Manager", "Please select a valid file or directory to rename");
    }
  }