void (@NotNull AnActionEvent e) { final ProjectStructureElement selectedElement = mySourceConfigurable.getSelectedElement(); if (!(selectedElement instanceof LibraryProjectStructureElement libraryElement)) return; final StructureConfigurableContext context = mySourceConfigurable.myContext; final LibraryEx oldLibrary = (LibraryEx)context.getLibrary(libraryElement.getLibrary().getName(), mySourceConfigurable.getLevel()); LOG.assertTrue(oldLibrary != null); final Library newLibrary = doCopy(oldLibrary); if (newLibrary == null) return; final Collection<ProjectStructureElementUsage> usages = context.getDaemonAnalyzer().getUsages(libraryElement); for (ProjectStructureElementUsage usage : usages) { usage.replaceElement(new LibraryProjectStructureElement(context, newLibrary)); } if (!myCopy) { mySourceConfigurable.removeLibrary(libraryElement); } myTargetConfigurable.getProjectStructureConfigurable().selectProjectOrGlobalLibrary(newLibrary, true); }