com.intellij.openapi.fileTypes.FileTypeFactory Java Examples
The following examples show how to use
com.intellij.openapi.fileTypes.FileTypeFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginAdvertiserEditorNotificationProvider.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction @Nullable @Override public EditorNotificationPanel createNotificationPanel(@Nonnull VirtualFile file, @Nonnull FileEditor fileEditor) { if (file.getFileType() != PlainTextFileType.INSTANCE && !(file.getFileType() instanceof AbstractFileType)) return null; final String extension = file.getExtension(); if (extension == null) { return null; } if (myEnabledExtensions.contains(extension) || isIgnoredFile(file)) return null; UnknownExtension fileFeatureForChecking = new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), file.getName()); List<PluginDescriptor> allPlugins = PluginsAdvertiserHolder.getLoadedPluginDescriptors(); Set<PluginDescriptor> byFeature = PluginsAdvertiser.findByFeature(allPlugins, fileFeatureForChecking); if (!byFeature.isEmpty()) { return createPanel(file, byFeature); } return null; }
Example #2
Source File: PluginAdvertiserEditorNotificationProvider.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private EditorNotificationPanel createPanel(VirtualFile virtualFile, Set<PluginDescriptor> plugins) { String extension = virtualFile.getExtension(); final EditorNotificationPanel panel = new EditorNotificationPanel(); panel.setText(IdeBundle.message("plugin.advestiser.notification.text", plugins.size())); final PluginDescriptor disabledPlugin = getDisabledPlugin(plugins.stream().map(x -> x.getPluginId().getIdString()).collect(Collectors.toSet())); if (disabledPlugin != null) { panel.createActionLabel("Enable " + disabledPlugin.getName() + " plugin", () -> { myEnabledExtensions.add(extension); consulo.container.plugin.PluginManager.enablePlugin(disabledPlugin.getPluginId().getIdString()); myNotifications.updateAllNotifications(); PluginManagerMain.notifyPluginsWereUpdated("Plugin was successfully enabled", null); }); } else { panel.createActionLabel(IdeBundle.message("plugin.advestiser.notification.install.link", plugins.size()), () -> { final PluginsAdvertiserDialog advertiserDialog = new PluginsAdvertiserDialog(null, new ArrayList<>(plugins)); advertiserDialog.show(); if (advertiserDialog.isUserInstalledPlugins()) { myEnabledExtensions.add(extension); myNotifications.updateAllNotifications(); } }); } panel.createActionLabel("Ignore by file name", () -> { myUnknownFeaturesCollector.ignoreFeature(new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, virtualFile.getName())); myNotifications.updateAllNotifications(); }); panel.createActionLabel("Ignore by extension", () -> { myUnknownFeaturesCollector.ignoreFeature(new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, "*." + virtualFile.getExtension())); myNotifications.updateAllNotifications(); }); return panel; }
Example #3
Source File: PluginAdvertiserEditorNotificationProvider.java From consulo with Apache License 2.0 | 5 votes |
private boolean isIgnoredFile(@Nonnull VirtualFile virtualFile) { UnknownExtension extension = new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, "*." + virtualFile.getExtension()); if(myUnknownFeaturesCollector.isIgnored(extension)) { return true; } extension = new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, virtualFile.getName()); if(myUnknownFeaturesCollector.isIgnored(extension)) { return true; } return false; }
Example #4
Source File: PluginsAdvertiser.java From consulo with Apache License 2.0 | 5 votes |
private static boolean isMyFeature(String extensionValue, UnknownExtension feature) { if (feature.getExtensionKey().equals(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName())) { FileNameMatcher matcher = createMatcher(extensionValue); return matcher != null && matcher.accept(feature.getValue()); } else { return extensionValue.equals(feature.getValue()); } }