public Object getData(String dataId) { if (myTreeBrowser != null && myTreeBrowser.isVisible()) { return null; } if (PlatformDataKeys.NAVIGATABLE.is(dataId)) { if (mySelectedFile == null || !mySelectedFile.isValid()) return null; return new OpenFileDescriptor(myProject, mySelectedFile); } else if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) { return getVirtualFileArray(); } else if (VcsDataKeys.IO_FILE_ARRAY.is(dataId)) { return getFileArray(); } else if (PlatformDataKeys.TREE_EXPANDER.is(dataId)) { if (myGroupByChangeList) { return myTreeBrowser != null ? myTreeBrowser.getTreeExpander() : null; } else { return myTreeExpander; } } else if (VcsDataKeys.UPDATE_VIEW_SELECTED_PATH.is(dataId)) { return mySelectedUrl; } else if (VcsDataKeys.UPDATE_VIEW_FILES_ITERABLE.is(dataId)) { return myTreeIterable; } else if (VcsDataKeys.LABEL_BEFORE.is(dataId)) { return myBefore; } else if (VcsDataKeys.LABEL_AFTER.is(dataId)) { return myAfter; } return super.getData(dataId); }
public void actionPerformed(AnActionEvent e) { final DataContext dc = e.getDataContext(); if ((!isVisible(dc)) || (!isEnabled(dc))) return; final Project project = CommonDataKeys.PROJECT.getData(dc); final Iterable<Pair<VirtualFilePointer, FileStatus>> iterable = VcsDataKeys.UPDATE_VIEW_FILES_ITERABLE.getData(dc); final Label before = (Label) VcsDataKeys.LABEL_BEFORE.getData(dc); final Label after = (Label) VcsDataKeys.LABEL_AFTER.getData(dc); final String selectedUrl = VcsDataKeys.UPDATE_VIEW_SELECTED_PATH.getData(dc); ShowDiffAction.showDiffForChange( new MyIterableWrapper(iterable.iterator(), before, after), new MySelectionMarker(selectedUrl), project, new ShowDiffUIContext(true)); }
private boolean isEnabled(final DataContext dc) { final Iterable<Pair<VirtualFilePointer, FileStatus>> iterable = VcsDataKeys.UPDATE_VIEW_FILES_ITERABLE.getData(dc); return iterable != null; }