Search in sources :

Example 1 with LibraryImpl

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 + ")";
}
Also used : ModuleLibraryTable(com.intellij.openapi.roots.impl.ModuleLibraryTable) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) LibraryImpl(com.intellij.openapi.roots.impl.libraries.LibraryImpl) Module(com.intellij.openapi.module.Module)

Example 2 with LibraryImpl

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;
                    }
                }
            }
        }
    }
}
Also used : LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryImpl(com.intellij.openapi.roots.impl.libraries.LibraryImpl) ModuleRootModel(com.intellij.openapi.roots.ModuleRootModel) ModuleLibraryOrderEntryImpl(com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl) Module(com.intellij.openapi.module.Module)

Example 3 with LibraryImpl

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;
        }
    };
}
Also used : OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) LibraryImpl(com.intellij.openapi.roots.impl.libraries.LibraryImpl) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Predicate(com.intellij.util.containers.Predicate)

Example 4 with LibraryImpl

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;
}
Also used : ExistingLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor) LibraryImpl(com.intellij.openapi.roots.impl.libraries.LibraryImpl) Library(com.intellij.openapi.roots.libraries.Library)

Example 5 with LibraryImpl

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryTable(com.intellij.openapi.roots.libraries.LibraryTable) LibraryImpl(com.intellij.openapi.roots.impl.libraries.LibraryImpl) ArrayList(java.util.ArrayList) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LibraryImpl (com.intellij.openapi.roots.impl.libraries.LibraryImpl)6 Module (com.intellij.openapi.module.Module)3 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)3 OrderEntry (com.intellij.openapi.roots.OrderEntry)2 Library (com.intellij.openapi.roots.libraries.Library)2 NotNull (org.jetbrains.annotations.NotNull)2 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)1 ModuleRootModel (com.intellij.openapi.roots.ModuleRootModel)1 ModuleLibraryOrderEntryImpl (com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl)1 ModuleLibraryTable (com.intellij.openapi.roots.impl.ModuleLibraryTable)1 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)1 ModuleEditor (com.intellij.openapi.roots.ui.configuration.ModuleEditor)1 ExistingLibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Predicate (com.intellij.util.containers.Predicate)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 ArrayList (java.util.ArrayList)1