@Override public void actionPerformed(AnActionEvent e) { final Project project = e.getData(PlatformDataKeys.PROJECT); if (project == null) return; Runnable searchEverywhere = mySearchEverywhereRunnable; mySearchEverywhereRunnable = null; hideHints(); if (searchEverywhere != null) { searchEverywhere.run(); return; } final RelativePoint popupPosition = JBPopupFactory.getInstance().guessBestPopupLocation(e.getDataContext()); PsiDocumentManager.getInstance(project).commitAllDocuments(); FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.usages"); UsageTarget[] usageTargets = e.getData(UsageView.USAGE_TARGETS_KEY); final Editor editor = e.getData(PlatformDataKeys.EDITOR); if (usageTargets == null) { chooseAmbiguousTargetAndPerform( project, editor, new PsiElementProcessor<PsiElement>() { @Override public boolean execute(@NotNull final PsiElement element) { startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE); return false; } }); } else { PsiElement element = ((PsiElementUsageTarget) usageTargets[0]).getElement(); if (element != null) { startFindUsages(element, popupPosition, editor, USAGES_PAGE_SIZE); } } }
@Override public void update(AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); presentation.setEnabled(allTargetsAreValid()); }
@Override public void update(AnActionEvent e) { super.update(e); e.getPresentation().setVisible(myContent != null); }