Search in sources :

Example 41 with Notification

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

the class ConfigurationErrorEvent method process.

@Override
public void process(@NotNull final TestEventXmlView xml) throws TestEventXmlView.XmlParserException {
    final String errorTitle = xml.getEventTitle();
    final String configurationErrorMsg = xml.getEventMessage();
    final boolean openSettings = xml.isEventOpenSettings();
    final Project project = getProject();
    assert project != null;
    final String message = openSettings ? String.format("<br>\n%s<br><br>\n\n<a href=\"Gradle settings\">Open gradle settings</a>", configurationErrorMsg) : String.format("<br>\n%s", configurationErrorMsg);
    GradleNotification.getInstance(project).showBalloon(errorTitle, message, NotificationType.WARNING, new NotificationListener() {

        @Override
        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            notification.expire();
            if ("Gradle settings".equals(event.getDescription())) {
                ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(GradleConstants.SYSTEM_ID);
                assert manager instanceof GradleManager;
                GradleManager gradleManager = (GradleManager) manager;
                Configurable configurable = gradleManager.getConfigurable(project);
                ShowSettingsUtil.getInstance().editConfigurable(project, configurable);
            } else {
                BrowserUtil.browse(event.getDescription());
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ExternalSystemManager(com.intellij.openapi.externalSystem.ExternalSystemManager) GradleManager(org.jetbrains.plugins.gradle.GradleManager) Configurable(com.intellij.openapi.options.Configurable) GradleNotification(org.jetbrains.plugins.gradle.service.project.GradleNotification) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 42 with Notification

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

the class FrameworkDetectionManager method doRunDetection.

private void doRunDetection() {
    Set<Integer> detectorsToProcess;
    synchronized (myLock) {
        detectorsToProcess = new HashSet<>(myDetectorsToProcess);
        detectorsToProcess.addAll(myDetectorsToProcess);
        myDetectorsToProcess.clear();
    }
    if (detectorsToProcess.isEmpty())
        return;
    if (LOG.isDebugEnabled()) {
        LOG.debug("Starting framework detectors: " + detectorsToProcess);
    }
    final FileBasedIndex index = FileBasedIndex.getInstance();
    List<DetectedFrameworkDescription> newDescriptions = new ArrayList<>();
    List<DetectedFrameworkDescription> oldDescriptions = new ArrayList<>();
    final DetectionExcludesConfiguration excludesConfiguration = DetectionExcludesConfiguration.getInstance(myProject);
    for (Integer id : detectorsToProcess) {
        final List<? extends DetectedFrameworkDescription> frameworks = runDetector(id, index, excludesConfiguration, true);
        oldDescriptions.addAll(frameworks);
        final Collection<? extends DetectedFrameworkDescription> updated = myDetectedFrameworksData.updateFrameworksList(id, frameworks);
        newDescriptions.addAll(updated);
        oldDescriptions.removeAll(updated);
        if (LOG.isDebugEnabled()) {
            LOG.debug(frameworks.size() + " frameworks detected, " + updated.size() + " changed");
        }
    }
    Set<String> frameworkNames = new HashSet<>();
    for (final DetectedFrameworkDescription description : FrameworkDetectionUtil.removeDisabled(newDescriptions, oldDescriptions)) {
        frameworkNames.add(description.getDetector().getFrameworkType().getPresentableName());
    }
    if (!frameworkNames.isEmpty()) {
        String names = StringUtil.join(frameworkNames, ", ");
        final String text = ProjectBundle.message("framework.detected.info.text", names, frameworkNames.size());
        FRAMEWORK_DETECTION_NOTIFICATION.createNotification("Frameworks detected", text, NotificationType.INFORMATION, new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                    showSetupFrameworksDialog(notification);
                }
            }
        }).notify(myProject);
    }
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) DetectedFrameworkDescription(com.intellij.framework.detection.DetectedFrameworkDescription) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) DetectionExcludesConfiguration(com.intellij.framework.detection.DetectionExcludesConfiguration) NotificationListener(com.intellij.notification.NotificationListener)

