Package com.intellij.openapi.roots

Examples of com.intellij.openapi.roots.ModifiableRootModel


            //
            //add the library to the module and commit the change
            //
            final ModuleRootManager modRootMgr = ModuleRootManager.getInstance(module);
            final ModifiableRootModel moduleRootModel = modRootMgr.getModifiableModel();
            moduleRootModel.addLibraryEntry(lib);
            moduleRootModel.commit();
        }
View Full Code Here


    ModuleManager moduleManager = ModuleManager.getInstance(project);
    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

    private final ModifiableRootModel intellijModule;
    private final LibraryModels libraryModels;

    public static IntellijModuleWrapper forModule(Module module) {
        ModifiableRootModel modifiableModel = null;
        try {
            modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
            return new IntellijModuleWrapper(modifiableModel);
        } catch (RuntimeException e) {
            if (modifiableModel != null) {
                modifiableModel.dispose();
            }
            throw e;
        }
    }
View Full Code Here

                    indicator.setText2("Removing for module " + module.getName());
                    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 {
                                        model.dispose();
                                    }
                                }
                            });
                        }
                    }, ModalityState.NON_MODAL);
View Full Code Here

      if (libraryTableModifiableModel.isChanged()) {
        libraryTableModifiableModel.commit();
      }

      // similar to DartSdkGlobalLibUtil.configureDependencyOnGlobalLib
      final ModifiableRootModel moduleModifiableModel = modifiableModelsProvider.getModuleModifiableModel(module);
      moduleModifiableModel.addLibraryEntry(dartSdkGlobalLib);
      modifiableModelsProvider.commitModuleModifiableModel(moduleModifiableModel);
    }

    DartiumUtil.applyDartiumSettings(FileUtilRt.toSystemIndependentName(data.dartiumPath), data.dartiumSettings);
  }
View Full Code Here

    myFixture.addFileToProject("dir2/example/web/foo.dart", "");
    myFixture.addFileToProject("dir2/example/web/sub/foo.dart", "");

    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
        final ContentEntry contentEntry = model.getContentEntries()[0];
        contentEntry.addExcludeFolder(rootUrl + "/dir1/someFolder");
        contentEntry.addExcludeFolder(rootUrl + "/dir1/packages/project1");
        contentEntry.addExcludeFolder(rootUrl + "/dir1/web/packages");
        contentEntry.addExcludeFolder(rootUrl + "/dir2/packages/oldProject2Name");
        contentEntry.addExcludeFolder(rootUrl + "/dir2/someFolder");
        contentEntry.addExcludeFolder(rootUrl + "/dir2/lib/someFolder");
        contentEntry.addExcludeFolder(rootUrl + "/dir2/example/nonexistent/packages");
        contentEntry.addExcludeFolder(rootUrl + "/dir2/example/packages/oldProject3Name");
        model.commit();
      }
    });

    DartProjectComponent.excludeBuildAndPackagesFolders(myModule, pubspec2);
View Full Code Here

    assertEquals(rootPath + "/example/packages/SomePackage/somepack.dart", file.getPath());
    assertEquals("package:SomePackage/somepack.dart", resolver.getDartUrlForFile(file));

    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      public void run() {
        final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(myModule).getModifiableModel();
        try {
          final Library library = modifiableModel.getModuleLibraryTable().createLibrary("Dart custom package roots");
          final Library.ModifiableModel libModel = library.getModifiableModel();
          libModel.addRoot(customPack1.getUrl(), OrderRootType.CLASSES);
          libModel.addRoot(customPack2.getUrl(), OrderRootType.CLASSES);
          libModel.commit();
          modifiableModel.commit();
        }
        catch (Exception e) {
          if (!modifiableModel.isDisposed()) modifiableModel.dispose();
        }
      }
    });

    resolver = DartUrlResolver.getInstance(getProject(), nestedPubspec);
View Full Code Here

        assertThat(osmorcFacetConfiguration.getManifestLocation(), equalTo(manifestFile.getPath()));
        assertThat(osmorcFacetConfiguration.isUseProjectDefaultManifestFileLocation(), equalTo(false));

        OsmorcFacet osmorcFacet = OsmorcFacetType.getInstance().createFacet(t0, "OSGi", osmorcFacetConfiguration, null);

        ModifiableRootModel model = ModuleRootManager.getInstance(t0).getModifiableModel();
        try {
            detector.setupFacet(osmorcFacet, model);

            assertThat(osmorcFacetConfiguration.getManifestLocation(), equalTo("src/META-INF/MANIFEST.MF"));
        }
        finally {
            model.dispose();
        }
    }
View Full Code Here

        assertThat(osmorcFacetConfiguration.getManifestLocation(), equalTo(manifestFile.getPath()));
        assertThat(osmorcFacetConfiguration.isUseProjectDefaultManifestFileLocation(), equalTo(false));

        OsmorcFacet osmorcFacet = OsmorcFacetType.getInstance().createFacet(t2, "OSGi", osmorcFacetConfiguration, null);

        ModifiableRootModel model = ModuleRootManager.getInstance(t2).getModifiableModel();
        try {
            detector.setupFacet(osmorcFacet, model);

            assertThat(osmorcFacetConfiguration.getManifestLocation(), equalTo(""));
            assertThat(osmorcFacetConfiguration.getBundlorFileLocation(), equalTo("src/META-INF/template.mf"));
            assertThat(osmorcFacetConfiguration.isUseBundlorFile(), equalTo(true));

        }
        finally {
            model.dispose();
        }
    }
View Full Code Here

  private void updateRoots(final Updater updater) {
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
      @Override
      public void run() {
        try {
          ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(getModule()).getModifiableModel();
          updater.update(modifiableModel);
          modifiableModel.commit();
        }
        catch (Throwable e) {
          throw new RuntimeException(e);
        }
      }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.roots.ModifiableRootModel

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.