コード例 #1
0
 private static void rollbackUnderProgress(
     @NotNull final Project project,
     @NotNull final VirtualFile virtualFile,
     @NotNull final Label labelToRevert) {
   ProgressManager.getInstance()
       .runProcessWithProgressSynchronously(
           () -> {
             try {
               labelToRevert.revert(project, virtualFile);
               VcsNotifier.getInstance(project)
                   .notifyImportantWarning(
                       "Apply Patch Aborted",
                       "All files changed during apply patch action were rolled back");
             } catch (LocalHistoryException e) {
               VcsNotifier.getInstance(project)
                   .notifyImportantWarning(
                       "Rollback Failed",
                       String.format(
                           "Try using local history dialog for %s and perform revert manually.",
                           virtualFile.getName()));
             }
           },
           "Rollback Applied Changes...",
           true,
           project);
 }
コード例 #2
0
  public void rescanAndNotifyIfNeeded() {
    Collection<VcsRootError> errors = scan();
    if (errors.isEmpty()) {
      synchronized (NOTIFICATION_LOCK) {
        expireNotification();
      }
      return;
    }

    Collection<VcsRootError> importantUnregisteredRoots = getImportantUnregisteredMappings(errors);
    Collection<VcsRootError> invalidRoots = getInvalidRoots(errors);

    List<String> unregRootPaths =
        ContainerUtil.map(importantUnregisteredRoots, PATH_FROM_ROOT_ERROR);
    if (invalidRoots.isEmpty()
        && (importantUnregisteredRoots.isEmpty()
            || myReportedUnregisteredRoots.containsAll(unregRootPaths))) {
      return;
    }
    myReportedUnregisteredRoots.addAll(unregRootPaths);

    String title = makeTitle(importantUnregisteredRoots, invalidRoots);
    String description = makeDescription(importantUnregisteredRoots, invalidRoots);

    synchronized (NOTIFICATION_LOCK) {
      expireNotification();
      NotificationListener listener =
          new MyNotificationListener(
              myProject, mySettings, myVcsManager, importantUnregisteredRoots);
      VcsNotifier notifier = VcsNotifier.getInstance(myProject);
      myNotification =
          invalidRoots.isEmpty()
              ? notifier.notifyMinorInfo(title, description, listener)
              : notifier.notifyError(title, description, listener);
    }
  }
コード例 #3
0
 /**
  * Checks Git version and updates the myVersion variable. In the case of exception or unsupported
  * version reports the problem. Note that unsupported version is also applied - some functionality
  * might not work (we warn about that), but no need to disable at all.
  */
 public void checkVersion() {
   final String executable = myAppSettings.getPathToGit();
   try {
     myVersion = GitVersion.identifyVersion(executable);
     if (!myVersion.isSupported()) {
       log.info("Unsupported Git version: " + myVersion);
       final String SETTINGS_LINK = "settings";
       final String UPDATE_LINK = "update";
       String message =
           String.format(
               "The <a href='"
                   + SETTINGS_LINK
                   + "'>configured</a> version of Git is not supported: %s.<br/> "
                   + "The minimal supported version is %s. Please <a href='"
                   + UPDATE_LINK
                   + "'>update</a>.",
               myVersion,
               GitVersion.MIN);
       VcsNotifier.getInstance(myProject)
           .notifyError(
               "Unsupported Git version",
               message,
               new NotificationListener.Adapter() {
                 @Override
                 protected void hyperlinkActivated(
                     @NotNull Notification notification, @NotNull HyperlinkEvent e) {
                   if (SETTINGS_LINK.equals(e.getDescription())) {
                     ShowSettingsUtil.getInstance()
                         .showSettingsDialog(myProject, getConfigurable().getDisplayName());
                   } else if (UPDATE_LINK.equals(e.getDescription())) {
                     BrowserUtil.browse("http://git-scm.com");
                   }
                 }
               });
     }
   } catch (Exception e) {
     if (getExecutableValidator()
         .checkExecutableAndNotifyIfNeeded()) { // check executable before notifying error
       final String reason = (e.getCause() != null ? e.getCause() : e).getMessage();
       String message = GitBundle.message("vcs.unable.to.run.git", executable, reason);
       if (!myProject.isDefault()) {
         showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
       }
       VcsBalloonProblemNotifier.showOverVersionControlView(myProject, message, MessageType.ERROR);
     }
   }
 }