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();
}
}
});
}
Aggregations