com.intellij.openapi.roots.ui.configuration.ModulesProvider Java Examples

The following examples show how to use com.intellij.openapi.roots.ui.configuration.ModulesProvider. 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: GradleToolDelegate.java    From intellij-quarkus with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void processImport(Module module) {
    Project project = module.getProject();
    File gradleFile = null;

    for(VirtualFile virtualFile : ModuleRootManager.getInstance(module).getContentRoots()) {
        File baseDir = VfsUtilCore.virtualToIoFile(virtualFile);
        File file = new File(baseDir, "build.gradle");
        if (file.exists()) {
            gradleFile = file;
            break;
        }
    }

    if (gradleFile != null) {
        ProjectImportProvider gradleProjectImportProvider = getGradleProjectImportProvider();
        ProjectImportBuilder gradleProjectImportBuilder = gradleProjectImportProvider.getBuilder();
        AddModuleWizard wizard = new AddModuleWizard(project, gradleFile.getPath(), new ProjectImportProvider[]{gradleProjectImportProvider});
        if (wizard.getStepCount() == 0 || wizard.showAndGet()) {
            gradleProjectImportBuilder.commit(project, (ModifiableModuleModel)null, (ModulesProvider)null);
        }
    }
}
 
Example #2
Source File: LibraryPackagingElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
@javax.annotation.Nullable
public Library findLibrary(@Nonnull PackagingElementResolvingContext context) {
  if (myModuleName == null) {
    return context.findLibrary(myLevel, myLibraryName);
  }
  final ModulesProvider modulesProvider = context.getModulesProvider();
  final Module module = modulesProvider.getModule(myModuleName);
  if (module != null) {
    for (OrderEntry entry : modulesProvider.getRootModel(module).getOrderEntries()) {
      if (entry instanceof LibraryOrderEntry) {
        final LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entry;
        if (libraryEntry.isModuleLevel()) {
          final String libraryName = libraryEntry.getLibraryName();
          if (libraryName != null && libraryName.equals(myLibraryName)) {
            return libraryEntry.getLibrary();
          }
        }
      }
    }
  }
  return null;
}
 
Example #3
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 #4
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 #5
Source File: PantsOpenProjectProvider.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
private void link(@NotNull VirtualFile projectFile, @NotNull Project project, AddModuleWizard dialog) {
  if (dialog == null) return;

  ProjectBuilder builder = dialog.getBuilder(project);
  if (builder == null) return;

  try {
    ApplicationManager.getApplication().runWriteAction(() -> {
      Optional.ofNullable(dialog.getNewProjectJdk())
        .ifPresent(jdk -> NewProjectUtil.applyJdkToProject(project, jdk));

      URI output = projectDir(projectFile).resolve(".out").toUri();
      Optional.ofNullable(CompilerProjectExtension.getInstance(project))
        .ifPresent(ext -> ext.setCompilerOutputUrl(output.toString()));
    });

    builder.commit(project, null, ModulesProvider.EMPTY_MODULES_PROVIDER);
    project.putUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT, Boolean.TRUE);

    project.save();
  }
  finally {
    builder.cleanup();
  }
}
 
Example #6
Source File: RoboVmModuleBuilder.java    From robovm-idea with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModulesProvider modulesProvider) {
    RoboVmModuleWizardStep wizardStep = new RoboVmModuleWizardStep(this, wizardContext, modulesProvider);

    if (!robovmDir.isEmpty()) {
        wizardStep.disableBuildSystem();
        buildSystem = BuildSystem.Gradle;
    }

    if (!robovmDir.isEmpty() && !RoboVmPlugin.isAndroidSdkSetup()) {
        RoboVmAndroidModuleWizardStep androidStep = new RoboVmAndroidModuleWizardStep(this, wizardContext,
                modulesProvider);
        return new ModuleWizardStep[] { androidStep, wizardStep };
    } else {
        return new ModuleWizardStep[] { wizardStep };
    }
}
 
Example #7
Source File: CppModuleType.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, CppModuleBuilder cppModuleBuilder, ModulesProvider modulesProvider) {
  final List<Sdk> list = CppSdkType.getInstance().getCppSdks();
  final ModuleWizardStep sourceModuleWizardStep = ProjectWizardStepFactory.getInstance().createSourcePathsStep(wizardContext, cppModuleBuilder, null, null);
  final ModuleWizardStep createSampleCode = new CreateEntryCodeStep(cppModuleBuilder);

  if (list.size() == 0) {
    return new ModuleWizardStep[] { new ChooseCppSdkStep(cppModuleBuilder, wizardContext),sourceModuleWizardStep, createSampleCode };
  }
  return new ModuleWizardStep[] { sourceModuleWizardStep, createSampleCode };
}
 
Example #8
Source File: SpringBootModuleBuilder.java    From crud-intellij-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
	SelectionContext.clearAllSet();
	CrudTableStep tableStep = new CrudTableStep(new CrudTableView());
	CrudDbStep dbStep = new CrudDbStep(new CrudDbView(), tableStep);
	CrudConnStep connStep = new CrudConnStep(new CrudConnView(), dbStep);
	return new ModuleWizardStep[]{
			connStep,
			dbStep,
			tableStep,
			new CrudProjectInfoStep()
	};
}
 
Example #9
Source File: ModuleUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean hasModuleExtension(@Nonnull ModulesProvider modulesProvider, @Nonnull Class<? extends ModuleExtension> clazz) {
  for (Module module : modulesProvider.getModules()) {
    ModuleRootModel rootModel = modulesProvider.getRootModel(module);
    if (rootModel == null) {
      continue;
    }

    ModuleExtension extension = rootModel.getExtension(clazz);
    if (extension != null) {
      return true;
    }
  }
  return false;
}
 
