Search in sources :

Example 1 with ConfigurationErrorDescription

use of com.intellij.openapi.module.ConfigurationErrorDescription in project intellij-community by JetBrains.

the class ProjectLoadingErrorsNotifierImpl method fireNotifications.

private void fireNotifications() {
    final MultiMap<ConfigurationErrorType, ConfigurationErrorDescription> descriptionsMap = new MultiMap<>();
    synchronized (myLock) {
        if (myErrors.isEmpty())
            return;
        descriptionsMap.putAllValues(myErrors);
        myErrors.clear();
    }
    for (final ConfigurationErrorType type : descriptionsMap.keySet()) {
        final Collection<ConfigurationErrorDescription> descriptions = descriptionsMap.get(type);
        if (descriptions.isEmpty())
            continue;
        final String invalidElements = getInvalidElementsString(type, descriptions);
        final String errorText = ProjectBundle.message("error.message.configuration.cannot.load") + " " + invalidElements + " <a href=\"\">Details...</a>";
        Notifications.Bus.notify(new Notification("Project Loading Error", "Error Loading Project", errorText, NotificationType.ERROR, new NotificationListener() {

            @Override
            public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                final List<ConfigurationErrorDescription> validDescriptions = ContainerUtil.findAll(descriptions, errorDescription -> errorDescription.isValid());
                if (RemoveInvalidElementsDialog.showDialog(myProject, CommonBundle.getErrorTitle(), type, invalidElements, validDescriptions)) {
                    notification.expire();
                }
            }
        }), myProject);
    }
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ConfigurationErrorDescription(com.intellij.openapi.module.ConfigurationErrorDescription) ConfigurationErrorType(com.intellij.openapi.module.ConfigurationErrorType) NotNull(org.jetbrains.annotations.NotNull) Notification(com.intellij.notification.Notification) NotificationListener(com.intellij.notification.NotificationListener)

Example 2 with ConfigurationErrorDescription

use of com.intellij.openapi.module.ConfigurationErrorDescription in project intellij-community by JetBrains.

the class RemoveInvalidElementsDialog method showDialog.

/**
   * @return {@code true} if the problems are resolved
   */
public static boolean showDialog(@NotNull Project project, @NotNull String title, ConfigurationErrorType type, @NotNull String invalidElements, @NotNull List<ConfigurationErrorDescription> errors) {
    if (errors.isEmpty()) {
        return true;
    }
    if (errors.size() == 1) {
        ConfigurationErrorDescription error = errors.get(0);
        String message = error.getDescription() + "\n" + error.getIgnoreConfirmationMessage();
        final int answer = Messages.showYesNoDialog(project, message, title, Messages.getErrorIcon());
        if (answer == Messages.YES) {
            error.ignoreInvalidElement();
            return true;
        }
        return false;
    }
    RemoveInvalidElementsDialog dialog = new RemoveInvalidElementsDialog(title, type, invalidElements, project, errors);
    if (dialog.showAndGet()) {
        for (ConfigurationErrorDescription errorDescription : dialog.getSelectedItems()) {
            errorDescription.ignoreInvalidElement();
        }
        return true;
    }
    return false;
}
Also used : ConfigurationErrorDescription(com.intellij.openapi.module.ConfigurationErrorDescription)

Aggregations

ConfigurationErrorDescription (com.intellij.openapi.module.ConfigurationErrorDescription)2 Notification (com.intellij.notification.Notification)1 NotificationListener (com.intellij.notification.NotificationListener)1 ConfigurationErrorType (com.intellij.openapi.module.ConfigurationErrorType)1 MultiMap (com.intellij.util.containers.MultiMap)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 NotNull (org.jetbrains.annotations.NotNull)1