本文整理汇总了Java中com.intellij.openapi.project.ex.ProjectManagerEx.openProject方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectManagerEx.openProject方法的具体用法?Java ProjectManagerEx.openProject怎么用?Java ProjectManagerEx.openProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.project.ex.ProjectManagerEx
的用法示例。
在下文中一共展示了ProjectManagerEx.openProject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRightProject
import com.intellij.openapi.project.ex.ProjectManagerEx; //导入方法依赖的package包/类
/**
* Tests that the theme editor works with the right virtual file
* when there are several projects with the same name open.
*/
public void testRightProject() throws IOException {
ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
Project otherProject = projectManager.newProject(getProject().getName(), FileUtilRt.generateRandomTemporaryPath().getPath(), true, true);
try {
assertNotNull(otherProject);
projectManager.openProject(otherProject);
ThemeEditorVirtualFile themeEditorVirtualFile = ThemeEditorVirtualFile.getThemeEditorFile(myModule.getProject());
VirtualFile virtualFile = themeEditorVirtualFile.getFileSystem().findFileByPath(themeEditorVirtualFile.getPath());
assertEquals(themeEditorVirtualFile, virtualFile);
}
finally {
if (otherProject != null) {
((ProjectManagerImpl)projectManager).closeProject(otherProject, false, true, false);
}
}
}
示例2: actionPerformed
import com.intellij.openapi.project.ex.ProjectManagerEx; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
final ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
Project project = projectManager.newProject("dummy", PathManager.getConfigPath() + "/dummy.ipr", true, false);
if (project == null) return;
projectManager.openProject(project);
}
示例3: doOpenProject
import com.intellij.openapi.project.ex.ProjectManagerEx; //导入方法依赖的package包/类
@Nullable
public static Project doOpenProject(@Nonnull final VirtualFile virtualFile, Project projectToClose, final boolean forceOpenInNewFrame, final int line, @Nullable Consumer<Project> callback) {
VirtualFile baseDir = virtualFile;
if (!baseDir.isDirectory()) {
baseDir = virtualFile.getParent();
while (baseDir != null) {
if (new File(FileUtil.toSystemDependentName(baseDir.getPath()), Project.DIRECTORY_STORE_FOLDER).exists()) {
break;
}
baseDir = baseDir.getParent();
}
if (baseDir == null) {
baseDir = virtualFile.getParent();
}
}
final File projectDir = new File(FileUtil.toSystemDependentName(baseDir.getPath()), Project.DIRECTORY_STORE_FOLDER);
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (!forceOpenInNewFrame && openProjects.length > 0) {
if (projectToClose == null) {
projectToClose = openProjects[openProjects.length - 1];
}
int exitCode = ProjectUtil.confirmOpenNewProject(false);
if (exitCode == GeneralSettings.OPEN_PROJECT_SAME_WINDOW) {
if (!ProjectUtil.closeAndDispose(projectToClose)) return null;
}
else if (exitCode != GeneralSettings.OPEN_PROJECT_NEW_WINDOW) { // not in a new window
return null;
}
}
boolean runConfigurators = true;
final ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
Project project = null;
if (projectDir.exists()) {
try {
for (ProjectOpenProcessor processor : ProjectOpenProcessors.getInstance().getProcessors()) {
processor.refreshProjectFiles(projectDir);
}
project = projectManager.convertAndLoadProject(baseDir.getPath());
if (project == null) {
WelcomeFrame.showIfNoProjectOpened();
return null;
}
final Module[] modules = ModuleManager.getInstance(project).getModules();
if (modules.length > 0) {
runConfigurators = false;
}
}
catch (Exception e) {
LOGGER.error(e);
}
}
else {
projectDir.mkdirs();
}
if (project == null) {
project = projectManager.newProject(projectDir.getParentFile().getName(), projectDir.getParent(), true, false);
}
if (project == null) return null;
openProjectToolWindow(project);
openFileFromCommandLine(project, virtualFile, line);
if (!projectManager.openProject(project)) {
WelcomeFrame.showIfNoProjectOpened();
final Project finalProject = project;
ApplicationManager.getApplication().runWriteAction(() -> Disposer.dispose(finalProject));
return project;
}
if (callback != null && runConfigurators) {
callback.consume(project);
}
return project;
}