Java Code Examples for com.intellij.openapi.module.Module#getProject()

The following examples show how to use com.intellij.openapi.module.Module#getProject() . 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: MavenToolDelegate.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();
    VirtualFile pomFile = null;
    VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
    for(VirtualFile contentRoot : contentRoots) {
        VirtualFile child = contentRoot.findChild("pom.xml");
        if (child != null) {
            pomFile = child;
            break;
        }
    }

    if (pomFile != null) {
        MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(project);
        mavenProjectsManager.addManagedFiles(Collections.singletonList(pomFile));
    }
}
 
Example 2
Source File: GradleModuleBuilderPostProcessor.java    From intellij-spring-assistant with MIT License 6 votes vote down vote up
@Override
public boolean postProcess(Module module) {
  // TODO: Find a way to use GradleModuleBuilder instead of GradleProjectImportBuilder when adding a child module to the parent
  Project project = module.getProject();
  VirtualFile gradleFile = findFileUnderRootInModule(module, "build.gradle");
  if (gradleFile == null) { // not a gradle project
    return true;
  } else {
    ProjectDataManager projectDataManager = getService(ProjectDataManager.class);
    GradleProjectImportBuilder importBuilder = new GradleProjectImportBuilder(projectDataManager);
    GradleProjectImportProvider importProvider = new GradleProjectImportProvider(importBuilder);
    AddModuleWizard addModuleWizard =
        new AddModuleWizard(project, gradleFile.getPath(), importProvider);
    if (addModuleWizard.getStepCount() > 0 && !addModuleWizard
        .showAndGet()) { // user has cancelled import project prompt
      return true;
    } else { // user chose to import via the gradle import prompt
      importBuilder.commit(project, null, null);
      return false;
    }
  }
}
 
Example 3
Source File: BlazeCreateResourceFileDialog.java    From intellij with Apache License 2.0 6 votes vote down vote up
private void updateRootElementTextField() {
  final CreateTypedResourceFileAction action = getSelectedAction(myResourceTypeCombo);

  if (action != null) {
    final Module module = myFacet.getModule();
    final List<String> allowedTagNames = action.getSortedAllowedTagNames(myFacet);
    myRootElementField =
        new TextFieldWithAutoCompletion<>(
            module.getProject(),
            new StringsCompletionProvider(allowedTagNames, null),
            true,
            null);
    myRootElementField.setEnabled(allowedTagNames.size() > 1);
    myRootElementField.setText(action.isChooseTagName() ? "" : action.getDefaultRootTag(module));
    myRootElementFieldWrapper.removeAll();
    myRootElementFieldWrapper.add(myRootElementField, BorderLayout.CENTER);
    myRootElementLabel.setLabelFor(myRootElementField);
  }
}
 
Example 4
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 5
Source File: AnalyzeDependenciesDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * The constructor
 *
 * @param module the dialog that allows analyzing dependencies
 */
protected AnalyzeDependenciesDialog(Module module) {
  super(module.getProject(), true);
  setTitle("Analyze Dependencies for " + module.getName());
  setModal(false);
  myComponent = new AnalyzeDependenciesComponent(module);
  Disposer.register(myDisposable, new Disposable() {
    @Override
    public void dispose() {
      myComponent.disposeUIResources();
    }
  });
  setOKButtonText("Close");
  init();
}
 
Example 6
Source File: ModuleCompileScope.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ModuleCompileScope(final Module module, boolean includeDependentModules) {
  myProject = module.getProject();
  myScopeModules = new HashSet<Module>();
  if (includeDependentModules) {
    buildScopeModulesSet(module);
  }
  else {
    myScopeModules.add(module);
  }
  myModules = ModuleManager.getInstance(myProject).getModules();
}
 
Example 7
Source File: SourceScope.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ModuleWithDependenciesAndLibsDependencies(final Module module) {
  super(module.getProject());
  myMainScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
  final Map<Module, Collection<Module>> map = buildAllDependencies(module.getProject());
  if (map == null) return;
  final Collection<Module> modules = map.get(module);
  for (final Module dependency : modules) {
    myScopes.add(GlobalSearchScope.moduleWithLibrariesScope(dependency));
  }
}
 
Example 8
Source File: HaxeCompiler.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public static HaxeCommonCompilerUtil.CompilationContext createDummyCompilationContext(final Module module) {
  DummyCompileContext context = new DummyCompileContext() {
    @Override
    public Project getProject() {
      return module.getProject();
    }
  };
  return createCompilationContext(context, module, null);
}
 
Example 9
Source File: RailwaysSettingsDialog.java    From railways with MIT License 5 votes vote down vote up
protected RailwaysSettingsDialog(@NotNull Module module) {
    super(module.getProject());

    setTitle("Configure Railways - module '" + module.getName() + "'");

    // Create panel and reset components
    myPanel = new RailwaysSettingsForm(module);
    myPanel.reset();

    // Important to call inherited init() method.
    init();
}
 
