Java Code Examples for com.intellij.notification.NotificationType#WARNING

The following examples show how to use com.intellij.notification.NotificationType#WARNING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerMessageHandler.java    From intellij-quarkus with Eclipse Public License 2.0 6 votes vote down vote up
private static NotificationType messageTypeToNotificationType(MessageType type) {
    NotificationType result = null;

    switch (type) {
        case Error:
            result = NotificationType.ERROR;
            break;
        case Info:
        case Log:
            result = NotificationType.INFORMATION;
            break;
        case Warning:
            result = NotificationType.WARNING;
    }
    return result;
}
 
Example 2
Source File: AbstractCommonUpdateAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private Notification prepareNotification(@Nonnull UpdateInfoTree tree, boolean someSessionWasCancelled) {
  int allFiles = getUpdatedFilesCount();

  String title;
  String content;
  NotificationType type;
  if (someSessionWasCancelled) {
    title = "Project Partially Updated";
    content = allFiles + " " + pluralize("file", allFiles) + " updated";
    type = NotificationType.WARNING;
  }
  else {
    title = allFiles + " Project " + pluralize("File", allFiles) + " Updated";
    content = notNullize(prepareScopeUpdatedText(tree));
    type = NotificationType.INFORMATION;
  }

  return STANDARD_NOTIFICATION.createNotification(title, content, type, null);
}
 
Example 3
Source File: IdeNotificationArea.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static NotificationType getMaximumType(List<Notification> notifications) {
  NotificationType result = null;
  for (Notification notification : notifications) {
    if (NotificationType.ERROR == notification.getType()) {
      return NotificationType.ERROR;
    }

    if (NotificationType.WARNING == notification.getType()) {
      result = NotificationType.WARNING;
    }
    else if (result == null && NotificationType.INFORMATION == notification.getType()) {
      result = NotificationType.INFORMATION;
    }
  }

  return result;
}
 
Example 4
Source File: JumpToSourceAction.java    From MavenHelper with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
	final Navigatable navigatable = getNavigatable(myArtifact, myProject, myMavenProject);
	if (navigatable != null && navigatable.canNavigate()) {
		navigatable.navigate(true);
	} else {
		final Notification notification = new Notification(MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION, "", "Parent dependency not found, strange...",
				NotificationType.WARNING);
		ApplicationManager.getApplication().invokeLater(new Runnable() {
			@Override
			public void run() {
				Notifications.Bus.notify(notification, myProject);
			}
		});
	}
}
 
Example 5
Source File: IntelliJDeploymentManager.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
@Override
void sendAlert(MessageType messageType, String title, String message) {
    NotificationType type;
    switch(messageType) {
        case ERROR:
            type = NotificationType.ERROR;
            break;
        case WARNING:
            type = NotificationType.WARNING;
            break;
        default:
            type = NotificationType.INFORMATION;
    }
    String myTitle = AEMBundle.message(title);
    myTitle = myTitle.equals("") ? title : myTitle;
    messageManager.showAlert(type, myTitle, message);
}
 
Example 6
Source File: QuarkusPreLoadingActivity.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void preload(@NotNull ProgressIndicator indicator) {
    if (PluginHelper.isLSPPluginInstalledAndNotUsed()) {
        Notification notification = new Notification(NOTIFICATION_GROUP, AllIcons.General.Warning,
                NOTIFICATION_GROUP, null,
                "LSP Support plugin in enabled but not used by any plugin, it may causes issues and Quarkus Tools does not depend on it anymore so you better disable or remove it.",
                NotificationType.WARNING, null);
        Notifications.Bus.notify(notification);
    }
}
 
Example 7
Source File: ExcludeDependencyAction.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
private void exclude() {
	final MavenArtifact artifactToExclude = myArtifact.getArtifact();
	final MavenArtifactNode oldestParent = getOldestParentMavenArtifact();

	DomFileElement domFileElement = getDomFileElement(oldestParent);

	if (domFileElement != null) {
		final MavenDomProjectModel rootElement = (MavenDomProjectModel) domFileElement.getRootElement();
		final MavenDomDependencies dependencies = rootElement.getDependencies();
		boolean found = false;

		for (MavenDomDependency mavenDomDependency : dependencies.getDependencies()) {
			if (isSameDependency(oldestParent.getArtifact(), mavenDomDependency)) {
				found = true;
				final MavenDomExclusions exclusions = mavenDomDependency.getExclusions();
				for (MavenDomExclusion mavenDomExclusion : exclusions.getExclusions()) {
					if (isSameDependency(artifactToExclude, mavenDomExclusion)) {
						return;
					}
				}
				createExclusion(artifactToExclude, exclusions);
				dependencyExcluded();
			}
		}
		if (!found) {
			final Notification notification = new Notification(MAVEN_HELPER_DEPENDENCY_ANALYZER_NOTIFICATION, "",
					"Parent dependency not found, it is probably in the parent pom", NotificationType.WARNING);
			ApplicationManager.getApplication().invokeLater(new Runnable() {
				@Override
				public void run() {
					Notifications.Bus.notify(notification, myProject);
				}
			});
		}
	}
}
 
