Search in sources :

Example 1 with MarkdownApplicationSettings

use of org.intellij.plugins.markdown.settings.MarkdownApplicationSettings in project intellij-plugins by JetBrains.

the class JavaFxCouldBeEnabledNotificationProvider method createNotificationPanel.

@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull final FileEditor fileEditor) {
    if (file.getFileType() != MarkdownFileType.INSTANCE) {
        return null;
    }
    if (PropertiesComponent.getInstance().getBoolean(DONT_ASK_TO_CHANGE_PROVIDER_TYPE_KEY)) {
        return null;
    }
    final MarkdownApplicationSettings markdownApplicationSettings = MarkdownApplicationSettings.getInstance();
    final MarkdownPreviewSettings oldPreviewSettings = markdownApplicationSettings.getMarkdownPreviewSettings();
    if (oldPreviewSettings.getHtmlPanelProviderInfo().getClassName().equals(JavaFxHtmlPanelProvider.class.getName())) {
        return null;
    }
    final MarkdownHtmlPanelProvider.AvailabilityInfo availabilityInfo = new JavaFxHtmlPanelProvider().isAvailable();
    if (availabilityInfo == MarkdownHtmlPanelProvider.AvailabilityInfo.UNAVAILABLE) {
        return null;
    }
    final EditorNotificationPanel panel = new EditorNotificationPanel();
    panel.setText("JavaFX WebKit-based preview renderer is available.");
    panel.createActionLabel("Change preview browser to JavaFX", () -> {
        final boolean isSuccess = availabilityInfo.checkAvailability(panel);
        if (isSuccess) {
            markdownApplicationSettings.setMarkdownPreviewSettings(new MarkdownPreviewSettings(oldPreviewSettings.getSplitEditorLayout(), new JavaFxHtmlPanelProvider().getProviderInfo(), oldPreviewSettings.isUseGrayscaleRendering()));
            EditorNotifications.updateAll();
        } else {
            Logger.getInstance(JavaFxCouldBeEnabledNotificationProvider.class).warn("Could not install and apply OpenJFX");
        }
    });
    panel.createActionLabel("Do not show again", () -> {
        PropertiesComponent.getInstance().setValue(DONT_ASK_TO_CHANGE_PROVIDER_TYPE_KEY, true);
        EditorNotifications.updateAll();
    });
    return panel;
}
Also used : MarkdownApplicationSettings(org.intellij.plugins.markdown.settings.MarkdownApplicationSettings) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) MarkdownHtmlPanelProvider(org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider) MarkdownPreviewSettings(org.intellij.plugins.markdown.settings.MarkdownPreviewSettings) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with MarkdownApplicationSettings

use of org.intellij.plugins.markdown.settings.MarkdownApplicationSettings in project intellij-plugins by JetBrains.

the class JavaFxHtmlPanel method subscribeForGrayscaleSetting.

private void subscribeForGrayscaleSetting() {
    MessageBusConnection settingsConnection = ApplicationManager.getApplication().getMessageBus().connect(this);
    MarkdownApplicationSettings.SettingsChangedListener settingsChangedListener = new MarkdownApplicationSettings.SettingsChangedListener() {

        @Override
        public void onSettingsChange(@NotNull final MarkdownApplicationSettings settings) {
            runInPlatformWhenAvailable(() -> {
                if (myWebView != null) {
                    updateFontSmoothingType(myWebView, settings.getMarkdownPreviewSettings().isUseGrayscaleRendering());
                }
            });
        }
    };
    settingsConnection.subscribe(MarkdownApplicationSettings.SettingsChangedListener.TOPIC, settingsChangedListener);
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) MarkdownApplicationSettings(org.intellij.plugins.markdown.settings.MarkdownApplicationSettings) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MarkdownApplicationSettings (org.intellij.plugins.markdown.settings.MarkdownApplicationSettings)2 EditorNotificationPanel (com.intellij.ui.EditorNotificationPanel)1 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)1 MarkdownPreviewSettings (org.intellij.plugins.markdown.settings.MarkdownPreviewSettings)1 MarkdownHtmlPanelProvider (org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1