Java 类com.intellij.util.ui.ConfirmationDialog 实例源码

项目:intellij-ce-playground    文件:AbstractVcsHelperImpl.java   
@Nullable
public Collection<VirtualFile> selectFilesToProcess(final List<VirtualFile> files,
                                                    final String title,
                                                    @Nullable final String prompt,
                                                    final String singleFileTitle,
                                                    final String singleFilePromptTemplate,
                                                    final VcsShowConfirmationOption confirmationOption) {
  if (files == null || files.isEmpty()) {
    return null;
  }

  if (files.size() == 1 && singleFilePromptTemplate != null) {
    String filePrompt = MessageFormat.format(singleFilePromptTemplate, files.get(0).getPresentableUrl());
    if (ConfirmationDialog
      .requestForConfirmation(confirmationOption, myProject, filePrompt, singleFileTitle, Messages.getQuestionIcon())) {
      return files;
    }
    return null;
  }

  SelectFilesDialog dlg = SelectFilesDialog.init(myProject, files, prompt, confirmationOption, true, true, false);
  dlg.setTitle(title);
  if (!confirmationOption.isPersistent()) {
    dlg.setDoNotAskOption(null);
  }
  if (dlg.showAndGet()) {
    final Collection<VirtualFile> selection = dlg.getSelectedFiles();
    // return items in the same order as they were passed to us
    final List<VirtualFile> result = new ArrayList<VirtualFile>();
    for (VirtualFile file : files) {
      if (selection.contains(file)) {
        result.add(file);
      }
    }
    return result;
  }
  return null;
}
项目:tools-idea    文件:AbstractVcsHelperImpl.java   
@Nullable
public Collection<VirtualFile> selectFilesToProcess(final List<VirtualFile> files,
                                                    final String title,
                                                    @Nullable final String prompt,
                                                    final String singleFileTitle,
                                                    final String singleFilePromptTemplate,
                                                    final VcsShowConfirmationOption confirmationOption) {
  if (files == null || files.isEmpty()) {
    return null;
  }

  if (files.size() == 1 && singleFilePromptTemplate != null) {
    String filePrompt = MessageFormat.format(singleFilePromptTemplate, files.get(0).getPresentableUrl());
    if (ConfirmationDialog
      .requestForConfirmation(confirmationOption, myProject, filePrompt, singleFileTitle, Messages.getQuestionIcon())) {
      return files;
    }
    return null;
  }

  SelectFilesDialog dlg = SelectFilesDialog.init(myProject, files, prompt, confirmationOption, true, true, false);
  dlg.setTitle(title);
  if (! confirmationOption.isPersistent()) {
    dlg.setDoNotAskOption(null);
  }
  dlg.show();
  if (dlg.isOK()) {
    final Collection<VirtualFile> selection = dlg.getSelectedFiles();
    // return items in the same order as they were passed to us
    final List<VirtualFile> result = new ArrayList<VirtualFile>();
    for(VirtualFile file: files) {
      if (selection.contains(file)) {
        result.add(file);
      }
    }
    return result;
  }
  return null;
}
项目:tools-idea    文件:AbstractVcsHelperImpl.java   
@Nullable
public Collection<FilePath> selectFilePathsToProcess(List<FilePath> files,
                                                     String title,
                                                     @Nullable String prompt,
                                                     String singleFileTitle,
                                                     String singleFilePromptTemplate,
                                                     VcsShowConfirmationOption confirmationOption,
                                                     @Nullable String okActionName,
                                                     @Nullable String cancelActionName) {
  if (files.size() == 1 && singleFilePromptTemplate != null) {
    final String filePrompt = MessageFormat.format(singleFilePromptTemplate, files.get(0).getPresentableUrl());
    if (ConfirmationDialog.requestForConfirmation(confirmationOption, myProject, filePrompt, singleFileTitle,
                                                  Messages.getQuestionIcon(), okActionName, cancelActionName)) {
      return files;
    }
    return null;
  }

  final SelectFilePathsDialog dlg =
    new SelectFilePathsDialog(myProject, files, prompt, confirmationOption, okActionName, cancelActionName, true);
  dlg.setTitle(title);
  if (! confirmationOption.isPersistent()) {
    dlg.setDoNotAskOption(null);
  }
  dlg.show();
  return dlg.isOK() ? dlg.getSelectedFiles() : null;
}
项目:consulo    文件:AbstractVcsHelperImpl.java   
@Nullable
public Collection<VirtualFile> selectFilesToProcess(final List<VirtualFile> files,
                                                    final String title,
                                                    @Nullable final String prompt,
                                                    final String singleFileTitle,
                                                    final String singleFilePromptTemplate,
                                                    final VcsShowConfirmationOption confirmationOption) {
  if (files == null || files.isEmpty()) {
    return null;
  }

  if (files.size() == 1 && singleFilePromptTemplate != null) {
    String filePrompt = MessageFormat.format(singleFilePromptTemplate, files.get(0).getPresentableUrl());
    if (ConfirmationDialog
            .requestForConfirmation(confirmationOption, myProject, filePrompt, singleFileTitle, Messages.getQuestionIcon())) {
      return files;
    }
    return null;
  }

  SelectFilesDialog dlg = SelectFilesDialog.init(myProject, files, prompt, confirmationOption, true, true, false);
  dlg.setTitle(title);
  if (!confirmationOption.isPersistent()) {
    dlg.setDoNotAskOption(null);
  }
  if (dlg.showAndGet()) {
    final Collection<VirtualFile> selection = dlg.getSelectedFiles();
    // return items in the same order as they were passed to us
    final List<VirtualFile> result = new ArrayList<>();
    for (VirtualFile file : files) {
      if (selection.contains(file)) {
        result.add(file);
      }
    }
    return result;
  }
  return null;
}
项目:intellij-ce-playground    文件:CommitHelper.java   
public static void moveToFailedList(final ChangeList changeList,
                                    final String commitMessage,
                                    final List<Change> failedChanges,
                                    final String newChangelistName,
                                    final Project project) {
  // No need to move since we'll get exactly the same changelist.
  if (failedChanges.containsAll(changeList.getChanges())) return;

  final VcsConfiguration configuration = VcsConfiguration.getInstance(project);
  if (configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST != VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
    final VcsShowConfirmationOption option = new VcsShowConfirmationOption() {
      public Value getValue() {
        return configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST;
      }

      public void setValue(final Value value) {
        configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST = value;
      }

      @Override
      public boolean isPersistent() {
        return true;
      }
    };
    boolean result = ConfirmationDialog.requestForConfirmation(option, project, VcsBundle.message("commit.failed.confirm.prompt"),
                                                               VcsBundle.message("commit.failed.confirm.title"),
                                                               Messages.getQuestionIcon());
    if (!result) return;
  }

  final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
  int index = 1;
  String failedListName = newChangelistName;
  while (changeListManager.findChangeList(failedListName) != null) {
    index++;
    failedListName = newChangelistName + " (" + index + ")";
  }

  final LocalChangeList failedList = changeListManager.addChangeList(failedListName, commitMessage);
  changeListManager.moveChangesTo(failedList, failedChanges.toArray(new Change[failedChanges.size()]));
}
项目:tools-idea    文件:CommitHelper.java   
public static void moveToFailedList(final ChangeList changeList,
                                    final String commitMessage,
                                    final List<Change> failedChanges,
                                    final String newChangelistName,
                                    final Project project) {
  // No need to move since we'll get exactly the same changelist.
  if (failedChanges.containsAll(changeList.getChanges())) return;

  final VcsConfiguration configuration = VcsConfiguration.getInstance(project);
  if (configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST != VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
    final VcsShowConfirmationOption option = new VcsShowConfirmationOption() {
      public Value getValue() {
        return configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST;
      }

      public void setValue(final Value value) {
        configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST = value;
      }

      @Override
      public boolean isPersistent() {
        return true;
      }
    };
    boolean result = ConfirmationDialog.requestForConfirmation(option, project, VcsBundle.message("commit.failed.confirm.prompt"),
                                                               VcsBundle.message("commit.failed.confirm.title"),
                                                               Messages.getQuestionIcon());
    if (!result) return;
  }

  final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
  int index = 1;
  String failedListName = newChangelistName;
  while (changeListManager.findChangeList(failedListName) != null) {
    index++;
    failedListName = newChangelistName + " (" + index + ")";
  }

  final LocalChangeList failedList = changeListManager.addChangeList(failedListName, commitMessage);
  changeListManager.moveChangesTo(failedList, failedChanges.toArray(new Change[failedChanges.size()]));
}
项目:consulo    文件:CommitHelper.java   
public static void moveToFailedList(final ChangeList changeList,
                                    final String commitMessage,
                                    final List<Change> failedChanges,
                                    final String newChangelistName,
                                    final Project project) {
  // No need to move since we'll get exactly the same changelist.
  if (failedChanges.containsAll(changeList.getChanges())) return;

  final VcsConfiguration configuration = VcsConfiguration.getInstance(project);
  if (configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST != VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
    final VcsShowConfirmationOption option = new VcsShowConfirmationOption() {
      @Override
      public Value getValue() {
        return configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST;
      }

      @Override
      public void setValue(final Value value) {
        configuration.MOVE_TO_FAILED_COMMIT_CHANGELIST = value;
      }

      @Override
      public boolean isPersistent() {
        return true;
      }
    };
    boolean result = ConfirmationDialog
            .requestForConfirmation(option, project, VcsBundle.message("commit.failed.confirm.prompt"), VcsBundle.message("commit.failed.confirm.title"),
                                    Messages.getQuestionIcon());
    if (!result) return;
  }

  final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
  int index = 1;
  String failedListName = newChangelistName;
  while (changeListManager.findChangeList(failedListName) != null) {
    index++;
    failedListName = newChangelistName + " (" + index + ")";
  }

  final LocalChangeList failedList = changeListManager.addChangeList(failedListName, commitMessage);
  changeListManager.moveChangesTo(failedList, failedChanges.toArray(new Change[failedChanges.size()]));
}