protected LanguagePerFileConfigurable(@NotNull Project project, Class<T> valueClass, PerFileMappings<T> mappings, String caption, String treeTableTitle, String overrideQuestion, String overrideTitle) { myProject = project; myValueClass = valueClass; myMappings = mappings; myTreeTableTitle = treeTableTitle; myOverrideQuestion = overrideQuestion; myOverrideTitle = overrideTitle; myLabel.setText(caption); }
@NotNull public static ListPopup forFileLanguages(@NotNull Project project, @NotNull final Iterable<VirtualFile> files, @NotNull final PerFileMappings<Language> mappings) { return forFileLanguages(project, null, new Consumer<Language>() { @Override public void consume(Language t) { for (VirtualFile file : files) { mappings.setMapping(file, t); } } }); }
public static boolean accept(@NotNull final VirtualFile file) { String fileExt = file.getExtension(); FileType fileType = file.getFileType(); boolean doAccept = fileType instanceof MultiMarkdownFileType; if (!doAccept) { doAccept = MultiMarkdownGlobalSettings.getInstance().scratchFileServiceFailed.runBuild(new FailedBuildRunnable<Boolean>() { @Nullable @Override public Boolean runCanFail() throws Throwable { // Issue: #14 scratch files have to be matched differently ScratchFileService fileService = ScratchFileService.getInstance(); PerFileMappings<Language> scratchesMapping = fileService.getScratchesMapping(); Language language = scratchesMapping.getMapping(file); return language instanceof MultiMarkdownLanguage; //// Issue: #15 class not found ScratchFileService, so we take care of it through reflection //Class<?> ScratchFileService = Class.forName("com.intellij.ide.scratch.ScratchFileService"); //Method getInstance = ScratchFileService.getMethod("getInstance"); //Method getScratchesMapping = ScratchFileService.getMethod("getScratchesMapping"); //Object fileService = getInstance.invoke(ScratchFileService); //PerFileMappings<Language> mappings = (PerFileMappings<Language>) getScratchesMapping.invoke(fileService); //Language language = mappings.getMapping(file); //return language instanceof MultiMarkdownLanguage; } @Nullable @Override public Boolean run() { return false; } }); } return doAccept; }
protected LanguagePerFileConfigurable(@Nonnull Project project, Class<T> valueClass, PerFileMappings<T> mappings, String caption, String treeTableTitle, String overrideQuestion, String overrideTitle) { myProject = project; myValueClass = valueClass; myMappings = mappings; myTreeTableTitle = treeTableTitle; myOverrideQuestion = overrideQuestion; myOverrideTitle = overrideTitle; myLabel.setText(caption); }
@NotNull public abstract PerFileMappings<Language> getScratchesMapping();
protected void actionPerformedImpl(AnActionEvent e, Project project, JBIterable<VirtualFile> files) { ScratchFileService fileService = ScratchFileService.getInstance(); PerFileMappings<Language> mapping = fileService.getScratchesMapping(); LRUPopupBuilder.forFileLanguages(project, files, mapping).showInBestPositionFor(e.getDataContext()); }
@NotNull @Override public PerFileMappings<Language> getScratchesMapping() { return myScratchMapping; }
@Nonnull public abstract PerFileMappings<Language> getScratchesMapping();
@Nonnull @Override public PerFileMappings<Language> getScratchesMapping() { return myScratchMapping; }