Search in sources :

Example 86 with Notification

use of com.intellij.notification.Notification in project intellij-community by JetBrains.

the class MavenProjectsProcessor method doProcessPendingTasks.

private void doProcessPendingTasks(MavenProgressIndicator indicator, MavenProjectsProcessorTask task) throws MavenProcessCanceledException {
    int counter = 0;
    try {
        while (true) {
            indicator.checkCanceled();
            counter++;
            int remained;
            synchronized (myQueue) {
                remained = myQueue.size();
            }
            indicator.setFraction(counter / (double) (counter + remained));
            try {
                final MavenGeneralSettings mavenGeneralSettings = MavenProjectsManager.getInstance(myProject).getGeneralSettings();
                task.perform(myProject, myEmbeddersManager, new SoutMavenConsole(mavenGeneralSettings.getOutputLevel(), mavenGeneralSettings.isPrintErrorStackTraces()), indicator);
            } catch (MavenProcessCanceledException e) {
                throw e;
            } catch (Throwable e) {
                MavenLog.LOG.error(e);
                new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Unable to import maven project", "See logs for details", NotificationType.ERROR).notify(myProject);
            }
            synchronized (myQueue) {
                task = myQueue.poll();
                if (task == null) {
                    isProcessing = false;
                    return;
                }
            }
        }
    } catch (MavenProcessCanceledException e) {
        synchronized (myQueue) {
            myQueue.clear();
            isProcessing = false;
        }
        throw e;
    }
}
Also used : SoutMavenConsole(org.jetbrains.idea.maven.execution.SoutMavenConsole) Notification(com.intellij.notification.Notification)

Example 87 with Notification

use of com.intellij.notification.Notification in project intellij-community by JetBrains.

the class MavenShowEffectivePom method actionPerformed.

public static void actionPerformed(@NotNull final Project project, @NotNull final VirtualFile file) {
    final MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
    final MavenProject mavenProject = manager.findProject(file);
    assert mavenProject != null;
    manager.evaluateEffectivePom(mavenProject, s -> ApplicationManager.getApplication().invokeLater(() -> {
        if (project.isDisposed())
            return;
        if (s == null) {
            new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Error", "Failed to evaluate effective pom.", NotificationType.ERROR).notify(project);
            return;
        }
        String fileName = mavenProject.getMavenId().getArtifactId() + "-effective-pom.xml";
        PsiFile file1 = PsiFileFactory.getInstance(project).createFileFromText(fileName, XMLLanguage.INSTANCE, s);
        try {
            file1.getVirtualFile().setWritable(false);
        } catch (IOException e) {
            LOG.error(e);
        }
        file1.navigate(true);
    }));
}
Also used : MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) PsiFile(com.intellij.psi.PsiFile) IOException(java.io.IOException) Notification(com.intellij.notification.Notification)

Example 88 with Notification

use of com.intellij.notification.Notification in project intellij-community by JetBrains.

the class MavenUtil method showError.

public static void showError(Project project, String title, Throwable e) {
    MavenLog.LOG.warn(title, e);
    Notifications.Bus.notify(new Notification(MAVEN_NOTIFICATION_GROUP, title, e.getMessage(), NotificationType.ERROR), project);
}
Also used : Notification(com.intellij.notification.Notification)

Example 89 with Notification

use of com.intellij.notification.Notification in project intellij-community by JetBrains.

the class GithubTest method checkNotification.

protected void checkNotification(@NotNull NotificationType type, @Nullable String title, @Nullable String content) {
    Notification actualNotification = myVcsNotifier.getLastNotification();
    assertNotNull("No notification was shown", actualNotification);
    if (title != null) {
        assertEquals("Notification has wrong title (content: " + actualNotification.getContent() + ")", title, actualNotification.getTitle());
    }
    if (content != null) {
        assertEquals("Notification has wrong content", content, actualNotification.getContent());
    }
    assertEquals("Notification has wrong type", type, actualNotification.getType());
}
Also used : Notification(com.intellij.notification.Notification)

Example 90 with Notification

use of com.intellij.notification.Notification in project intellij-community by JetBrains.

the class HgVcs method checkVersion.

/**
   * Checks Hg version and updates the myVersion variable.
   * In the case of nullable or unsupported version reports the problem.
   */
public void checkVersion() {
    final String executable = getGlobalSettings().getHgExecutable();
    VcsNotifier vcsNotifier = VcsNotifier.getInstance(myProject);
    final String SETTINGS_LINK = "settings";
    final String UPDATE_LINK = "update";
    NotificationListener linkAdapter = 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://mercurial.selenic.com");
            }
        }
    };
    try {
        myVersion = HgVersion.identifyVersion(executable);
        //if version is not supported, but have valid hg executable
        if (!myVersion.isSupported()) {
            LOG.info("Unsupported Hg version: " + myVersion);
            String message = String.format("The <a href='" + SETTINGS_LINK + "'>configured</a> version of Hg is not supported: %s.<br/> " + "The minimal supported version is %s. Please <a href='" + UPDATE_LINK + "'>update</a>.", myVersion, HgVersion.MIN);
            vcsNotifier.notifyError("Unsupported Hg version", message, linkAdapter);
        } else if (myVersion.hasUnsupportedExtensions()) {
            String unsupportedExtensionsAsString = myVersion.getUnsupportedExtensions().toString();
            LOG.warn("Unsupported Hg extensions: " + unsupportedExtensionsAsString);
            String message = String.format("Some hg extensions %s are not found or not supported by your hg version and will be ignored.\n" + "Please, update your hgrc or Mercurial.ini file", unsupportedExtensionsAsString);
            vcsNotifier.notifyWarning("Unsupported Hg version", message);
        }
    } catch (Exception e) {
        if (getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
            //sometimes not hg application has version command, but we couldn't parse an answer as valid hg,
            // so parse(output) throw ParseException, but hg and git executable seems to be valid in this case
            final String reason = (e.getCause() != null ? e.getCause() : e).getMessage();
            String message = HgVcsMessages.message("hg4idea.unable.to.run.hg", executable);
            vcsNotifier.notifyError(message, reason + "<br/> Please check your hg executable path in <a href='" + SETTINGS_LINK + "'> settings </a>", linkAdapter);
        }
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Aggregations

Notification (com.intellij.notification.Notification)108 HyperlinkEvent (javax.swing.event.HyperlinkEvent)34 NotNull (org.jetbrains.annotations.NotNull)34 NotificationListener (com.intellij.notification.NotificationListener)33 Project (com.intellij.openapi.project.Project)19 IOException (java.io.IOException)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 File (java.io.File)8 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)7 Nullable (org.jetbrains.annotations.Nullable)7 Module (com.intellij.openapi.module.Module)6 Task (com.intellij.openapi.progress.Task)6 ExecutionException (com.intellij.execution.ExecutionException)4 NotificationType (com.intellij.notification.NotificationType)4 Application (com.intellij.openapi.application.Application)3 Library (com.intellij.openapi.roots.libraries.Library)3 ActionCallback (com.intellij.openapi.util.ActionCallback)3 ArrayList (java.util.ArrayList)3 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)2 NotificationAction (com.intellij.notification.NotificationAction)2