Exemplo n.º 1
0
 private void createChangelist(final ContinuationPause context) {
   final ChangeListManager listManager = ChangeListManager.getInstance(myProject);
   String name = myTitle;
   int i = 1;
   boolean updateDefaultList = false;
   while (true) {
     final LocalChangeList changeList = listManager.findChangeList(name);
     if (changeList == null) {
       final LocalChangeList newList = listManager.addChangeList(name, null);
       listManager.setDefaultChangeList(newList);
       updateDefaultList = true;
       break;
     }
     if (changeList.getChanges().isEmpty()) {
       if (!changeList.isDefault()) {
         listManager.setDefaultChangeList(changeList);
         updateDefaultList = true;
       }
       break;
     }
     name = myTitle + " (" + i + ")";
     ++i;
   }
   if (updateDefaultList) {
     context.suspend();
     listManager.invokeAfterUpdate(
         new Runnable() {
           public void run() {
             context.ping();
           }
         },
         InvokeAfterUpdateMode.BACKGROUND_NOT_CANCELLABLE_NOT_AWT,
         "",
         ModalityState.NON_MODAL);
   }
 }
Exemplo n.º 2
0
    @Override
    public void run(ContinuationContext context) {
      final String message;
      final Intersection intersection;
      final ChangeListManager listManager = ChangeListManager.getInstance(myProject);
      final List<LocalChangeList> localChangeLists = listManager.getChangeListsCopy();

      if (myMergeAll) {
        intersection = getMergeAllIntersection(localChangeLists);
        message =
            "There are local changes that can potentially intersect with merge changes.\nDo you want to continue?";
      } else {
        intersection = checkIntersection(myLists, localChangeLists);
        message =
            "There are local changes that will intersect with merge changes.\nDo you want to continue?";
      }
      if (intersection == null || intersection.getChangesSubset().isEmpty()) return;

      final LocalChangesAction action;
      if (!myMergeAll) {
        final LocalChangesAction[] possibleResults = {
          LocalChangesAction.shelve,
          LocalChangesAction.inspect,
          LocalChangesAction.continueMerge,
          LocalChangesAction.cancel
        };
        final int result =
            Messages.showDialog(
                message,
                myTitle,
                new String[] {
                  "Shelve local changes", "Inspect changes", "Continue merge", "Cancel"
                },
                0,
                Messages.getQuestionIcon());
        action = possibleResults[result];
      } else {
        final LocalChangesAction[] possibleResults = {
          LocalChangesAction.shelve, LocalChangesAction.continueMerge, LocalChangesAction.cancel
        };
        final int result =
            Messages.showDialog(
                message,
                myTitle,
                new String[] {"Shelve local changes", "Continue merge", "Cancel"},
                0,
                Messages.getQuestionIcon());
        action = possibleResults[result];
      }
      switch (action) {
          // shelve
        case shelve:
          context.next(new ShelveLocalChanges(intersection));
          return;
          // cancel
        case cancel:
          context.cancelEverything();
          return;
          // continue
        case continueMerge:
          return;
          // inspect
        case inspect:
          final Collection<Change> changes =
              (Collection<Change>) intersection.getChangesSubset().values();
          final List<FilePath> paths = ChangesUtil.getPaths(changes);
          Collections.sort(paths, FilePathByPathComparator.getInstance());
          // todo rework message
          IntersectingLocalChangesPanel.showInVersionControlToolWindow(
              myProject,
              myTitle + ", local changes intersection",
              paths,
              "The following file(s) have local changes that will intersect with merge changes:");
          context.cancelEverything();
          return;
        default:
      }
    }