boolean (final String inputString) { final String oldName = myLibrary.getName(); final Library.ModifiableModel modifiableModel = renameLibrary(inputString); final Ref<Boolean> success = Ref.create(Boolean.TRUE); CommandProcessor.getInstance().executeCommand(myProject, () -> { UndoableAction action = new BasicUndoableAction() { @Override public void undo() { final Library.ModifiableModel modifiableModel1 = renameLibrary(oldName); modifiableModel1.commit(); } @Override public void redo() { final Library.ModifiableModel modifiableModel1 = renameLibrary(inputString); modifiableModel1.commit(); } }; UndoManager.getInstance(myProject).undoableActionPerformed(action); ApplicationManager.getApplication().runWriteAction(() -> modifiableModel.commit()); }, IdeBundle.message("command.renaming.module", oldName), null); return success.get().booleanValue(); }