@Override public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); presentation.setVisible(false); final DataContext dataContext = e.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project != null) { final RunConfiguration configuration = RunConfiguration.DATA_KEY.getData(dataContext); if (isPatternBasedConfiguration(configuration)) { final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(dataContext); if (testProxy != null) { final Location location = testProxy.getLocation( project, ((T) configuration).getConfigurationModule().getSearchScope()); if (location != null) { final PsiElement psiElement = location.getPsiElement(); if (psiElement instanceof PsiClass && getPattern((T) configuration) .contains(((PsiClass) psiElement).getQualifiedName())) { presentation.setVisible(true); } } } } } }
@Override public void actionPerformed(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); LOG.assertTrue(project != null); final T configuration = (T) RunConfiguration.DATA_KEY.getData(dataContext); LOG.assertTrue(configuration != null); final GlobalSearchScope searchScope = configuration.getConfigurationModule().getSearchScope(); final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(dataContext); LOG.assertTrue(testProxy != null); final String qualifiedName = ((PsiClass) testProxy.getLocation(project, searchScope).getPsiElement()).getQualifiedName(); getPattern(configuration).remove(qualifiedName); }
@Nullable private static Object getSelectedTestProxy(final AnActionEvent e) { return AbstractTestProxy.DATA_KEY.getData(e.getDataContext()); }