void (@NotNull DataContext dataContext) { final Module module = myOrderEntry.getOwnerModule(); String message = IdeBundle.message("detach.library.from.module", myOrderEntry.getPresentableName(), module.getName()); String title = IdeBundle.message("detach.library"); int ret = Messages.showOkCancelDialog(myProject, message, title, Messages.getQuestionIcon()); if (ret != Messages.OK) return; CommandProcessor.getInstance().executeCommand(module.getProject(), () -> { final Runnable action = () -> { ModuleRootManager rootManager = ModuleRootManager.getInstance(module); OrderEntry[] orderEntries = rootManager.getOrderEntries(); ModifiableRootModel model = rootManager.getModifiableModel(); OrderEntry[] modifiableEntries = model.getOrderEntries(); for (int i = 0; i < orderEntries.length; i++) { OrderEntry entry = orderEntries[i]; if (entry instanceof LibraryOrderEntry && ((LibraryOrderEntry)entry).getLibrary() == myOrderEntry.getLibrary()) { model.removeOrderEntry(modifiableEntries[i]); } } model.commit(); }; ApplicationManager.getApplication().runWriteAction(action); }, title, null); }