use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class GeneratePluginClassAction method update.
public void update(final AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
if (presentation.isEnabled()) {
final Project project = e.getProject();
final Module module = e.getData(LangDataKeys.MODULE);
if (project != null && module != null && PsiUtil.isPluginModule(module)) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view != null) {
// from com.intellij.ide.actions.CreateClassAction.update()
ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
PsiDirectory[] dirs = view.getDirectories();
for (PsiDirectory dir : dirs) {
if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && JavaDirectoryService.getInstance().getPackage(dir) != null) {
return;
}
}
}
}
presentation.setEnabledAndVisible(false);
}
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class RunTargetAction method update.
@Override
public void update(AnActionEvent e) {
super.update(e);
final Presentation presentation = e.getPresentation();
Pair<AntBuildFileBase, AntDomTarget> antTarget = findAntTarget(e);
if (antTarget == null) {
presentation.setEnabled(false);
presentation.setText(AntActionsBundle.message("action.RunTargetAction.text", ""));
} else {
presentation.setEnabled(true);
presentation.setText(AntActionsBundle.message("action.RunTargetAction.text", "'" + antTarget.second.getName().getValue() + "'"));
}
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class StopAction method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
presentation.setEnabled(!myAntBuildMessageView.isStopped());
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class AddAntBuildFile method update.
public void update(@NotNull AnActionEvent e) {
final Presentation presentation = e.getPresentation();
final Project project = e.getProject();
if (project != null) {
final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (files != null && files.length > 0) {
for (VirtualFile file : files) {
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (!(psiFile instanceof XmlFile)) {
continue;
}
final XmlFile xmlFile = (XmlFile) psiFile;
final XmlDocument document = xmlFile.getDocument();
if (document == null) {
continue;
}
final XmlTag rootTag = document.getRootTag();
if (rootTag == null) {
continue;
}
if (!"project".equals(rootTag.getName())) {
continue;
}
if (AntConfigurationBase.getInstance(project).getAntBuildFile(psiFile) != null) {
continue;
}
// found at least one candidate file
enable(presentation);
return;
}
}
}
disable(presentation);
}
use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.
the class AntBuildFilePropertiesAction method update.
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
presentation.setEnabled(myAntExplorer.isBuildFileSelected());
}
Aggregations