Package com.intellij.openapi.roots.libraries

Examples of com.intellij.openapi.roots.libraries.Library$ModifiableModel


            if (libraryModel == null) {
              continue;
            }
            String libraryName = libraryModel.getName();
            if (libraryName != null && libraryName.startsWith(LIBRARY_NAME)) {
              Library library = libraryModel.getOriginalLibrary();
              if (library instanceof LibraryEx) {
                LibraryEx libraryEx = (LibraryEx) library;
                if (libraryEx.isDisposed()) {
                  continue;
                }
View Full Code Here


        BundleManifest manifest = bundleManager.getManifestByObject(module);
        exportedPackage = manifest != null ? manifest.getExportedPackage(packageName) : null;
      }
    }
    else if (entry instanceof LibraryOrderEntry) {
      Library library = ((LibraryOrderEntry)entry).getLibrary();
      if (library != null) {
        BundleManifest manifest = bundleManager.getManifestByObject(library);
        exportedPackage = manifest != null ? manifest.getExportedPackage(packageName) : null;
      }
    }
View Full Code Here

                            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

            String libPath = PathUtil.getJarPathForClass(org.junit.Test.class);

            String url = VfsUtil.getUrlForLibraryRoot(new File(libPath));
            VirtualFile libVirtFile = VirtualFileManager.getInstance().findFileByUrl(url);

            final Library jarLibrary = moduleRootModel.getModuleLibraryTable().createLibrary();
            final Library.ModifiableModel libraryModel = jarLibrary.getModifiableModel();
            assert libVirtFile != null;
            libraryModel.addRoot(libVirtFile, OrderRootType.CLASSES);
            libraryModel.commit();

            final LibraryOrderEntry orderEntry = moduleRootModel.findLibraryOrderEntry(jarLibrary);
View Full Code Here

  }

  protected static void addLibraryToRoots(final Module module, final VirtualFile jarFile, final OrderRootType rootType) {
    final ModuleRootManager manager = ModuleRootManager.getInstance(module);
    final ModifiableRootModel rootModel = manager.getModifiableModel();
    final Library jarLibrary = rootModel.getModuleLibraryTable().createLibrary();
    final Library.ModifiableModel libraryModel = jarLibrary.getModifiableModel();
    libraryModel.addRoot(jarFile, rootType);
    libraryModel.commit();
    rootModel.commit();
  }
View Full Code Here

    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));
          final VirtualFile root = JarFileSystem.getInstance().refreshAndFindFileByPath(newPath + "!/");
View Full Code Here

    else if (!orderEntry.isValid()) {
      return SimpleTextCellAppearance.invalid(orderEntry.getPresentableName(), INVALID_ICON);
    }
    else if (orderEntry instanceof LibraryOrderEntry) {
      LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)orderEntry;
      final Library library = libraryOrderEntry.getLibrary();
      if (!libraryOrderEntry.isValid()){ //library can be removed
        return SimpleTextCellAppearance.invalid(orderEntry.getPresentableName(), INVALID_ICON);
      }
      return forLibrary(library);
    }
View Full Code Here

        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

        //Reset them module's library order entries here - this actually happens in org.jetbrains.idea.maven.importing.MavenRootModelAdapter.initOrderEntries()
        for (OrderEntry orderEntry : module.getOrderEntries()) {
            if (orderEntry instanceof LibraryOrderEntry) {
                //Remove any library from the project list so it can be refreshed.
              Library library = ((LibraryOrderEntry) orderEntry).getLibrary();
              if (library != null) {
                projectLibraries.removeLibrary(library);
              }
                module.removeOrderEntry(orderEntry);
            }
View Full Code Here

        for (Object obj : dependencyMaps) {
            Map dependency = (Map) obj;
            //Check if the library already exists
            String libraryName = LEIN_LIB_PREFIX + ": " + dependency.get("groupid") + ":" +
                    dependency.get("artifactid") + ":" + dependency.get("version");
            Library library = libraryTable.getLibraryByName(libraryName);
            if (library == null) {
                library = libraryTable.createLibrary(libraryName);
            }

            // Add the library to a library model, which represents the data for a single library.
            Library.ModifiableModel libraryModel = library.getModifiableModel();

            //Right now only deal with classes - a lot of clojure libraries have the .clj in them and not in a separate file
            //Remove existing classes as this is what maven does - you need to declare the dependencies in the project file
            for (String url : libraryModel.getUrls(OrderRootType.CLASSES)) {
                libraryModel.removeRoot(url, OrderRootType.CLASSES);
View Full Code Here

TOP

Related Classes of com.intellij.openapi.roots.libraries.Library$ModifiableModel

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.