protected boolean validateAndApply() {
    String newName = myNameField.getText().trim();
    if (newName.length() == 0) {
      newName = null;
    }
    if (shouldCheckName(newName)) {
      final LibraryTable.ModifiableModel tableModifiableModel = getTableModifiableModel();
      if (tableModifiableModel != null && !(tableModifiableModel instanceof ModuleLibraryTableBase)) {
        if (newName == null) {
          Messages.showErrorDialog(JavaUiBundle.message("library.name.not.specified.error"), JavaUiBundle.message("library.name.not.specified.title"));
          return false;
        }
        if (LibraryEditingUtil.libraryAlreadyExists(tableModifiableModel, newName)) {
          Messages.showErrorDialog(JavaUiBundle.message("library.name.already.exists.error", newName), JavaUiBundle.message("library.name.already.exists.title"));
          return false;
        }
      }
      myLibraryRootsComponent.renameLibrary(newName);
    }
    myLibraryRootsComponent.applyProperties();
    return true;
  }
protected boolean validateAndApply()