Example 43 with Notification

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

the class AbstractLayoutCodeProcessor method handleFileTooBigException.

protected void handleFileTooBigException(Logger logger, FilesTooBigForDiffException e, @NotNull PsiFile file) {
    logger.info("Error while calculating changed ranges for: " + file.getVirtualFile(), e);
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
        Notification notification = new Notification(ApplicationBundle.message("reformat.changed.text.file.too.big.notification.groupId"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.title"), ApplicationBundle.message("reformat.changed.text.file.too.big.notification.text", file.getName()), NotificationType.INFORMATION);
        notification.notify(file.getProject());
    }
}
Also used : Notification(com.intellij.notification.Notification)

Example 44 with Notification

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

the class ChangeListStorageImpl method notifyUser.

public static void notifyUser(String message) {
    final String logFile = PathManager.getLogPath();
    /*String createIssuePart = "<br>" +
                             "<br>" +
                             "Please attach log files from <a href=\"file\">" + logFile + "</a><br>" +
                             "to the <a href=\"url\">YouTrack issue</a>";*/
    Notifications.Bus.notify(new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Local History is broken", message, /*+ createIssuePart*/
    NotificationType.ERROR, new NotificationListener() {

        @Override
        public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
            if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if ("url".equals(event.getDescription())) {
                    BrowserUtil.browse("http://youtrack.jetbrains.net/issue/IDEA-71270");
                } else {
                    File file = new File(logFile);
                    ShowFilePathAction.openFile(file);
                }
            }
        }
    }), null);
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) NotNull(org.jetbrains.annotations.NotNull) File(java.io.File) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 45 with Notification

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

the class ModuleManagerComponent method showUnknownModuleTypeNotification.

@Override
protected void showUnknownModuleTypeNotification(@NotNull List<Module> modulesWithUnknownTypes) {
    if (!ApplicationManager.getApplication().isHeadlessEnvironment() && !modulesWithUnknownTypes.isEmpty()) {
        String message;
        if (modulesWithUnknownTypes.size() == 1) {
            message = ProjectBundle.message("module.unknown.type.single.error", modulesWithUnknownTypes.get(0).getName(), ModuleType.get(modulesWithUnknownTypes.get(0)).getId());
        } else {
            StringBuilder modulesBuilder = new StringBuilder();
            for (final Module module : modulesWithUnknownTypes) {
                modulesBuilder.append("<br>\"");
                modulesBuilder.append(module.getName()).append("\" (type '").append(ModuleType.get(module).getId()).append("')");
            }
            modulesBuilder.append("<br>");
            message = ProjectBundle.message("module.unknown.type.multiple.error", modulesBuilder.toString());
        }
        // it is not modal warning at all
        //Messages.showWarningDialog(myProject, message, ProjectBundle.message("module.unknown.type.title"));
        Notifications.Bus.notify(new Notification("Module Manager", ProjectBundle.message("module.unknown.type.title"), message, NotificationType.WARNING), myProject);
    }
}
Also used : Module(com.intellij.openapi.module.Module) Notification(com.intellij.notification.Notification)

Aggregations

Notification (com.intellij.notification.Notification)114 HyperlinkEvent (javax.swing.event.HyperlinkEvent)34 NotNull (org.jetbrains.annotations.NotNull)34 NotificationListener (com.intellij.notification.NotificationListener)33 Project (com.intellij.openapi.project.Project)20 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 File (java.io.File)11 IOException (java.io.IOException)11 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)8 Nullable (org.jetbrains.annotations.Nullable)8 Task (com.intellij.openapi.progress.Task)7 Module (com.intellij.openapi.module.Module)6 ExecutionException (com.intellij.execution.ExecutionException)4 NotificationAction (com.intellij.notification.NotificationAction)4 NotificationType (com.intellij.notification.NotificationType)4 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)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