本文整理汇总了Java中com.intellij.openapi.project.ProjectManager.getOpenProjects方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectManager.getOpenProjects方法的具体用法?Java ProjectManager.getOpenProjects怎么用?Java ProjectManager.getOpenProjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.project.ProjectManager
的用法示例。
在下文中一共展示了ProjectManager.getOpenProjects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findProject
import com.intellij.openapi.project.ProjectManager; //导入方法依赖的package包/类
@Nullable
public Project findProject() {
final ProjectManager projectManager = ProjectManager.getInstance();
for (Project project : projectManager.getOpenProjects()) {
if (myProjectId.equals(getProjectId(project))) return project;
}
return null;
}
示例2: findProject
import com.intellij.openapi.project.ProjectManager; //导入方法依赖的package包/类
@NotNull
private static Project findProject(@NotNull IntegrationKey key) {
final ProjectManager projectManager = ProjectManager.getInstance();
for (Project project : projectManager.getOpenProjects()) {
if (key.getIdeProjectName().equals(project.getName()) && key.getIdeProjectLocationHash().equals(project.getLocationHash())) {
return project;
}
}
return projectManager.getDefaultProject();
}
示例3: guessProjectForFile
import com.intellij.openapi.project.ProjectManager; //导入方法依赖的package包/类
@Nullable
public Project guessProjectForFile(final VirtualFile file) {
ProjectManager projectManager = ProjectManager.getInstance();
if (projectManager == null) return null;
final Project[] projects = projectManager.getOpenProjects();
if (projects.length == 1) {
return !projects[0].isDisposed() ? projects[0] : null;
}
else {
return null;
}
}
示例4: getProjectsForFile
import com.intellij.openapi.project.ProjectManager; //导入方法依赖的package包/类
@NotNull
@Override
public Collection<Project> getProjectsForFile(VirtualFile file) {
final ProjectManager projectManager = ProjectManager.getInstance();
if (projectManager == null || file == null) { return new HashSet<Project>(); }
final Project[] openProjects = projectManager.getOpenProjects();
return Arrays.asList(openProjects);
}
示例5: findAnyGradleHome
import com.intellij.openapi.project.ProjectManager; //导入方法依赖的package包/类
@Nullable
public static File findAnyGradleHome(boolean interactive) {
// Try cheapest option first:
String lastUsedGradleHome = getLastUsedGradleHome();
if (!lastUsedGradleHome.isEmpty()) {
File path = new File(lastUsedGradleHome);
if (isValidGradleHome(path)) {
return path;
}
}
ProjectManager projectManager = ProjectManager.getInstance();
for (Project project : projectManager.getOpenProjects()) {
File gradleHome = findGradleHome(project);
if (gradleHome != null) {
return gradleHome;
}
}
if (interactive) {
ChooseGradleHomeDialog chooseGradleHomeDialog = new ChooseGradleHomeDialog();
chooseGradleHomeDialog.setTitle("Choose Gradle Installation");
String description = "A Gradle installation is necessary to stop all daemons.\n" +
"Please select the home directory of a Gradle installation, otherwise the project won't be closed.";
chooseGradleHomeDialog.setDescription(description);
if (!chooseGradleHomeDialog.showAndGet()) {
return null;
}
String enteredPath = chooseGradleHomeDialog.getEnteredGradleHomePath();
File gradleHomePath = new File(enteredPath);
if (isValidGradleHome(gradleHomePath)) {
chooseGradleHomeDialog.storeLastUsedGradleHomePath();
return gradleHomePath;
}
}
return null;
}
示例6: noProjectsAreOpen
import com.intellij.openapi.project.ProjectManager; //导入方法依赖的package包/类
private boolean noProjectsAreOpen() {
logger.info("Checking that at least one project is open.");
ProjectManager projectManager = ProjectManager.getInstance();
Project[] openProjects = projectManager.getOpenProjects();
return openProjects.length == 0;
}