Package com.intellij.openapi.roots.libraries

Examples of com.intellij.openapi.roots.libraries.LibraryTable


            return mgr.getProgressIndicator();
    }

    public static Library findLibrary(final Project pProject, final Artifact pDependency) {
        final LibraryTablesRegistrar libTableMgr = LibraryTablesRegistrar.getInstance();
        final LibraryTable libTable = libTableMgr.getLibraryTable(pProject);

        String libName = pDependency.toString();
        Library lib = libTable.getLibraryByName(libName);
        if (lib == null) {
            String type = pDependency.getType();
            if (type == null || type.trim().length() == 0)
                type = "jar";

            if (libName.endsWith("." + type)) {
                final int newLength = libName.length() - 1 - type.length();
                libName = libName.substring(0, newLength);
                lib = libTable.getLibraryByName(libName);
            }
        }

        return lib;
    }
View Full Code Here


        protected final LibraryTablesRegistrar libTableMgr = LibraryTablesRegistrar.getInstance();

        public void run() {
            final Project project = problem.getProject();
            final Module module = problem.getModule();
            final LibraryTable libTable = libTableMgr.getLibraryTable(project);

            //
            //if a library with the name of the dependency already exists,
            //use it. Otherwise, create a new one
            //
            final Artifact artifact = problem.getArtifact();
            Library lib = IDEUtils.findLibrary(project, artifact);
            if (lib == null)
                lib = libTable.createLibrary(artifact.toString());

            //
            //get the library's modifiable model
            //
            final Library.ModifiableModel model = lib.getModifiableModel();
View Full Code Here

      @Override public void run() {
        Module[] modules = ModuleManager.getInstance(project).getModules();
        for (Module module : findModulesWithLibrary(modules, libraryName)) {

          ModifiableRootModel moduleRootManager = ModuleRootManager.getInstance(module).getModifiableModel();
          LibraryTable libraryTable = moduleRootManager.getModuleLibraryTable();

          Library library = libraryTable.getLibraryByName(libraryName);
          if (library != null) libraryTable.removeLibrary(library);
          moduleRootManager.commit();

        }
      }
    });
View Full Code Here

      @Override public void run() {
        Module[] modules = ModuleManager.getInstance(project).getModules();
        for (Module module : findModulesWithoutLibrary(modules, libraryName)) {

          ModifiableRootModel moduleRootManager = ModuleRootManager.getInstance(module).getModifiableModel();
          LibraryTable libraryTable = moduleRootManager.getModuleLibraryTable();

          Library library = libraryTable.createLibrary(libraryName);
          Library.ModifiableModel modifiableLibrary = library.getModifiableModel();
          for (Pair<String, OrderRootType> pathAndType : paths) {
            modifiableLibrary.addRoot(pathAndType.first, pathAndType.second);
          }
          modifiableLibrary.commit();
View Full Code Here

    }
  }

  private Library[] getProjectLibraries(Project project) {
    LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
    LibraryTable libraryTable = registrar.getLibraryTable(project);
    return libraryTable.getLibraries();
  }
View Full Code Here

    return libraryTable.getLibraries();
  }

  private Library[] getGlobalLibraries() {
    LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
    LibraryTable libraryTable = registrar.getLibraryTable();
    return libraryTable.getLibraries();
  }
View Full Code Here

    Module[] modules = moduleManager.getModules();
    List<Library> moduleLibraries = new ArrayList<Library>();
    for (Module module : modules) {
      ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
      ModifiableRootModel rootModel = rootManager.getModifiableModel();
      LibraryTable libraryTable = rootModel.getModuleLibraryTable();
      Collections.addAll(moduleLibraries, libraryTable.getLibraries());
    }
    return moduleLibraries.toArray(new Library[moduleLibraries.size()]);
  }
View Full Code Here

        }
        return libraryModels.get(libraryName);
    }

    private Library getIvyIdeaLibrary(ModifiableRootModel modifiableRootModel, final String libraryName) {
        final LibraryTable libraryTable = modifiableRootModel.getModuleLibraryTable();
        final Library library = libraryTable.getLibraryByName(libraryName);
        if (library == null) {
            LOGGER.info("Internal library not found for module " + modifiableRootModel.getModule().getModuleFilePath() + ", creating with name " + libraryName + "...");
            return libraryTable.createLibrary(libraryName);
        }
        return library;
    }
View Full Code Here

                String library = IvyIdeaConfigHelper.getCreatedLibraryName(intellijModule, externalDependency.getConfigurationName());
                librariesInUse.add(library);
            }
        }

        final LibraryTable libraryTable = intellijModule.getModuleLibraryTable();
        for (Library library : libraryTable.getLibraries()) {
            final String libraryName = library.getName();
            if (IvyIdeaConfigHelper.isCreatedLibraryName(libraryName) && !librariesInUse.contains(libraryName)) {
                libraryTable.removeLibrary(library);
            }
        }
    }
View Full Code Here

                    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
                        public void run() {
                            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                                public void run() {
                                    final ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
                                    final LibraryTable moduleLibraryTable = model.getModuleLibraryTable();
                                    final Library[] libraries = moduleLibraryTable.getLibraries();
                                    boolean found = false;
                                    for (final Library library : libraries) {
                                        if (IvyIdeaConfigHelper.isCreatedLibraryName(library.getName())) {
                                            found = true;
                                            moduleLibraryTable.removeLibrary(library);
                                        }
                                    }
                                    if (found) {
                                        model.commit();
                                    } else {
View Full Code Here

TOP

Related Classes of com.intellij.openapi.roots.libraries.LibraryTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.