@Override public void actionPerformed(AnActionEvent e) { DataContext context = e.getDataContext(); Editor editor = PlatformDataKeys.EDITOR.getData(context); PsiFile psiFile = LangDataKeys.PSI_FILE.getData(context); if (psiFile == null) return; List<GotoRelatedItem> items = getItems(psiFile, editor, context); if (items.isEmpty()) return; if (items.size() == 1 && items.get(0).getElement() != null) { items.get(0).navigate(); return; } if (ApplicationManager.getApplication().isUnitTestMode()) { System.out.println(items); } createPopup(items, "Go to Related Files").showInBestPositionFor(context); }
@Override public void update(AnActionEvent e) { e.getPresentation().setEnabled(LangDataKeys.PSI_FILE.getData(e.getDataContext()) != null); }