use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class LibraryGroupNode method getLibraryRoots.
@NotNull
public static VirtualFile[] getLibraryRoots(@NotNull LibraryOrderEntry orderEntry) {
Library library = orderEntry.getLibrary();
if (library == null)
return VirtualFile.EMPTY_ARRAY;
OrderRootType[] rootTypes = LibraryType.DEFAULT_EXTERNAL_ROOT_TYPES;
if (library instanceof LibraryEx) {
if (((LibraryEx) library).isDisposed())
return VirtualFile.EMPTY_ARRAY;
PersistentLibraryKind<?> libKind = ((LibraryEx) library).getKind();
if (libKind != null) {
rootTypes = LibraryType.findByKind(libKind).getExternalRootTypes();
}
}
final ArrayList<VirtualFile> files = new ArrayList<>();
for (OrderRootType rootType : rootTypes) {
files.addAll(Arrays.asList(library.getFiles(rootType)));
}
return VfsUtilCore.toVirtualFileArray(files);
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class RepositoryLibrarySupport method isLibraryEqualsToSelected.
private boolean isLibraryEqualsToSelected(Library library) {
if (!(library instanceof LibraryEx)) {
return false;
}
LibraryEx libraryEx = (LibraryEx) library;
if (!RepositoryLibraryType.REPOSITORY_LIBRARY_KIND.equals(libraryEx.getKind())) {
return false;
}
LibraryProperties libraryProperties = libraryEx.getProperties();
if (libraryProperties == null || !(libraryProperties instanceof RepositoryLibraryProperties)) {
return false;
}
RepositoryLibraryProperties repositoryLibraryProperties = (RepositoryLibraryProperties) libraryProperties;
RepositoryLibraryDescription description = RepositoryLibraryDescription.findDescription(repositoryLibraryProperties);
if (!description.equals(libraryDescription)) {
return false;
}
return Comparing.equal(repositoryLibraryProperties.getVersion(), model.getVersion());
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class ChangeLibraryLevelActionBase method doCopy.
@Nullable
protected Library doCopy(LibraryEx library) {
final VirtualFile baseDir = getBaseDir();
final String libPath = baseDir != null ? baseDir.getPath() + "/lib" : "";
final VirtualFile[] classesRoots = library.getFiles(OrderRootType.CLASSES);
boolean allowEmptyName = isConvertingToModuleLibrary() && classesRoots.length == 1;
final String libraryName = allowEmptyName ? "" : StringUtil.notNullize(library.getName(), LibraryTypeServiceImpl.suggestLibraryName(classesRoots));
final LibraryTableModifiableModelProvider provider = getModifiableTableModelProvider();
final ChangeLibraryLevelDialog dialog = new ChangeLibraryLevelDialog(getParentComponent(), myProject, myCopy, libraryName, libPath, allowEmptyName, provider);
if (!dialog.showAndGet()) {
return null;
}
final Set<File> fileToCopy = new LinkedHashSet<>();
final Map<String, String> copiedFiles = new HashMap<>();
final String targetDirectoryPath = dialog.getDirectoryForFilesPath();
if (targetDirectoryPath != null) {
for (OrderRootType type : OrderRootType.getAllTypes()) {
for (VirtualFile root : library.getFiles(type)) {
if (root.isInLocalFileSystem() || root.getFileSystem() instanceof ArchiveFileSystem) {
fileToCopy.add(VfsUtil.virtualToIoFile(PathUtil.getLocalFile(root)));
}
}
}
if (!copyOrMoveFiles(fileToCopy, targetDirectoryPath, copiedFiles)) {
return null;
}
}
final Library copied = provider.getModifiableModel().createLibrary(StringUtil.nullize(dialog.getLibraryName()), library.getKind());
final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx) copied.getModifiableModel();
LibraryEditingUtil.copyLibrary(library, copiedFiles, model);
WriteAction.run(() -> model.commit());
return copied;
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class LibraryPresentationManagerImpl method getCustomIcon.
@Override
public Icon getCustomIcon(@NotNull Library library, StructureConfigurableContext context) {
LibraryEx libraryEx = (LibraryEx) library;
final LibraryKind kind = libraryEx.getKind();
if (kind != null) {
return LibraryType.findByKind(kind).getIcon(libraryEx.getProperties());
}
final List<Icon> icons = getCustomIcons(library, context);
if (icons.size() == 1) {
return icons.get(0);
}
return null;
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class LibraryProjectStructureElement method check.
@Override
public void check(ProjectStructureProblemsHolder problemsHolder) {
if (((LibraryEx) myLibrary).isDisposed())
return;
final LibraryEx library = (LibraryEx) myContext.getLibraryModel(myLibrary);
if (library == null || library.isDisposed())
return;
reportInvalidRoots(problemsHolder, library, OrderRootType.CLASSES, "classes", ProjectStructureProblemType.error("library-invalid-classes-path"));
final String libraryName = library.getName();
if (libraryName == null || !libraryName.startsWith("Maven: ")) {
reportInvalidRoots(problemsHolder, library, OrderRootType.SOURCES, "sources", ProjectStructureProblemType.warning("library-invalid-source-javadoc-path"));
reportInvalidRoots(problemsHolder, library, JavadocOrderRootType.getInstance(), "javadoc", ProjectStructureProblemType.warning("library-invalid-source-javadoc-path"));
}
}
Aggregations