use of com.intellij.openapi.roots.LibraryOrderEntry in project intellij-community by JetBrains.
the class ProjectSettingsService method getLibrarySettingsConfigurable.
@Nullable
private static Configurable getLibrarySettingsConfigurable(OrderEntry orderEntry) {
if (!(orderEntry instanceof LibraryOrderEntry))
return null;
LibraryOrderEntry libOrderEntry = (LibraryOrderEntry) orderEntry;
Library lib = libOrderEntry.getLibrary();
if (lib instanceof LibraryEx) {
Project project = libOrderEntry.getOwnerModule().getProject();
PersistentLibraryKind<?> libKind = ((LibraryEx) lib).getKind();
if (libKind != null) {
return LibrarySettingsProvider.getAdditionalSettingsConfigurable(project, libKind);
}
}
return null;
}
use of com.intellij.openapi.roots.LibraryOrderEntry in project intellij-community by JetBrains.
the class LibraryPackagingElement method findLibrary.
@Nullable
public Library findLibrary(@NotNull PackagingElementResolvingContext context) {
if (myModuleName == null) {
return context.findLibrary(myLevel, myLibraryName);
}
final ModulesProvider modulesProvider = context.getModulesProvider();
final Module module = modulesProvider.getModule(myModuleName);
if (module != null) {
for (OrderEntry entry : modulesProvider.getRootModel(module).getOrderEntries()) {
if (entry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryEntry = (LibraryOrderEntry) entry;
if (libraryEntry.isModuleLevel()) {
final String libraryName = libraryEntry.getLibraryName();
if (libraryName != null && libraryName.equals(myLibraryName)) {
return libraryEntry.getLibrary();
}
}
}
}
}
return null;
}
use of com.intellij.openapi.roots.LibraryOrderEntry in project intellij-community by JetBrains.
the class ChooseLibrariesDialogBase method collectChildren.
protected void collectChildren(Object element, final List<Object> result) {
if (element instanceof Application) {
Collections.addAll(result, ProjectManager.getInstance().getOpenProjects());
final LibraryTablesRegistrar instance = LibraryTablesRegistrar.getInstance();
//1
result.add(instance.getLibraryTable());
//2
result.addAll(instance.getCustomLibraryTables());
} else if (element instanceof Project) {
Collections.addAll(result, ModuleManager.getInstance((Project) element).getModules());
result.add(LibraryTablesRegistrar.getInstance().getLibraryTable((Project) element));
} else if (element instanceof LibraryTable) {
Collections.addAll(result, ((LibraryTable) element).getLibraries());
} else if (element instanceof Module) {
for (OrderEntry entry : ModuleRootManager.getInstance((Module) element).getOrderEntries()) {
if (entry instanceof LibraryOrderEntry) {
final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) entry;
if (LibraryTableImplUtil.MODULE_LEVEL.equals(libraryOrderEntry.getLibraryLevel())) {
final Library library = libraryOrderEntry.getLibrary();
result.add(library);
}
}
}
}
}
use of com.intellij.openapi.roots.LibraryOrderEntry in project intellij-community by JetBrains.
the class MavenProjectImporter method removeUnusedProjectLibraries.
private boolean removeUnusedProjectLibraries() {
Set<Library> unusedLibraries = new HashSet<>();
Collections.addAll(unusedLibraries, myModelsProvider.getAllLibraries());
for (ModuleRootModel eachModel : collectModuleModels()) {
for (OrderEntry eachEntry : eachModel.getOrderEntries()) {
if (eachEntry instanceof LibraryOrderEntry) {
unusedLibraries.remove(((LibraryOrderEntry) eachEntry).getLibrary());
}
}
}
boolean removed = false;
for (Library each : unusedLibraries) {
if (!isDisposed(each) && MavenRootModelAdapter.isMavenLibrary(each) && !MavenRootModelAdapter.isChangedByUser(each)) {
myModelsProvider.removeLibrary(each);
removed = true;
}
}
return removed;
}
use of com.intellij.openapi.roots.LibraryOrderEntry in project intellij-community by JetBrains.
the class MvcUpgradeAction method removeOldMvcSdk.
public static void removeOldMvcSdk(MvcFramework framework, ModifiableRootModel model) {
final LibraryPresentationManager presentationManager = LibraryPresentationManager.getInstance();
for (OrderEntry entry : model.getOrderEntries()) {
if (entry instanceof LibraryOrderEntry) {
final Library library = ((LibraryOrderEntry) entry).getLibrary();
final LibrariesContainer container = LibrariesContainerFactory.createContainer(model);
if (library != null) {
final VirtualFile[] files = container.getLibraryFiles(library, OrderRootType.CLASSES);
if (presentationManager.isLibraryOfKind(Arrays.asList(files), framework.getLibraryKind())) {
model.removeOrderEntry(entry);
}
}
}
}
}
Aggregations