Search in sources :

Example 11 with OrderEntry

use of com.intellij.openapi.roots.OrderEntry in project intellij-community by JetBrains.

the class AddNewModuleLibraryAction method createTableItem.

@Override
protected ClasspathTableItem<?> createTableItem(final Library item) {
    final OrderEntry[] entries = myClasspathPanel.getRootModel().getOrderEntries();
    for (OrderEntry entry : entries) {
        if (entry instanceof LibraryOrderEntry) {
            final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) entry;
            if (item.equals(libraryOrderEntry.getLibrary())) {
                return ClasspathTableItem.createLibItem(libraryOrderEntry, myContext);
            }
        }
    }
    LOG.error("Unknown library " + item);
    return null;
}
Also used : LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry)

Example 12 with OrderEntry

use of com.intellij.openapi.roots.OrderEntry in project intellij-community by JetBrains.

the class ChangeLibraryLevelInClasspathAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent event) {
    final OrderEntry entry = myPanel.getSelectedEntry();
    if (!(entry instanceof LibraryOrderEntry))
        return;
    LibraryOrderEntry libraryEntry = (LibraryOrderEntry) entry;
    final LibraryEx library = (LibraryEx) libraryEntry.getLibrary();
    if (library == null)
        return;
    final Library copied = doCopy(library);
    if (copied == null)
        return;
    if (!isConvertingToModuleLibrary()) {
        OrderEntryUtil.replaceLibrary(myPanel.getRootModel(), library, copied);
    } else {
        OrderEntryUtil.replaceLibraryEntryByAdded(myPanel.getRootModel(), libraryEntry);
    }
}
Also used : LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) OrderEntry(com.intellij.openapi.roots.OrderEntry) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) Library(com.intellij.openapi.roots.libraries.Library)

Example 13 with OrderEntry

use of com.intellij.openapi.roots.OrderEntry in project intellij-community by JetBrains.

the class ClasspathTableModel method getEntries.

private List<OrderEntry> getEntries() {
    final int count = getRowCount();
    final List<OrderEntry> entries = new ArrayList<>(count);
    for (int row = 0; row < count; row++) {
        final OrderEntry entry = getItem(row).getEntry();
        if (entry != null) {
            entries.add(entry);
        }
    }
    return entries;
}
Also used : OrderEntry(com.intellij.openapi.roots.OrderEntry) JdkOrderEntry(com.intellij.openapi.roots.JdkOrderEntry) ArrayList(java.util.ArrayList)

Example 14 with OrderEntry

use of com.intellij.openapi.roots.OrderEntry in project intellij-community by JetBrains.

the class ClasspathTableModel method init.

public void init() {
    final OrderEntry[] orderEntries = getModel().getOrderEntries();
    boolean hasJdkOrderEntry = false;
    List<ClasspathTableItem<?>> items = new ArrayList<>();
    for (final OrderEntry orderEntry : orderEntries) {
        if (orderEntry instanceof JdkOrderEntry) {
            hasJdkOrderEntry = true;
        }
        items.add(ClasspathTableItem.createItem(orderEntry, myContext));
    }
    if (!hasJdkOrderEntry) {
        items.add(0, new InvalidJdkItem());
    }
    setItems(items);
}
Also used : OrderEntry(com.intellij.openapi.roots.OrderEntry) JdkOrderEntry(com.intellij.openapi.roots.JdkOrderEntry) JdkOrderEntry(com.intellij.openapi.roots.JdkOrderEntry) ArrayList(java.util.ArrayList)

Example 15 with OrderEntry

use of com.intellij.openapi.roots.OrderEntry in project intellij-community by JetBrains.

the class PsiFileNode method isNavigatableLibraryRoot.

private boolean isNavigatableLibraryRoot() {
    VirtualFile jarRoot = getJarRoot();
    final Project project = getProject();
    if (jarRoot != null && project != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) {
        final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(jarRoot, project);
        return orderEntry != null && ProjectSettingsService.getInstance(project).canOpenLibraryOrSdkSettings(orderEntry);
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) OrderEntry(com.intellij.openapi.roots.OrderEntry)

Aggregations

OrderEntry (com.intellij.openapi.roots.OrderEntry)54 Module (com.intellij.openapi.module.Module)24 VirtualFile (com.intellij.openapi.vfs.VirtualFile)23 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)18 Project (com.intellij.openapi.project.Project)14 Library (com.intellij.openapi.roots.libraries.Library)12 ArrayList (java.util.ArrayList)11 JdkOrderEntry (com.intellij.openapi.roots.JdkOrderEntry)10 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)10 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)8 ModuleOrderEntry (com.intellij.openapi.roots.ModuleOrderEntry)8 Nullable (org.jetbrains.annotations.Nullable)8 NotNull (org.jetbrains.annotations.NotNull)7 ModuleLibraryOrderEntryImpl (com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl)5 List (java.util.List)5 Sdk (com.intellij.openapi.projectRoots.Sdk)4 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)4 AccessToken (com.intellij.openapi.application.AccessToken)3 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)3 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)3