Package com.intellij.openapi.roots.libraries

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


                                          @NotNull DependencyScope scope,
                                          @NotNull Collection<String> binaryPaths,
                                          @NotNull Collection<String> sourcePaths,
                                          @NotNull Collection<String> documentationPaths,
                                          @NotNull DependencyOrder order) {
        LibraryTable libraryTable = ProjectLibraryTable.getInstance(model.getProject());
        Library library = libraryTable.getLibraryByName(libraryName);
        if (library == null) {
            // Create library.
            LibraryTable.ModifiableModel libraryTableModel = libraryTable.getModifiableModel();
            try {
                library = libraryTableModel.createLibrary(libraryName);
                updateLibraryBinaryPaths(library, binaryPaths);
            } finally {
                libraryTableModel.commit();
View Full Code Here


        Collection<String> binaryPaths = dependency.getPaths(LibraryDependency.PathType.BINARY);
        setUpLibraryDependency(model, dependency.getName(), dependency.getScope(), binaryPaths, getDependencyOrder(dependency));
    }

    private void updateDependenciesWithJavadocSources(@NotNull ModifiableRootModel model, @NotNull IdeaAndroidUnitTest androidUnitTest) {
        LibraryTable libraryTable = ProjectLibraryTable.getInstance(model.getProject());

        for (Library library : libraryTable.getLibraries()) {
            Collection<String> sourcesPaths = androidUnitTest.getSourcesPaths(library.getName());
            Collection<String> javadocPaths = androidUnitTest.getJavadocPaths(library.getName());

            updateLibrarySourcesIfAbsent(library, sourcesPaths, OrderRootType.SOURCES);
            updateLibrarySourcesIfAbsent(library, javadocPaths, OrderRootType.DOCUMENTATION);
View Full Code Here

  private static void doInit(@NotNull final Project project) {
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        JSLibraryManager libraryManager = JSLibraryManager.getInstance(project);
        LibraryTable libraryTable = libraryManager.getLibraryTable(ScriptingLibraryModel.LibraryLevel.GLOBAL);
        libraryTable.addListener(new MyLibraryChangeWatcher());
      }
    });
  }
View Full Code Here

            }
            JarFileWriter jarFileWriter = new JarFileWriter();
            jarFileWriter.writeJarFile(lib, name + ".jar", new File(temp + File.separator + "classes"));
            Project project = codegenBean.getActiveProject();

            final LibraryTable table = (LibraryTable) project.getComponent(LibraryTable.class);




            ApplicationManager.getApplication().runWriteAction(new
                    Runnable() {
                        public void run() {

                            String url = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, lib.getAbsolutePath() + File.separator + name + ".jar") + JarFileSystem.JAR_SEPARATOR;



                            VirtualFile jarVirtualFile = VirtualFileManager.getInstance().findFileByUrl(url);
                            Library myLibrary = table.createLibrary(name);
                            Library.ModifiableModel libraryModel = myLibrary.getModifiableModel();
                            libraryModel.addRoot(jarVirtualFile, OrderRootType.CLASSES);
                            libraryModel.commit();

View Full Code Here

  public static void addLibrary(final Module module, final String libName, final String libPath, final String... jarArr) {
    assert ModuleRootManager.getInstance(module).getContentRoots().length > 0 : "content roots must not be empty";
    new WriteCommandAction(module.getProject()) {
      protected void run(Result result) throws Throwable {
        final ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
        final LibraryTable libraryTable = ProjectLibraryTable.getInstance(module.getProject());
        final Library library = libraryTable.createLibrary(libName);
        final Library.ModifiableModel libraryModel = library.getModifiableModel();
        for (String jar : jarArr) {
          final String path = libPath + jar;
          final String newPath = model.getContentRoots()[0].getPath() + "/" + jar;
          FileUtil.copy(new File(path), new File(newPath));
View Full Code Here

  public static Library findLibrary(String libraryName, String libraryLevel, Project project) {
    if (libraryName == null) {
      return null;
    }

    LibraryTable table = findTable(libraryLevel, project);
    if (table == null) {
      return null;
    }
    else {
      return table.getLibraryByName(libraryName);
    }
  }
View Full Code Here

        }
        else {
            compilerModuleExtension.inheritCompilerOutputPath(true);
        }

        LibraryTable libraryTable = rootModel.getModuleLibraryTable();
        for (Pair<String, String> libInfo : myModuleLibraries) {
            final String moduleLibraryPath = libInfo.first;
            final String sourceLibraryPath = libInfo.second;
            Library library = libraryTable.createLibrary();
            Library.ModifiableModel modifiableModel = library.getModifiableModel();
            modifiableModel.addRoot(getUrlByPath(moduleLibraryPath), OrderRootType.CLASSES);
            if (sourceLibraryPath != null) {
                modifiableModel.addRoot(getUrlByPath(sourceLibraryPath), OrderRootType.SOURCES);
            }
            modifiableModel.commit();
        }
        RunnableHelper.runWhenInitialized(getMyProject(), new Runnable() {
            public void run() {
                final LibraryTablesRegistrar libTablesRegistrar = LibraryTablesRegistrar.getInstance();

                final LibraryTable libraryTable = libTablesRegistrar.getLibraryTable(getMyProject());

                final LibraryTable.ModifiableModel libTableModel = libraryTable.getModifiableModel();


                Library library = libTableModel.createLibrary(AsposeConstants.LIBRARY_NAME);
                libTableModel.commit();

                @NonNls final String path = getContentEntryPath() + File.separator + AsposeConstants.LIB_FOLDER;
                new File(path).mkdirs();


                for (AsposeJavaComponent component : AsposeJavaComponents.list.values()) {
                    if (component.is_selected()) {
                        try {
                            AsposeComponentsManager.copyDirectory(AsposeComponentsManager.getLibaryDownloadPath() + component.get_name().toLowerCase(), path+File.separator+component.get_name());
                        } catch (IOException ex) {
                            ex.printStackTrace();
                        }
                        String[] children = new File(path +File.separator+component.get_name().toLowerCase()+ File.separator).list();
                        for (String _child : children) {
                            String jarPath = "jar://" + path +File.separator+component.get_name()+ File.separator + _child + "!/";

                            Library.ModifiableModel model = library.getModifiableModel();

                            model.addRoot(jarPath, OrderRootType.CLASSES);

                            model.commit();

                        }
                    }
                }



                Collection<Module> modules = ModuleUtil.getModulesOfType(getMyProject(), StdModuleTypes.JAVA);
                Iterator itr = modules.iterator();
                Module module = null;
                while (itr.hasNext()) {
                    module = (Module) itr.next();
                    break;
                }
                final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);

                final ModifiableRootModel moduleRootModel = moduleRootManager.getModifiableModel();

                final Library lib = libraryTable.getLibraryByName(AsposeConstants.LIBRARY_NAME);

                if (moduleRootModel.findLibraryOrderEntry(lib) == null) {

                    moduleRootModel.addLibraryEntry(lib);
View Full Code Here

  @NotNull
  public static String getErlangSdkPath(@NotNull Project project) {
    AccessToken token = ApplicationManager.getApplication().acquireReadActionLock();
    try {
      LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
      Library lib = table.getLibraryByName(ERLANG_LIBRARY_NAME);
      String[] urls = lib == null ? ArrayUtil.EMPTY_STRING_ARRAY : lib.getUrls(OrderRootType.CLASSES);
      return VfsUtilCore.urlToPath(ObjectUtils.notNull(ArrayUtil.getFirstElement(urls), ""));
    }
    finally {
      token.finish();
View Full Code Here

 
  private void setUpOrUpdateSdk(@NotNull final String path) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);
        Library get = table.getLibraryByName(ERLANG_LIBRARY_NAME);
        Library lib = get != null ? get : table.createLibrary(ERLANG_LIBRARY_NAME);

        Library.ModifiableModel libraryModel = lib.getModifiableModel();
        String libUrl = ArrayUtil.getFirstElement(lib.getUrls(OrderRootType.CLASSES));
        if (libUrl != null) {
          libraryModel.removeRoot(libUrl, OrderRootType.CLASSES);
        }

        String url = VfsUtilCore.pathToUrl(path);
        libraryModel.addRoot(url, OrderRootType.CLASSES);
        libraryModel.commit();
       
        boolean remove = path.isEmpty();
        if (remove) {
          updateModules(lib, true);
          table.removeLibrary(lib);
        }

        table.getModifiableModel().commit();

        if (!remove) {
          updateModules(lib, false);
        }
      }
View Full Code Here

    }
  }

  public static Library[] getProjectClojureLibraries(Project project) {
    if (project == null) return new Library[0];
    final LibraryTable table = ProjectLibraryTable.getInstance(project);
    final List<Library> all = ContainerUtil.findAll(table.getLibraries(), CLOJURE_LIB_CONDITION);
    return all.toArray(new Library[all.size()]);
  }
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.