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 ModuleLibraryTable)) {
       if (newName == null) {
         Messages.showErrorDialog(
             ProjectBundle.message("library.name.not.specified.error", newName),
             ProjectBundle.message("library.name.not.specified.title"));
         return false;
       }
       if (LibraryEditingUtil.libraryAlreadyExists(tableModifiableModel, newName)) {
         Messages.showErrorDialog(
             ProjectBundle.message("library.name.already.exists.error", newName),
             ProjectBundle.message("library.name.already.exists.title"));
         return false;
       }
     }
     myLibraryRootsComponent.renameLibrary(newName);
   }
   myLibraryRootsComponent.applyProperties();
   return true;
 }
 public LibraryEditorDialogBase(
     final Component parent, final LibraryRootsComponent libraryRootsComponent) {
   super(parent, true);
   myLibraryRootsComponent = libraryRootsComponent;
   libraryRootsComponent.resetProperties();
   setTitle(ProjectBundle.message("library.configure.title"));
   Disposer.register(getDisposable(), myLibraryRootsComponent);
 }
  @Override
  protected JComponent createNorthPanel() {
    String currentName = myLibraryRootsComponent.getLibraryEditor().getName();
    myNameField = new JTextField(currentName);
    myNameField.selectAll();

    FormBuilder formBuilder =
        FormBuilder.createFormBuilder().addLabeledComponent("&Name:", myNameField);
    addNorthComponents(formBuilder);
    return formBuilder.addVerticalGap(10).getPanel();
  }
 public void setContextModule(Module module) {
   myLibraryRootsComponent.setContextModule(module);
 }
 @Override
 protected JComponent createCenterPanel() {
   return myLibraryRootsComponent.getComponent();
 }