예제 #1
0
  private static String constructMessage(
      final ConflictManagerExternal conflictManager, boolean allConflictsResolved)
      throws OseeCoreException {
    StringBuilder message = new StringBuilder();
    Branch sourceBranch = conflictManager.getSourceBranch();
    Branch destinationBranch = conflictManager.getDestinationBranch();

    if (allConflictsResolved) {
      message.append("Ready to commit");
    } else {
      message.append("Couldn't commit branch because of unresolved conflicts");
    }
    message.append(
        String.format(
            "\n\n\"[%s]\"\n\n onto destination branch \n\n\"[%s]\"\n\n",
            sourceBranch, destinationBranch));

    int numOriginalConflicts = conflictManager.getOriginalConflicts().size();
    if (allConflictsResolved) {
      message.append(
          String.format(
              "with all (%d) conflicts resolved\n\nWould you like to Commit?",
              numOriginalConflicts));
    } else {
      message.append(
          "with "
              + conflictManager.getRemainingConflicts().size()
              + " / "
              + numOriginalConflicts
              + " conflicts still unresolved\n");
    }

    return message.toString();
  }
예제 #2
0
  private static int promptUserMutlipleChoices(ConflictManagerExternal conflictManager)
      throws OseeCoreException {
    boolean isAllConflictsResolved = !conflictManager.remainingConflictsExist();
    Messages = constructMessage(conflictManager, isAllConflictsResolved);
    Choices = constructChoices(conflictManager, isAllConflictsResolved);
    final MutableInteger result = new MutableInteger(CANCEL);

    Displays.pendInDisplayThread(
        new Runnable() {
          @Override
          public void run() {
            MessageDialog dialog =
                new MessageDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    TITLE,
                    null,
                    Messages,
                    MessageDialog.QUESTION,
                    Choices,
                    CANCEL);
            result.setValue(dialog.open());
          }
        });

    if (!isAllConflictsResolved) { // Since all conflicts were not resolved, options start with
                                   // Launch Merge Manager(1) instead of Commit(0)
      result.getValueAndInc();
    }

    return result.getValue();
  }
예제 #3
0
  public static boolean handleCommitInProgressPostPrompt(
      final ConflictManagerExternal conflictManager, int userOption, boolean skipPrompts)
      throws OseeCoreException {
    boolean toReturn = false;
    Branch sourceBranch = conflictManager.getSourceBranch();
    Branch destinationBranch = conflictManager.getDestinationBranch();

    if (userOption == COMMIT) { // Commit
      BranchManager.commitBranch(null, conflictManager, archiveBranch, false);
      toReturn = true;
    } else if (userOption == LAUNCH_MERGE_VIEW) { // Launch Merge
      MergeView.openView(sourceBranch, destinationBranch, sourceBranch.getBaseTransaction());
    } else if (userOption == DELETE_MERGE) { // Delete Merge
      deleteSingleMergeBranches(sourceBranch, destinationBranch, skipPrompts);
    } else if (userOption == FORCE_COMMIT) { // Force Commit, admin only
      BranchManager.commitBranch(null, conflictManager, archiveBranch, true);
      toReturn = true;
    } else if (userOption == CANCEL) {
      // do nothing
    }
    return toReturn;
  }