void (@NotNull AnActionEvent event) { Presentation presentation = event.getPresentation(); PsiElement psiElement = event.getData(CommonDataKeys.PSI_FILE); boolean visible = psiElement instanceof XmlFile; presentation.setVisible(visible); boolean enabled = psiElement instanceof XmlFile; if (enabled) { final PsiFile containingFile = psiElement.getContainingFile(); if (containingFile != null && containingFile.getVirtualFile() != null && (containingFile.getFileType() == XmlFileType.INSTANCE || containingFile.getFileType() == XHtmlFileType.INSTANCE )) { enabled = containingFile.getUserData(runningValidationKey) == null; } else { enabled = false; } } presentation.setEnabled(enabled); if (ActionPlaces.isPopupPlace(event.getPlace())) { presentation.setVisible(enabled); } }