@Override public void actionPerformed(AnActionEvent e) { final Project project = getEventProject(e); final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY); FeatureUsageTracker.getInstance().triggerFeatureUsed("jar.diff"); if (project != null && files != null) { VirtualFileDiffElement src = null; VirtualFileDiffElement trg = null; if (files.length == 2 && isArchive(files[0]) && isArchive(files[1])) { src = new JarFileDiffElement(files[0]); trg = new JarFileDiffElement(files[1]); } else if (files.length == 1 && isArchive(files[0])) { src = new JarFileDiffElement(files[0]); final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, true, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return file.isDirectory() || (!file.isDirectory() && isArchive(file)); } }; final VirtualFile[] result = FileChooser.chooseFiles(descriptor, project, project.getBaseDir()); if (result.length == 1 && result[0] != null && isArchive(result[0])) { trg = new JarFileDiffElement(result[0]); } } final DirDiffManager mgr = DirDiffManager.getInstance(project); if (src != null && trg != null && mgr.canShow(src, trg)) { mgr.showDiff(src, trg, new DirDiffSettings(), null); } } }
@Override public void show(DiffRequest request) { final DiffContent[] contents = request.getContents(); final VirtualFile file1 = contents[0].getFile(); final VirtualFile file2 = contents[1].getFile(); assert file1 != null && file2 != null; final JarFileDiffElement element = new JarFileDiffElement(file1); final JarFileDiffElement element1 = new JarFileDiffElement(file2); final DirDiffSettings settings = new DirDiffSettings(); settings.showInFrame = false; settings.enableChoosers = false; DirDiffManager.getInstance(request.getProject()).showDiff(element, element1, settings); }