com.intellij.openapi.roots.ModifiableModelsProvider Java Examples

The following examples show how to use com.intellij.openapi.roots.ModifiableModelsProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlutterSmallIDEProjectGenerator.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void applyDartModule(FlutterSdk sdk, Project project, Module module, PubRoot root) {
  ApplicationManager.getApplication().runWriteAction(() -> {
    // Set up Dart SDK.
    final String dartSdkPath = sdk.getDartSdkPath();
    if (dartSdkPath == null) {
      FlutterMessages.showError("Error creating project", "unable to get Dart SDK"); // shouldn't happen; we just created it.
      return;
    }
    DartPlugin.ensureDartSdkConfigured(project, sdk.getDartSdkPath());
    DartPlugin.enableDartSdk(module);
    FlutterSdkUtil.updateKnownSdkPaths(sdk.getHomePath());

    // Set up module.
    final ModifiableRootModel modifiableModel = ModifiableModelsProvider.SERVICE.getInstance().getModuleModifiableModel(module);
    modifiableModel.addContentEntry(root.getRoot());
    ModifiableModelsProvider.SERVICE.getInstance().commitModuleModifiableModel(modifiableModel);

    FlutterModuleUtils.autoShowMain(project, root);
  });
}
 
Example #2
Source File: FlutterSmallIDEProjectGenerator.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void applyDartModule(FlutterSdk sdk, Project project, Module module, PubRoot root) {
  ApplicationManager.getApplication().runWriteAction(() -> {
    // Set up Dart SDK.
    final String dartSdkPath = sdk.getDartSdkPath();
    if (dartSdkPath == null) {
      FlutterMessages.showError("Error creating project", "unable to get Dart SDK"); // shouldn't happen; we just created it.
      return;
    }
    DartPlugin.ensureDartSdkConfigured(project, sdk.getDartSdkPath());
    DartPlugin.enableDartSdk(module);
    FlutterSdkUtil.updateKnownSdkPaths(sdk.getHomePath());

    // Set up module.
    final ModifiableRootModel modifiableModel = ModifiableModelsProvider.SERVICE.getInstance().getModuleModifiableModel(module);
    modifiableModel.addContentEntry(root.getRoot());
    ModifiableModelsProvider.SERVICE.getInstance().commitModuleModifiableModel(modifiableModel);

    FlutterModuleUtils.autoShowMain(project, root);
  });
}
 
Example #3
Source File: HaxeProjectConfigurationUpdater.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
@Override
public void updateProject(@NotNull Project project, @NotNull ModifiableModelsProvider modelsProvider, @NotNull ModulesProvider modulesProvider) {
  if(myLibraries != null && !myLibraries.isEmpty()) {
    List<LibraryData> libraries = collectLibraries(project);
    if(!libraries.isEmpty()) {
      setupLibraries(project, modelsProvider, modulesProvider, libraries);
    }
  }
  if(myHxml != null) {
    Module rootModule = getRootModule(modelsProvider, modulesProvider);
    if(rootModule != null) {
      setupCompilationSettings(rootModule, modelsProvider.getModuleModifiableModel(rootModule));
      setupHxmlRunConfigurations(rootModule);
    }
  }
}
 
Example #4
Source File: HaxeProjectConfigurationUpdater.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
private void setupLibraries(Project project, ModifiableModelsProvider modelsProvider, ModulesProvider modulesProvider, List<LibraryData> libraries) {
  LibraryTable.ModifiableModel librariesModel = modelsProvider.getLibraryTableModifiableModel(project);

  for(LibraryData lib:libraries) {
    VirtualFile root = LocalFileSystem.getInstance().findFileByPath(lib.getClasspath());
    if(root != null) {
      LibraryImpl library = (LibraryImpl)librariesModel.createLibrary(lib.getName());
      LibraryEx.ModifiableModelEx model = library.getModifiableModel();
      model.setKind(HaxeLibraryType.HAXE_LIBRARY);
      model.addRoot(root, OrderRootType.CLASSES);
      model.addRoot(root, OrderRootType.SOURCES);
      model.commit();

      for(Module module:modulesProvider.getModules()) {
        ModifiableRootModel moduleModel = modelsProvider.getModuleModifiableModel(module);
        moduleModel.addLibraryEntry(library);
        moduleModel.commit();
      }
    }
  }

  librariesModel.commit();
}
 
Example #5
Source File: MuleFrameworkDetector.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void setupFramework(@NotNull ModifiableModelsProvider modifiableModelsProvider, @NotNull ModulesProvider modulesProvider)
{
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            final Module moduleForFile = ProjectRootManager.getInstance(context.getProject()).getFileIndex().getModuleForFile(collection.iterator().next());
            final AddSupportForSingleFrameworkDialog dialog = AddSupportForSingleFrameworkDialog.createDialog(moduleForFile, new MuleFrameworkSupportProvider());
            dialog.setTitle(dialog.getTitle() + " - " + moduleForFile.getName());
            dialog.showAndGet();
        }
    });
}
 
Example #6
Source File: MuleFrameworkConfigurable.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void addSupport(@NotNull Module module, @NotNull ModifiableRootModel modifiableRootModel, @NotNull ModifiableModelsProvider modifiableModelsProvider) {

    String muleHome = null;

    Library[] libs = modifiableModelsProvider.getLibraryTableModifiableModel().getLibraries();
    for (Library nextLib : libs) {
        LibraryEx libraryEx = (LibraryEx)nextLib;
        if (muleHome == null && MuleLibraryKind.MULE_LIBRARY_KIND.equals(libraryEx.getKind())) {
            MuleLibraryProperties properties = (MuleLibraryProperties)libraryEx.getProperties();
            if (properties != null && properties.getState() != null) {
                muleHome = properties.getState().getMuleHome();
                break;
            }
        }
    }

    //Project myProject = module.getProject();
    //if (!MuleConfigUtils.isMuleProject(myProject)) {

    if (!hasFacet(module)) {
        MuleFacetType type = (MuleFacetType) FacetTypeRegistry.getInstance().findFacetType(MuleFacet.ID);
        MuleFacetConfiguration configuration = type.createDefaultConfiguration();
        if (muleHome != null)
            configuration.setPathToSdk(muleHome);
        Facet facet = type.createFacet(module, type.getPresentableName(), configuration, null);
        ModifiableFacetModel model = FacetManager.getInstance(module).createModifiableModel();
        model.addFacet(facet);
        model.commit();
    }
}
 
Example #7
Source File: HaxeProjectConfigurationUpdater.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Nullable
private Module getRootModule(ModifiableModelsProvider modelsProvider, ModulesProvider modulesProvider) {
  for(Module module:modulesProvider.getModules()) {
    ModifiableRootModel model = modelsProvider.getModuleModifiableModel(module);
    for(VirtualFile root:model.getContentRoots()) {
      if(root.getPath().equals(myProjectRoot)) {
        return module;
      }
    }
  }
  return null;
}