Package com.intellij.openapi.roots.libraries

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


  @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);
View Full Code Here

  @NotNull
  public static String getClojureSdkJarPath(Module module) {
    if (module == null) return "";
    Library[] libraries = getClojureSdkLibrariesByModule(module);
    if (libraries.length == 0) return "";
    final Library library = libraries[0];
    return getClojureJarPathForLibrary(library);
  }
View Full Code Here

  public static boolean isClojureConfigured(final Module module) {
    ModuleRootManager manager = ModuleRootManager.getInstance(module);
    for (OrderEntry entry : manager.getOrderEntries()) {
      if (entry instanceof LibraryOrderEntry) {
        Library library = ((LibraryOrderEntry) entry).getLibrary();
        if (library != null) {
          for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) {
            String path = file.getPath();
            if (path.endsWith(".jar!/")) {
              if (file.findFileByRelativePath(CLOJURE_MAIN_CLASS_FILE) != null) {
                return true;
              }
View Full Code Here

        ModuleRootManager manager = ModuleRootManager.getInstance(module);
        ModifiableRootModel model = manager.getModifiableModel();
        for (OrderEntry entry : model.getOrderEntries()) {
          if (entry instanceof LibraryOrderEntry) {
            LibraryOrderEntry libEntry = (LibraryOrderEntry) entry;
            Library library = libEntry.getLibrary();
            if (condition.value(library)) {
              libraries.add(library);
            }
          }
        }
View Full Code Here

    if (processor.result) {
      if (rootModel == null) {
        rootModel = rootManager.getModifiableModel();
      }
      final LibraryTable libraryTable = rootModel.getModuleLibraryTable();
      final Library scalaLib = libraryTable.createLibrary(clojureLibraryName);
      final Library.ModifiableModel libModel = scalaLib.getModifiableModel();
      libModels.add(libModel);
      addLibraryRoots(libModel, mockLib, mockLibSrc);
    }
    return rootModel;
  }
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();
View Full Code Here

                    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

            ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
            OrderEntry[] entries = rootManager.getOrderEntries();
            for (OrderEntry entry : entries) {
                if (entry instanceof LibraryOrderEntry) {
                    final LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entry;
                    final Library library = libraryEntry.getLibrary();
//                    log.debug("\tEntry: " + libraryEntry.getPresentableName());
                    String[] sourceUrls = entry.getUrls(OrderRootType.SOURCES);
                    String alfrescoJarUrl = null;
                    String alfrescoJavaJarUrl = null;
                    for (String url : sourceUrls) {
//                        log.debug("\t\tURL: " + url);
                        if (alfrescoJar.matcher(url).matches())
                            alfrescoJarUrl = url;
                        if (alfrescoJavaJar.matcher(url).matches())
                            alfrescoJavaJarUrl = url;
                    }
                    if (null != alfrescoJarUrl) {
                        final String finalAlfrescoJarUrl = alfrescoJarUrl;
                        final String finalAlfrescoJavaJarUrl = alfrescoJavaJarUrl;
                        ApplicationManager.getApplication().runWriteAction(new Runnable() {
                            @Override
                            public void run() {
                                Library.ModifiableModel modifiableModel = null;
                                if (library != null) {
                                    log.info("Updating sources for: " + libraryEntry.getPresentableName());
                                    modifiableModel = library.getModifiableModel();
                                    // TODO: Need to be smarter about this, may need to handle multiple
                                    if (null != finalAlfrescoJavaJarUrl)
                                        modifiableModel.removeRoot(finalAlfrescoJavaJarUrl, OrderRootType.SOURCES);
                                    modifiableModel.addRoot(finalAlfrescoJarUrl + "java", OrderRootType.SOURCES);
                                    modifiableModel.commit();
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.