use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class GenerateGroovyDocAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final Module module = LangDataKeys.MODULE.getData(dataContext);
if (module == null)
return;
GroovyDocConfiguration configuration = new GroovyDocConfiguration();
final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
if (files.length == 1) {
configuration.INPUT_DIRECTORY = files[0].getPath();
}
final GenerateGroovyDocDialog dialog = new GenerateGroovyDocDialog(project, configuration);
if (!dialog.showAndGet()) {
return;
}
generateGroovydoc(configuration, project);
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class GroovyCompilerConfigurable method createExcludedConfigurable.
private ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
final ExcludesConfiguration configuration = myConfig.getExcludeFromStubGeneration();
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return super.isFileVisible(file, showHiddenFiles) && !index.isExcluded(file);
}
};
descriptor.setRoots(ContainerUtil.concat(ContainerUtil.map(ModuleManager.getInstance(project).getModules(), new Function<Module, List<VirtualFile>>() {
@Override
public List<VirtualFile> fun(final Module module) {
return ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
}
})));
return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class ModuleChooserUtil method selectModule.
public static void selectModule(@NotNull Project project, final Collection<Module> suitableModules, final Function<Module, String> versionProvider, final Consumer<Module> callback, @Nullable DataContext context) {
final List<Module> modules = new ArrayList<>();
final Map<Module, String> versions = new HashMap<>();
for (Module module : suitableModules) {
modules.add(module);
versions.put(module, versionProvider.fun(module));
}
if (modules.size() == 1) {
callback.consume(modules.get(0));
return;
}
Collections.sort(modules, ModulesAlphaComparator.INSTANCE);
BaseListPopupStep<Module> step = new BaseListPopupStep<Module>("Which module to use classpath of?", modules, PlatformIcons.CONTENT_ROOT_ICON_CLOSED) {
@NotNull
@Override
public String getTextFor(Module value) {
return String.format("%s (%s)", value.getName(), versions.get(value));
}
@Override
public String getIndexedString(Module value) {
return value.getName();
}
@Override
public boolean isSpeedSearchEnabled() {
return true;
}
@Override
public PopupStep onChosen(Module selectedValue, boolean finalChoice) {
PropertiesComponent.getInstance(selectedValue.getProject()).setValue(GROOVY_LAST_MODULE, selectedValue.getName());
callback.consume(selectedValue);
return null;
}
};
final String lastModuleName = PropertiesComponent.getInstance(project).getValue(GROOVY_LAST_MODULE);
if (lastModuleName != null) {
int defaultOption = ContainerUtil.indexOf(modules, new Condition<Module>() {
@Override
public boolean value(Module module) {
return module.getName().equals(lastModuleName);
}
});
if (defaultOption >= 0) {
step.setDefaultOptionIndex(defaultOption);
}
}
final ListPopup listPopup = JBPopupFactory.getInstance().createListPopup(step);
if (context == null) {
listPopup.showCenteredInCurrentWindow(project);
} else {
listPopup.showInBestPositionFor(context);
}
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class MavenExternalParameters method dumpModulesPaths.
private static File dumpModulesPaths(@NotNull Project project) throws IOException {
ApplicationManager.getApplication().assertReadAccessAllowed();
Properties res = new Properties();
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
for (Module module : ModuleManager.getInstance(project).getModules()) {
if (manager.isMavenizedModule(module)) {
MavenProject mavenProject = manager.findProject(module);
if (mavenProject != null && !manager.isIgnored(mavenProject)) {
res.setProperty(mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId() + ":pom" + ':' + mavenProject.getMavenId().getVersion(), mavenProject.getFile().getPath());
res.setProperty(mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId() + ':' + mavenProject.getPackaging() + ':' + mavenProject.getMavenId().getVersion(), mavenProject.getOutputDirectory());
res.setProperty(mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId() + ":test-jar" + ':' + mavenProject.getMavenId().getVersion(), mavenProject.getTestOutputDirectory());
addArtifactFileMapping(res, mavenProject, "sources");
addArtifactFileMapping(res, mavenProject, "test-sources");
addArtifactFileMapping(res, mavenProject, "javadoc");
addArtifactFileMapping(res, mavenProject, "test-javadoc");
}
}
}
File file = new File(PathManager.getSystemPath(), "Maven/idea-projects-state-" + project.getLocationHash() + ".properties");
FileUtil.ensureExists(file.getParentFile());
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
try {
res.store(out, null);
} finally {
out.close();
}
return file;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class MavenExternalParameters method getJdk.
@NotNull
private static Sdk getJdk(@Nullable Project project, MavenRunnerSettings runnerSettings, boolean isGlobalRunnerSettings) throws ExecutionException {
String name = runnerSettings.getJreName();
if (name.equals(MavenRunnerSettings.USE_INTERNAL_JAVA)) {
return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
}
if (name.equals(MavenRunnerSettings.USE_PROJECT_JDK)) {
if (project != null) {
Sdk res = ProjectRootManager.getInstance(project).getProjectSdk();
if (res != null) {
return res;
}
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) {
return sdk;
}
}
}
if (project == null) {
Sdk recent = ProjectJdkTable.getInstance().findMostRecentSdkOfType(JavaSdk.getInstance());
if (recent != null)
return recent;
return JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
}
throw new ProjectJdkSettingsOpenerExecutionException("Project JDK is not specified. <a href=''>Configure</a>", project);
}
if (name.equals(MavenRunnerSettings.USE_JAVA_HOME)) {
final String javaHome = System.getenv("JAVA_HOME");
if (StringUtil.isEmptyOrSpaces(javaHome)) {
throw new ExecutionException(RunnerBundle.message("maven.java.home.undefined"));
}
final Sdk jdk = JavaSdk.getInstance().createJdk("", javaHome);
if (jdk == null) {
throw new ExecutionException(RunnerBundle.message("maven.java.home.invalid", javaHome));
}
return jdk;
}
for (Sdk projectJdk : ProjectJdkTable.getInstance().getAllJdks()) {
if (projectJdk.getName().equals(name)) {
return projectJdk;
}
}
if (isGlobalRunnerSettings) {
throw new ExecutionException(RunnerBundle.message("maven.java.not.found.default.config", name));
} else {
throw new ExecutionException(RunnerBundle.message("maven.java.not.found", name));
}
}
Aggregations