Search in sources :

Example 1 with MarkdownHtmlPanelProvider

use of org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider in project intellij-plugins by JetBrains.

the class MarkdownPreviewSettingsForm method createUIComponents.

private void createUIComponents() {
    //noinspection unchecked
    final List<MarkdownHtmlPanelProvider.ProviderInfo> providerInfos = ContainerUtil.mapNotNull(MarkdownHtmlPanelProvider.getProviders(), provider -> {
        if (provider.isAvailable() == MarkdownHtmlPanelProvider.AvailabilityInfo.UNAVAILABLE) {
            return null;
        }
        return provider.getProviderInfo();
    });
    myPreviewPanelModel = new CollectionComboBoxModel<>(providerInfos, providerInfos.get(0));
    myPreviewProvider = new ComboBox(myPreviewPanelModel);
    mySplitLayoutModel = new EnumComboBoxModel<>(SplitFileEditor.SplitEditorLayout.class);
    myDefaultSplitLayout = new ComboBox(mySplitLayoutModel);
    myLastItem = myPreviewProvider.getSelectedItem();
    myPreviewProvider.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            final Object item = e.getItem();
            if (e.getStateChange() != ItemEvent.SELECTED || !(item instanceof MarkdownHtmlPanelProvider.ProviderInfo)) {
                return;
            }
            final MarkdownHtmlPanelProvider provider = MarkdownHtmlPanelProvider.createFromInfo((MarkdownHtmlPanelProvider.ProviderInfo) item);
            final MarkdownHtmlPanelProvider.AvailabilityInfo availability = provider.isAvailable();
            if (!availability.checkAvailability(myMainPanel)) {
                myPreviewProvider.setSelectedItem(myLastItem);
            } else {
                myLastItem = item;
                updateUseGrayscaleEnabled();
            }
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) ComboBox(com.intellij.openapi.ui.ComboBox) ItemListener(java.awt.event.ItemListener) MarkdownHtmlPanelProvider(org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider)

Aggregations

ComboBox (com.intellij.openapi.ui.ComboBox)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 MarkdownHtmlPanelProvider (org.intellij.plugins.markdown.ui.preview.MarkdownHtmlPanelProvider)1