use of com.intellij.openapi.roots.impl.libraries.LibraryImpl in project intellij-community by JetBrains.
the class LibraryElementPresentation method getLibraryTableComment.
public static String getLibraryTableComment(final Library library) {
LibraryTable libraryTable = library.getTable();
String displayName;
if (libraryTable != null) {
displayName = libraryTable.getPresentation().getDisplayName(false);
} else {
Module module = ((LibraryImpl) library).getModule();
String tableName = getLibraryTableDisplayName(library);
displayName = module != null ? "'" + module.getName() + "' " + tableName : tableName;
}
return " (" + displayName + ")";
}
use of com.intellij.openapi.roots.impl.libraries.LibraryImpl in project intellij-community by JetBrains.
the class ArtifactEditorContextImpl method selectLibrary.
@Override
public void selectLibrary(@NotNull Library library) {
final LibraryTable table = library.getTable();
if (table != null) {
ProjectStructureConfigurable.getInstance(getProject()).selectProjectOrGlobalLibrary(library, true);
} else {
final Module module = ((LibraryImpl) library).getModule();
if (module != null) {
final ModuleRootModel rootModel = myParent.getModulesProvider().getRootModel(module);
final String libraryName = library.getName();
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (entry instanceof ModuleLibraryOrderEntryImpl) {
final ModuleLibraryOrderEntryImpl libraryEntry = (ModuleLibraryOrderEntryImpl) entry;
if (libraryName != null && libraryName.equals(libraryEntry.getLibraryName()) || libraryName == null && library.equals(libraryEntry.getLibrary())) {
ProjectStructureConfigurable.getInstance(getProject()).selectOrderEntry(module, libraryEntry);
return;
}
}
}
}
}
}
use of com.intellij.openapi.roots.impl.libraries.LibraryImpl in project intellij-community by JetBrains.
the class LibraryEditingUtil method getNotAddedSuitableLibrariesCondition.
public static Predicate<Library> getNotAddedSuitableLibrariesCondition(final ModuleRootModel rootModel, final FacetsProvider facetsProvider) {
final OrderEntry[] orderEntries = rootModel.getOrderEntries();
final Set<Library> result = new HashSet<>(orderEntries.length);
for (OrderEntry orderEntry : orderEntries) {
if (orderEntry instanceof LibraryOrderEntry && orderEntry.isValid()) {
final LibraryImpl library = (LibraryImpl) ((LibraryOrderEntry) orderEntry).getLibrary();
if (library != null) {
final Library source = library.getSource();
result.add(source != null ? source : library);
}
}
}
return new Predicate<Library>() {
@Override
public boolean apply(Library library) {
if (result.contains(library))
return false;
if (library instanceof LibraryImpl) {
final Library source = ((LibraryImpl) library).getSource();
if (source != null && result.contains(source))
return false;
}
PersistentLibraryKind<?> kind = ((LibraryEx) library).getKind();
if (kind != null) {
LibraryType type = LibraryType.findByKind(kind);
if (type != null && !type.isSuitableModule(rootModel.getModule(), facetsProvider)) {
return false;
}
}
return true;
}
};
}
use of com.intellij.openapi.roots.impl.libraries.LibraryImpl in project intellij-community by JetBrains.
the class LibrariesModifiableModel method getLibraryEditor.
public ExistingLibraryEditor getLibraryEditor(Library library) {
final Library source = ((LibraryImpl) library).getSource();
if (source != null) {
return getLibraryEditor(source);
}
ExistingLibraryEditor libraryEditor = myLibrary2EditorMap.get(library);
if (libraryEditor == null) {
libraryEditor = createLibraryEditor(library);
}
return libraryEditor;
}
use of com.intellij.openapi.roots.impl.libraries.LibraryImpl in project intellij-community by JetBrains.
the class PackagingElementFactoryImpl method createLibraryElements.
@NotNull
@Override
public List<? extends PackagingElement<?>> createLibraryElements(@NotNull Library library) {
final LibraryTable table = library.getTable();
final String libraryName = library.getName();
if (table != null) {
return Collections.singletonList(createLibraryFiles(libraryName, table.getTableLevel(), null));
}
if (libraryName != null) {
final Module module = ((LibraryImpl) library).getModule();
if (module != null) {
return Collections.singletonList(createLibraryFiles(libraryName, LibraryTableImplUtil.MODULE_LEVEL, module.getName()));
}
}
final List<PackagingElement<?>> elements = new ArrayList<>();
for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) {
final String path = FileUtil.toSystemIndependentName(PathUtil.getLocalPath(file));
elements.add(file.isDirectory() && file.isInLocalFileSystem() ? new DirectoryCopyPackagingElement(path) : new FileCopyPackagingElement(path));
}
return elements;
}
Aggregations