Search in sources :

Example 1 with PropertyKey

use of org.jetbrains.annotations.PropertyKey in project intellij-community by JetBrains.

the class SystemHealthMonitor method showNotification.

private void showNotification(final KeyHyperlinkAdapter keyHyperlinkAdapter, Object... params) {
    @PropertyKey(resourceBundle = "messages.IdeBundle") String key = keyHyperlinkAdapter.getKey();
    final String ignoreKey = keyHyperlinkAdapter.getIgnoreKey();
    boolean ignored = myProperties.isValueSet(ignoreKey);
    LOG.info("issue detected: " + key + (ignored ? " (ignored)" : ""));
    if (ignored)
        return;
    final String message = IdeBundle.message(key, params) + IdeBundle.message("sys.health.acknowledge.link");
    final Application app = ApplicationManager.getApplication();
    app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {

        @Override
        public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
            app.invokeLater(() -> {
                JComponent component = WindowManager.getInstance().findVisibleFrame().getRootPane();
                if (component != null) {
                    Rectangle rect = component.getVisibleRect();
                    JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, MessageType.WARNING, keyHyperlinkAdapter).setFadeoutTime(-1).setHideOnFrameResize(false).setHideOnLinkClick(true).setDisposable(app).createBalloon().show(new RelativePoint(component, new Point(rect.x + 30, rect.y + rect.height - 10)), Balloon.Position.above);
                }
                Notification notification = LOG_GROUP.createNotification(message, NotificationType.WARNING);
                notification.setImportant(true);
                Notifications.Bus.notify(notification);
            });
        }
    });
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PropertyKey(org.jetbrains.annotations.PropertyKey)

Aggregations

RelativePoint (com.intellij.ui.awt.RelativePoint)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 PropertyKey (org.jetbrains.annotations.PropertyKey)1