Search in sources :

Example 11 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.

the class AddLibraryToModuleDependenciesAction method update.

@Override
public void update(AnActionEvent e) {
    final ProjectStructureElement element = myConfigurable.getSelectedElement();
    boolean visible = false;
    if (element instanceof LibraryProjectStructureElement) {
        final LibraryEx library = (LibraryEx) ((LibraryProjectStructureElement) element).getLibrary();
        visible = !LibraryEditingUtil.getSuitableModules(ModuleStructureConfigurable.getInstance(myProject), library.getKind(), library).isEmpty();
    }
    e.getPresentation().setVisible(visible);
}
Also used : LibraryProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement) ProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) LibraryProjectStructureElement(com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement)

Example 12 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx 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 LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.

the class LibraryTest method testRemoveExcludedRootWhenParentRootIsRemoved.

public void testRemoveExcludedRootWhenParentRootIsRemoved() {
    VirtualFile jar = getJDomJar();
    LibraryEx library = (LibraryEx) createLibrary("junit", jar, null);
    LibraryEx.ModifiableModelEx model = library.getModifiableModel();
    VirtualFile excluded = jar.findChild("org");
    assertNotNull(excluded);
    model.addExcludedRoot(excluded.getUrl());
    commit(model);
    assertOrderedEquals(library.getExcludedRoots(), excluded);
    LibraryEx.ModifiableModelEx model2 = library.getModifiableModel();
    model2.removeRoot(jar.getUrl(), OrderRootType.CLASSES);
    commit(model2);
    assertEmpty(library.getExcludedRoots());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx)

Example 14 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.

the class LibraryTest method testAddRemoveExcludedRoot.

public void testAddRemoveExcludedRoot() {
    VirtualFile jar = getJDomJar();
    LibraryEx library = (LibraryEx) createLibrary("junit", jar, null);
    assertEmpty(library.getExcludedRoots());
    LibraryEx.ModifiableModelEx model = library.getModifiableModel();
    model.addExcludedRoot(jar.getUrl());
    commit(model);
    assertOrderedEquals(library.getExcludedRoots(), jar);
    LibraryEx.ModifiableModelEx model2 = library.getModifiableModel();
    model2.removeExcludedRoot(jar.getUrl());
    commit(model2);
    assertEmpty(library.getExcludedRoots());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx)

Example 15 with LibraryEx

use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-plugins by JetBrains.

the class FlexBuildConfigurationsExtension method selectOrderEntry.

@Nullable
public ActionCallback selectOrderEntry(@NotNull final Module module, @Nullable final OrderEntry entry) {
    if (ModuleType.get(module) != FlexModuleType.getInstance()) {
        return null;
    }
    if (entry instanceof LibraryOrderEntry) {
        final Library library = ((LibraryOrderEntry) entry).getLibrary();
        if (library != null && library.getTable() == null && ((LibraryEx) library).getKind() == FlexLibraryType.FLEX_LIBRARY) {
            final String libraryId = FlexProjectRootsUtil.getLibraryId(library);
            final List<CompositeConfigurable> configurables = myConfigurator.getBCConfigurables(module);
            // several build configurations may depend on the same library, here we select the first one we find
            for (CompositeConfigurable configurable : configurables) {
                final FlexBCConfigurable bcConfigurable = FlexBCConfigurable.unwrap(configurable);
                final Dependencies dependencies = bcConfigurable.getDependenciesConfigurable().getEditableObject();
                for (DependencyEntry e : dependencies.getEntries()) {
                    if (!(e instanceof ModuleLibraryEntry) || !((ModuleLibraryEntry) e).getLibraryId().equals(libraryId)) {
                        continue;
                    }
                    final Place p = FlexProjectStructureUtil.createPlace(bcConfigurable, DependenciesConfigurable.TAB_NAME);
                    final DependenciesConfigurable.Location.TableEntry tableEntry = DependenciesConfigurable.Location.TableEntry.forModuleLibrary(libraryId);
                    p.putPath(FlexBCConfigurable.LOCATION_ON_TAB, tableEntry);
                    return ProjectStructureConfigurable.getInstance(module.getProject()).navigateTo(p, true);
                }
            }
        }
    }
    return ProjectStructureConfigurable.getInstance(module.getProject()).select(module.getName(), null, true);
}
Also used : ModuleLibraryEntry(com.intellij.lang.javascript.flex.projectStructure.model.ModuleLibraryEntry) CompositeConfigurable(com.intellij.lang.javascript.flex.projectStructure.ui.CompositeConfigurable) LibraryEx(com.intellij.openapi.roots.impl.libraries.LibraryEx) LibraryOrderEntry(com.intellij.openapi.roots.LibraryOrderEntry) FlexBCConfigurable(com.intellij.lang.javascript.flex.projectStructure.ui.FlexBCConfigurable) DependencyEntry(com.intellij.lang.javascript.flex.projectStructure.model.DependencyEntry) Library(com.intellij.openapi.roots.libraries.Library) Dependencies(com.intellij.lang.javascript.flex.projectStructure.model.Dependencies) Place(com.intellij.ui.navigation.Place) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)38 Library (com.intellij.openapi.roots.libraries.Library)19 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 NotNull (org.jetbrains.annotations.NotNull)8 Nullable (org.jetbrains.annotations.Nullable)8 Module (com.intellij.openapi.module.Module)6 LibraryTable (com.intellij.openapi.roots.libraries.LibraryTable)6 Project (com.intellij.openapi.project.Project)5 FlexLibraryProperties (com.intellij.lang.javascript.flex.library.FlexLibraryProperties)4 Logger (com.intellij.openapi.diagnostic.Logger)4 ContainerUtil (com.intellij.util.containers.ContainerUtil)4 Disposable (com.intellij.openapi.Disposable)3 OrderRootType (com.intellij.openapi.roots.OrderRootType)3 LibraryProperties (com.intellij.openapi.roots.libraries.LibraryProperties)3 StringUtil (com.intellij.openapi.util.text.StringUtil)3 List (java.util.List)3 FlexCommonUtils (com.intellij.flex.FlexCommonUtils)2 BuildConfigurationNature (com.intellij.flex.model.bc.BuildConfigurationNature)2 OutputType (com.intellij.flex.model.bc.OutputType)2