Example 8
Source File: FlatWelcomePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private JComponent createEventsLink() {
  final Ref<ActionLink> actionLinkRef = new Ref<>();
  final JComponent panel = createActionLink("Events", AllIcons.Ide.Notification.NoEvents, actionLinkRef, new AnAction() {
    @RequiredUIAccess
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      ((WelcomeDesktopBalloonLayoutImpl)myFlatWelcomeFrame.getBalloonLayout()).showPopup();
    }
  });
  panel.setVisible(false);
  myEventListener = types -> {
    NotificationType type1 = null;
    for (NotificationType t : types) {
      if (NotificationType.ERROR == t) {
        type1 = NotificationType.ERROR;
        break;
      }
      if (NotificationType.WARNING == t) {
        type1 = NotificationType.WARNING;
      }
      else if (type1 == null && NotificationType.INFORMATION == t) {
        type1 = NotificationType.INFORMATION;
      }
    }

    actionLinkRef.get().setIcon(TargetAWT.to(IdeNotificationArea.createIconWithNotificationCount(type1, types.size())));
    panel.setVisible(true);
  };
  myEventLocation = () -> {
    Point location = SwingUtilities.convertPoint(panel, 0, 0, getRootPane().getLayeredPane());
    return new Point(location.x, location.y + 5);
  };
  return panel;
}
 
Example 9
Source File: GaugeNotification.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
public NotificationType getType() {
    switch (type) {
        case "error":
            return NotificationType.ERROR;
        case "warning":
            return NotificationType.WARNING;
        case "info":
            return NotificationType.INFORMATION;
        default:
            return NotificationType.INFORMATION;

    }

}
 
Example 10
Source File: ErrorMessageService.java    From tmc-intellij with MIT License 5 votes vote down vote up
private Icon iconForNotificationType(NotificationType type) {
    if (type == NotificationType.WARNING) {
        return Messages.getWarningIcon();
    } else if (type == NotificationType.ERROR) {
        return Messages.getErrorIcon();
    } else if (type == NotificationType.INFORMATION) {
        return Messages.getInformationIcon();
    } else {
        return Messages.getErrorIcon();
    }
}
 
Example 11
Source File: PresentableErrorMessage.java    From tmc-intellij with MIT License 5 votes vote down vote up
/**
 * Generates a human readable error message for a {@link TmcCoreException} and decides the
 * error's severity.
 */
static PresentableErrorMessage forTmcException(TmcCoreException exception) {
    String causeMessage;

    causeMessage = exception.getMessage();

    String shownMessage;
    NotificationType type = NotificationType.WARNING;

    if (causeMessage.contains("Download failed")
            || causeMessage.contains("404")
            || causeMessage.contains("500")) {
        shownMessage = notifyAboutCourseServerAddressAndInternet();
    } else if (!TmcSettingsManager.get().userDataExists()) {
        shownMessage = notifyAboutUsernamePasswordAndServerAddress(causeMessage);
    } else if (causeMessage.contains("401")) {
        shownMessage = notifyAboutIncorrectUsernameOrPassword(causeMessage);
        type = NotificationType.ERROR;
    } else if (causeMessage.contains("Organization not selected")) {
        shownMessage = causeMessage;
    } else if (causeMessage.contains("Failed to fetch courses from the server")
            || causeMessage.contains("Failed to compress project")
            || causeMessage.contains("Failed to submit exercise")) {
        shownMessage = notifyAboutFailedSubmissionAttempt();
    } else if (TmcSettingsManager.get().getServerAddress().isEmpty()) {
        shownMessage = notifyAboutEmptyServerAddress(causeMessage);
    } else {
        shownMessage = causeMessage;
        type = NotificationType.ERROR;
    }

    return new PresentableErrorMessage(shownMessage, type);
}
 
Example 12
Source File: SwaggerFileService.java    From intellij-swagger with MIT License 5 votes vote down vote up
private void notifyFailure(final Exception exception) {
  Notification notification =
      new Notification(
          "Swagger UI",
          "Could not generate Swagger UI",
          exception.getMessage(),
          NotificationType.WARNING);

  Notifications.Bus.notify(notification);
}
 
Example 13
Source File: BuildTemplateAction.java    From react-templates-plugin with MIT License 4 votes vote down vote up
public static void warn(Project project, String msg) {
    Notification errorNotification1 = new Notification("React-Templates plugin", "React-Templates plugin", msg, NotificationType.WARNING);
    Notifications.Bus.notify(errorNotification1, project);
}
 
