Java Code Examples for com.intellij.ide.impl.ProjectUtil#openAsync()

The following examples show how to use com.intellij.ide.impl.ProjectUtil#openAsync() . 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: ReopenProjectAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  //Force move focus to IdeFrame
  IdeEventQueue.getInstance().getPopupManager().closeAllPopups();

  final int modifiers = e.getModifiers();
  final boolean forceOpenInNewFrame = BitUtil.isSet(modifiers, InputEvent.CTRL_MASK) || BitUtil.isSet(modifiers, InputEvent.SHIFT_MASK) || e.getPlace() == ActionPlaces.WELCOME_SCREEN;

  Project project = e.getData(CommonDataKeys.PROJECT);
  if (!new File(myProjectPath).exists()) {
    if (Messages.showDialog(project, "The path " +
                                     FileUtil.toSystemDependentName(myProjectPath) +
                                     " does not exist.\n" +
                                     "If it is on a removable or network drive, please make sure that the drive is connected.", "Reopen Project", new String[]{"OK", "&Remove From List"}, 0,
                            Messages.getErrorIcon()) == 1) {
      myIsRemoved = true;
      RecentProjectsManager.getInstance().removePath(myProjectPath);
    }
    return;
  }

  ProjectUtil.openAsync(myProjectPath, project, forceOpenInNewFrame, UIAccess.current());
}
 
Example 2
Source File: RecentProjectsManagerBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void doReopenLastProject() {
  GeneralSettings generalSettings = GeneralSettings.getInstance();
  if (generalSettings.isReopenLastProject()) {
    Set<String> openPaths;
    boolean forceNewFrame = true;
    synchronized (myStateLock) {
      openPaths = ContainerUtil.newLinkedHashSet(myState.openPaths);
      if (openPaths.isEmpty()) {
        openPaths = ContainerUtil.createMaybeSingletonSet(myState.lastPath);
        forceNewFrame = false;
      }
    }

    for (String openPath : openPaths) {
      if (isValidProjectPath(openPath)) {
        ProjectUtil.openAsync(openPath, null, forceNewFrame, UIAccess.current());
      }
    }
  }
}
 
Example 3
Source File: ProjectImporterCheckoutListener.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean processCheckedOutDirectory(Project project, File directory) {
  final File[] files = directory.listFiles();
  if (files != null) {
    final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
    for (File file : files) {
      if (file.isDirectory()) continue;
      final VirtualFile virtualFile = localFileSystem.findFileByIoFile(file);
      if (virtualFile != null) {
        final ProjectOpenProcessor openProcessor = ProjectOpenProcessors.getInstance().findProcessor(file);
        if (openProcessor != null) {
          int rc = Messages.showYesNoDialog(project, VcsBundle .message("checkout.open.project.prompt", files[0].getPath()),
                                            VcsBundle.message("checkout.title"), Messages.getQuestionIcon());
          if (rc == Messages.YES) {
            ProjectUtil.openAsync(virtualFile.getPath(), project, false, UIAccess.current());
          }
          return true;
        }
      }
    }
  }
  return false;
}