コード例 #1
0
  private DeleteRemoteBranchDecision confirmBranchDeletion(
      @NotNull String branchName,
      @NotNull Collection<String> trackingBranches,
      boolean currentBranchTracksBranchToDelete,
      @NotNull Collection<GitRepository> repositories) {
    String title = "Delete Remote Branch";
    String message = "Delete remote branch " + branchName;

    boolean delete;
    final boolean deleteTracking;
    if (trackingBranches.isEmpty()) {
      delete =
          Messages.showYesNoDialog(
                  myProject, message, title, "Delete", "Cancel", Messages.getQuestionIcon())
              == Messages.YES;
      deleteTracking = false;
    } else {
      if (currentBranchTracksBranchToDelete) {
        message +=
            "\n\nCurrent branch "
                + GitBranchUtil.getCurrentBranchOrRev(repositories)
                + " tracks "
                + branchName
                + " but won't be deleted.";
      }
      final String checkboxMessage;
      if (trackingBranches.size() == 1) {
        checkboxMessage =
            "Delete tracking local branch " + trackingBranches.iterator().next() + " as well";
      } else {
        checkboxMessage =
            "Delete tracking local branches " + StringUtil.join(trackingBranches, ", ");
      }

      final AtomicBoolean deleteChoice = new AtomicBoolean();
      delete =
          MessageDialogBuilder.yesNo(title, message)
                  .project(myProject)
                  .yesText("Delete")
                  .noText("Cancel")
                  .doNotAsk(
                      new DialogWrapper.DoNotAskOption.Adapter() {
                        @Override
                        public void rememberChoice(boolean isSelected, int exitCode) {
                          deleteChoice.set(isSelected);
                        }

                        @NotNull
                        @Override
                        public String getDoNotShowMessage() {
                          return checkboxMessage;
                        }
                      })
                  .show()
              == Messages.YES;
      deleteTracking = deleteChoice.get();
    }
    return new DeleteRemoteBranchDecision(delete, deleteTracking);
  }
コード例 #2
0
  private boolean getAddedFilesPlaceOption() {
    final SvnConfiguration configuration = SvnConfiguration.getInstance(myVcs.getProject());
    boolean add = Boolean.TRUE.equals(configuration.isKeepNewFilesAsIsForTreeConflictMerge());
    if (configuration.isKeepNewFilesAsIsForTreeConflictMerge() != null) {
      return add;
    }
    if (!containAdditions(myTheirsChanges) && !containAdditions(myTheirsBinaryChanges)) {
      return false;
    }
    return Messages.YES
        == MessageDialogBuilder.yesNo(
                TreeConflictRefreshablePanel.TITLE,
                "Keep newly created file(s) in their original place?")
            .yesText("Keep")
            .noText("Move")
            .doNotAsk(
                new DialogWrapper.DoNotAskOption() {
                  @Override
                  public boolean isToBeShown() {
                    return true;
                  }

                  @Override
                  public void setToBeShown(boolean value, int exitCode) {
                    if (!value) {
                      if (exitCode == 0) {
                        // yes
                        configuration.setKeepNewFilesAsIsForTreeConflictMerge(true);
                      } else {
                        configuration.setKeepNewFilesAsIsForTreeConflictMerge(false);
                      }
                    }
                  }

                  @Override
                  public boolean canBeHidden() {
                    return true;
                  }

                  @Override
                  public boolean shouldSaveOptionsOnCancel() {
                    return true;
                  }

                  @NotNull
                  @Override
                  public String getDoNotShowMessage() {
                    return CommonBundle.message("dialog.options.do.not.ask");
                  }
                })
            .show();
  }