Example 14
Source File: BuildTemplateAction.java    From react-templates-plugin with MIT License 4 votes vote down vote up
public static void warn(Project project, String msg) {
    Notification errorNotification1 = new Notification("React-Templates plugin", "React-Templates plugin", msg, NotificationType.WARNING);
    Notifications.Bus.notify(errorNotification1, project);
}
 
Example 15
Source File: WindowsDefenderNotification.java    From consulo with Apache License 2.0 4 votes vote down vote up
public WindowsDefenderNotification(String text, Collection<Path> paths) {
   super("System Health", "", text, NotificationType.WARNING);
  myPaths = paths;
}
 
Example 16
Source File: MessageType.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public NotificationType toNotificationType() {
  return this == ERROR ? NotificationType.ERROR : this == WARNING ? NotificationType.WARNING : NotificationType.INFORMATION;
}
 
Example 17
Source File: SystemShortcuts.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void doNotify(@Nonnull Keymap keymap, @Nonnull String actionId, @Nonnull KeyStroke sysKS, @Nullable String macOsShortcutAction, @Nonnull KeyboardShortcut conflicted) {
  if (!ourIsNotificationRegistered) {
    ourIsNotificationRegistered = true;
    NotificationsConfiguration.getNotificationsConfiguration().register(ourNotificationGroupId, NotificationDisplayType.STICKY_BALLOON, true);
  }

  final AnAction act = ActionManager.getInstance().getAction(actionId);
  final String actText = act == null ? actionId : act.getTemplateText();
  final String message = "The " +
                         actText +
                         " shortcut conflicts with macOS shortcut" +
                         (macOsShortcutAction == null ? "" : " '" + macOsShortcutAction + "'") +
                         ". Modify this shortcut or change macOS system settings.";
  final Notification notification = new Notification(ourNotificationGroupId, "Shortcuts conflicts", message, NotificationType.WARNING, null);

  final AnAction configureShortcut = DumbAwareAction.create("Modify shortcut", e -> {
    Component component = e.getDataContext().getData(PlatformDataKeys.CONTEXT_COMPONENT);
    if (component == null) {
      Window[] frames = Window.getWindows();
      component = frames == null || frames.length == 0 ? null : frames[0];
      if (component == null) {
        LOG.error("can't show KeyboardShortcutDialog (parent component wasn't found)");
        return;
      }
    }

    KeymapPanel.addKeyboardShortcut(actionId, ActionShortcutRestrictions.getInstance().getForActionId(actionId), keymap, component, conflicted, SystemShortcuts.this);
    notification.expire();
  });
  notification.addAction(configureShortcut);

  final AnAction muteAction = DumbAwareAction.create("Don't show again", e -> {
    myMutedConflicts.addMutedAction(actionId);
    notification.expire();
  });
  notification.addAction(muteAction);

  if (SystemInfo.isMac) {
    final AnAction changeSystemSettings = DumbAwareAction.create("Change system settings", e -> {
      ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final GeneralCommandLine cmdLine =
                new GeneralCommandLine("osascript", "-e", "tell application \"System Preferences\"", "-e", "set the current pane to pane id \"com.apple.preference.keyboard\"", "-e",
                                       "reveal anchor \"shortcutsTab\" of pane id \"com.apple.preference.keyboard\"", "-e", "activate", "-e", "end tell");
        try {
          ExecUtil.execAndGetOutput(cmdLine);
          // NOTE: we can't detect OS-settings changes
          // but we can try to schedule check conflicts (and expire notification if necessary)
        }
        catch (ExecutionException ex) {
          LOG.error(ex);
        }
      });
    });
    notification.addAction(changeSystemSettings);
  }

  myNotifiedActions.add(actionId);
  notification.notify(null);
}
 
Example 18
Source File: ORNotification.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@NotNull
private static Icon getIcon(@NotNull NotificationType type) {
    return type == NotificationType.INFORMATION ? ORIcons.RML_BLUE : (type == NotificationType.WARNING ? ORIcons.RML_YELLOW : ORIcons.RML_FILE);
}
 
Example 19
Source File: LOG.java    From SmartIM4IntelliJ with Apache License 2.0 4 votes vote down vote up
public static void sendNotification(String title, String content) {
    Notification n = new Notification("SmartIM", title, content, NotificationType.WARNING);
    Notifications.Bus.notify(n);
}
 
Example 20
Source File: CommitHelper.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static NotificationType resolveNotificationType(@Nonnull GeneralCommitProcessor processor) {
  boolean hasExceptions = !processor.getVcsExceptions().isEmpty();
  boolean hasOnlyWarnings = doesntContainErrors(processor.getVcsExceptions());

  return hasExceptions ? (hasOnlyWarnings ? NotificationType.WARNING : NotificationType.ERROR) : NotificationType.INFORMATION;
}