Example 10
Source File: BlazeAndroidRunConfigurationValidationUtil.java    From intellij with Apache License 2.0 5 votes vote down vote up
public static List<ValidationError> validateModule(@Nullable Module module) {
  List<ValidationError> errors = Lists.newArrayList();
  if (module == null) {
    errors.add(
        ValidationError.fatal(
            "No run configuration module found. Have you successfully synced your project?"));
    return errors;
  }
  final Project project = module.getProject();
  if (AndroidProjectInfo.getInstance(project).requiredAndroidModelMissing()) {
    errors.add(ValidationError.fatal(SYNC_FAILED_ERR_MSG));
  }
  return errors;
}
 
Example 11
Source File: BlazeModuleSystem.java    From intellij with Apache License 2.0 5 votes vote down vote up
BlazeModuleSystem(Module module) {
  this.module = module;
  this.project = module.getProject();
  classFileFinder = BlazeClassFileFinderFactory.createBlazeClassFileFinder(module);
  sampleDataDirectoryProvider = new BlazeSampleDataDirectoryProvider(module);
  isWorkspaceModule = BlazeDataStorage.WORKSPACE_MODULE_NAME.equals(module.getName());
}
 
Example 12
Source File: MavenModuleBuilderPostProcessor.java    From intellij-spring-assistant with MIT License 5 votes vote down vote up
@Override
public boolean postProcess(Module module) {
  // TODO: Find a way to use GradleModuleBuilder instead of GradleProjectImportBuilder when adding a child module to the parent
  Project project = module.getProject();
  VirtualFile pomFile = findFileUnderRootInModule(module, "pom.xml");
  if (pomFile == null) { // not a maven project
    return true;
  } else {
    MavenProjectsManager mavenProjectsManager = getInstance(project);
    mavenProjectsManager.addManagedFiles(singletonList(pomFile));
    return false;
  }
}
 
Example 13
Source File: BlazeCreateXmlResourcePanel.java    From intellij with Apache License 2.0 4 votes vote down vote up
public BlazeCreateXmlResourcePanel(
    Module module,
    ResourceType resourceType,
    ResourceFolderType folderType,
    @Nullable String resourceName,
    @Nullable String resourceValue,
    boolean chooseName,
    boolean chooseValue,
    boolean chooseFilename,
    @Nullable VirtualFile defaultFile,
    @Nullable VirtualFile contextFile,
    Function<Module, IdeResourceNameValidator> nameValidatorFactory) {
  setupUi();
  setChangeNameVisible(false);
  setChangeValueVisible(false);
  setChangeFileNameVisible(chooseFilename);
  myModule = module;
  myContextFile = contextFile;
  if (chooseName) {
    setChangeNameVisible(true);
  }
  if (!StringUtil.isEmpty(resourceName)) {
    myNameField.setText(resourceName);
  }

  if (chooseValue) {
    setChangeValueVisible(true);
    if (!StringUtil.isEmpty(resourceValue)) {
      myValueField.setText(resourceValue);
    }
  }

  myResourceType = resourceType;

  ApplicationManager.getApplication().assertReadAccessAllowed();
  // Set up UI to choose the base directory if needed (use context to prune selection).
  myResDirLabel.setVisible(false);
  myResDirCombo.setVisible(false);
  myResDirCombo.addBrowseFolderListener(
      module.getProject(), FileChooserDescriptorFactory.createSingleFolderDescriptor());
  setupResourceDirectoryCombo();

  if (defaultFile == null) {
    final String defaultFileName =
        AndroidResourceUtilCompat.getDefaultResourceFileName(myResourceType);

    if (defaultFileName != null) {
      myFileNameCombo.getEditor().setItem(defaultFileName);
    }
  }

  myDirectoriesLabel.setLabelFor(myDirectoriesPanel);
  mySubdirPanel =
      new CreateXmlResourceSubdirPanel(module.getProject(), folderType, myDirectoriesPanel, this);
  myResourceNameValidator = nameValidatorFactory.apply(getModule());

  if (defaultFile != null) {
    resetFromFile(defaultFile, module.getProject());
  }
}
 
Example 14
Source File: PsiBasedClassFileFinder.java    From intellij with Apache License 2.0 4 votes vote down vote up
public PsiBasedClassFileFinder(Module module) {
  this.module = module;
  project = module.getProject();
}
 
Example 15
Source File: PackageNodeUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ModuleLibrariesSearchScope(@Nonnull Module module) {
  super(module.getProject());
  myModule = module;
}
 
Example 16
Source File: LibrariesContainerFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static LibrariesContainer createContainer(@Nonnull Module module) {
  return new LibrariesContainerImpl(module.getProject(), module, null);
}
 
Example 17
Source File: LibrariesContainerFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static LibrariesContainer createContainer(@Nonnull ModifiableRootModel rootModel) {
  Module module = rootModel.getModule();
  return new LibrariesContainerImpl(module.getProject(), module, rootModel);
}
 
Example 18
Source File: ModuleNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ModuleNode(Module module) {
  super(module.getProject());
  myModule = module;
}
 
Example 19
Source File: ModuleStructurePane.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ModuleStructurePane(Module module) {
  super(module.getProject());
  myModule = module;
}
 
Example 20
Source File: FileRecursiveIterator.java    From consulo with Apache License 2.0 4 votes vote down vote up
FileRecursiveIterator(@Nonnull Module module) {
  this(module.getProject(), ContainerUtil.<PsiDirectory, VirtualFile>map(collectModuleDirectories(module), psiDir -> psiDir.getVirtualFile()));
}