You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NotificationsService.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.rthoni.intellij.codefromds.ui.others;
  2. import com.intellij.notification.Notification;
  3. import com.intellij.notification.NotificationType;
  4. import com.intellij.notification.Notifications;
  5. import com.intellij.openapi.application.ApplicationManager;
  6. import com.intellij.openapi.components.ServiceManager;
  7. /**
  8. * Created by robin on 11/18/16.
  9. */
  10. public class NotificationsService {
  11. public static NotificationsService getInstance() {
  12. return ServiceManager.getService(NotificationsService.class);
  13. }
  14. public void showNotification(String title, String content, NotificationType type)
  15. {
  16. ApplicationManager.getApplication().invokeLater(() -> {
  17. Notification n = new Notification("Code From Ds", title, content, type);
  18. Notifications.Bus.notify(n);
  19. });
  20. }
  21. public void showErrorNotification(String title, String content)
  22. {
  23. showNotification(title, content, NotificationType.ERROR);
  24. }
  25. public void showInfoNotification(String title, String content)
  26. {
  27. showNotification(title, content, NotificationType.INFORMATION);
  28. }
  29. }