Example #10
Source File: ModuleOutputPackagingElementImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@javax.annotation.Nullable
public Module findModule(PackagingElementResolvingContext context) {
  final Module module = NamedPointerUtil.get(myModulePointer);
  final ModulesProvider modulesProvider = context.getModulesProvider();
  if (module != null) {
    if (modulesProvider instanceof DefaultModulesProvider//optimization
        || ArrayUtil.contains(module, modulesProvider.getModules())) {
      return module;
    }
  }
  return modulesProvider.getModule(myModulePointer.getName());
}
 
Example #11
Source File: ModuleOutputElementTypeBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
private List<Module> getSuitableModules(ArtifactEditorContext context) {
  ModulesProvider modulesProvider = context.getModulesProvider();
  ArrayList<Module> modules = new ArrayList<Module>();
  for (Module module : modulesProvider.getModules()) {
    if (isSuitableModule(modulesProvider, module)) {
      modules.add(module);
    }
  }
  return modules;
}
 
Example #12
Source File: ModuleOutputElementTypeBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public boolean isSuitableModule(ModulesProvider modulesProvider, Module module) {
  for (ContentEntry entry : modulesProvider.getRootModel(module).getContentEntries()) {
    if (entry.getFolders(Predicates.equalTo(myContentFolderTypeProvider)).length != 0) {
      return true;
    }
  }
  return false;
}
 
Example #13
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;
}
 
Example #14
Source File: HaxeModuleType.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public ModuleWizardStep[] createWizardSteps(final WizardContext wizardContext,
                                            final HaxeModuleBuilder moduleBuilder,
                                            final ModulesProvider modulesProvider) {
  HaxeSdkType type = HaxeSdkType.getInstance();
  type.ensureSdk();

  return new ModuleWizardStep[]{
    new HaxeSdkWizardStep(moduleBuilder, wizardContext, type)
  };
}
 
Example #15
Source File: DemoModuleWizardStep.java    From intellij-sdk-docs with Apache License 2.0 5 votes vote down vote up
@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext,
                                            @NotNull ModulesProvider modulesProvider) {
  return new ModuleWizardStep[]{new ModuleWizardStep() {
    @Override
    public JComponent getComponent() {
      return new JLabel("Put your content here");
    }

    @Override
    public void updateDataModel() {

    }
  }};
}
 
Example #16
Source File: DemoModuleType.java    From intellij-sdk-docs with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext,
                                            @NotNull DemoModuleBuilder moduleBuilder,
                                            @NotNull ModulesProvider modulesProvider) {
  return super.createWizardSteps(wizardContext, moduleBuilder, modulesProvider);
}
 
Example #17
Source File: SlingMavenModuleBuilder.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
    // It is not possible with IntelliJ to use the same Form with another class AFAIK
    // The original Select Properties Step is replaced by our own as we need to handle additional Properties from
    // archetype (required properties) and provide a Name field for convenience.
    return new ModuleWizardStep[]{
        new MavenModuleWizardStep(this, wizardContext, !wizardContext.isNewWizard()),
        new ArchetypePropertiesStep(wizardContext.getProject(), this)
    };
}
 
Example #18
Source File: BlazeProjectImportBuilder.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public List<Module> commit(
    Project project,
    @Nullable ModifiableModuleModel modifiableModuleModel,
    ModulesProvider modulesProvider) {
  builder.commitToProject(project);
  return ImmutableList.of();
}
 
Example #19
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 #20
Source File: ArtifactsTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public ModulesProvider getModulesProvider() {
  return new DefaultModulesProvider(myProject);
}
 
Example #21
Source File: QuarkusModuleBuilder.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
    return new ModuleWizardStep[]{new QuarkusModuleInfoStep(wizardContext), new QuarkusExtensionsStep(wizardContext)};
}
 
Example #22
Source File: SandArtifactType.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isAvailableForAdd(@Nonnull ModulesProvider modulesProvider) {
  return ModuleUtil.hasModuleExtension(modulesProvider, SandModuleExtension.class);
}
 
Example #23
Source File: ArtifactsStructureConfigurableContextImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public ModulesProvider getModulesProvider() {
  return myContext.getModulesConfigurator();
}
 
Example #24
Source File: ArtifactEditorContextImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public ModulesProvider getModulesProvider() {
  return myParent.getModulesProvider();
}
 
Example #25
Source File: ModuleConfigurationStateImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public ModulesProvider getModulesProvider() {
  return myProvider;
}
 
Example #26
Source File: ModuleConfigurationStateImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ModuleConfigurationStateImpl(@Nonnull Project project, @Nonnull ModulesProvider provider) {
  myProvider = provider;
  myProject = project;
}
 
Example #27
Source File: QuarkusModuleBuilder.java    From intellij-quarkus with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ModuleWizardStep[] createFinishingSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
    this.wizardContext = wizardContext;
    return super.createFinishingSteps(wizardContext, modulesProvider);
}
 
Example #28
Source File: DefaultPackagingElementResolvingContext.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public ModulesProvider getModulesProvider() {
  return myModulesProvider;
}
 
Example #29
Source File: DubboPluginModuleBuilder.java    From intellij-idea-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
    return new ModuleWizardStep[]{
            new DubboModuleWizardStep(this, wizardContext, !wizardContext.isNewWizard())
    };
}
 
Example #30
Source File: InitializrModuleBuilder.java    From intellij-spring-assistant with MIT License 4 votes vote down vote up
public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext,
    @NotNull ModulesProvider modulesProvider) {
  return new ModuleWizardStep[] {new ProjectDetailsStep(this, wizardContext),
      new DependencySelectionStep(this)};
}