当前位置: 首页>>代码示例>>Java>>正文


Java ProjectManagerEx.openProject方法代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ThemeEditorVirtualFileTest.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:NewDummyProjectAction.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:81,代码来源:PlatformProjectOpenProcessor.java


注:本文中的com.intellij.openapi.project.ex.ProjectManagerEx.openProject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。