Search in sources :

Example 1 with MarkdownPreviewSettings

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

the class MarkdownPreviewFileEditor method retrievePanelProvider.

@Nullable("Null means leave current panel")
private MarkdownHtmlPanelProvider retrievePanelProvider(@NotNull MarkdownApplicationSettings settings) {
    final MarkdownHtmlPanelProvider.ProviderInfo providerInfo = settings.getMarkdownPreviewSettings().getHtmlPanelProviderInfo();
    if (providerInfo.equals(myLastPanelProviderInfo)) {
        return null;
    }
    MarkdownHtmlPanelProvider provider = MarkdownHtmlPanelProvider.createFromInfo(providerInfo);
    if (provider.isAvailable() != MarkdownHtmlPanelProvider.AvailabilityInfo.AVAILABLE) {
        settings.setMarkdownPreviewSettings(new MarkdownPreviewSettings(settings.getMarkdownPreviewSettings().getSplitEditorLayout(), MarkdownPreviewSettings.DEFAULT.getHtmlPanelProviderInfo(), settings.getMarkdownPreviewSettings().isUseGrayscaleRendering()));
        Messages.showMessageDialog(myHtmlPanelWrapper, "Tried to use preview panel provider (" + providerInfo.getName() + "), but it is unavailable. Reverting to default.", CommonBundle.getErrorTitle(), Messages.getErrorIcon());
        provider = MarkdownHtmlPanelProvider.getProviders()[0];
    }
    myLastPanelProviderInfo = settings.getMarkdownPreviewSettings().getHtmlPanelProviderInfo();
    return provider;
}
Also used : MarkdownPreviewSettings(org.intellij.plugins.markdown.settings.MarkdownPreviewSettings) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with MarkdownPreviewSettings

use of org.intellij.plugins.markdown.settings.MarkdownPreviewSettings 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)

Aggregations

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