Search in sources :

Example 21 with Presentation

use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.

the class RemoveFromIgnoreListAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    presentation.setEnabledAndVisible(true);
    presentation.setText(myActionName);
    presentation.setDescription(SvnBundle.message("action.Subversion.UndoIgnore.description"));
}
Also used : Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 22 with Presentation

use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.

the class IpnbRunCellBaseAction method update.

@Override
public void update(AnActionEvent e) {
    final DataContext context = e.getDataContext();
    final IpnbFileEditor editor = IpnbFileEditor.DATA_KEY.getData(context);
    final Presentation presentation = e.getPresentation();
    presentation.setEnabledAndVisible(editor != null);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 23 with Presentation

use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.

the class MvcActionGroup method update.

@Override
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    Pair<MvcFramework, Module> pair = MvcActionBase.guessFramework(e);
    if (pair != null && pair.first.showActionGroup()) {
        presentation.setVisible(true);
        presentation.setText(pair.getFirst().getDisplayName());
        presentation.setIcon(pair.getFirst().getIcon());
    } else {
        presentation.setVisible(false);
    }
}
Also used : Presentation(com.intellij.openapi.actionSystem.Presentation) Module(com.intellij.openapi.module.Module)

Example 24 with Presentation

use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.

the class AbstractCreateFormAction method update.

public void update(final AnActionEvent e) {
    super.update(e);
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final Presentation presentation = e.getPresentation();
    if (presentation.isEnabled()) {
        final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
        if (view != null) {
            final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
            final PsiDirectory[] dirs = view.getDirectories();
            for (final PsiDirectory dir : dirs) {
                if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && JavaDirectoryService.getInstance().getPackage(dir) != null) {
                    return;
                }
            }
        }
        presentation.setEnabled(false);
        presentation.setVisible(false);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) PsiDirectory(com.intellij.psi.PsiDirectory) Presentation(com.intellij.openapi.actionSystem.Presentation) IdeView(com.intellij.ide.IdeView)

Example 25 with Presentation

use of com.intellij.openapi.actionSystem.Presentation in project intellij-community by JetBrains.

the class CCDeleteAllAnswerPlaceholdersAction method update.

@Override
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    presentation.setEnabledAndVisible(false);
    Project project = e.getProject();
    if (project == null) {
        return;
    }
    if (!CCUtils.isCourseCreator(project)) {
        return;
    }
    DataContext context = e.getDataContext();
    VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
    if (file == null) {
        return;
    }
    TaskFile taskFile = StudyUtils.getTaskFile(project, file);
    if (taskFile == null || taskFile.getAnswerPlaceholders().isEmpty()) {
        return;
    }
    presentation.setEnabledAndVisible(true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Presentation(com.intellij.openapi.actionSystem.Presentation)

Aggregations

Presentation (com.intellij.openapi.actionSystem.Presentation)236 Project (com.intellij.openapi.project.Project)76 VirtualFile (com.intellij.openapi.vfs.VirtualFile)34 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)11 DataContext (com.intellij.openapi.actionSystem.DataContext)10 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)8 AnAction (com.intellij.openapi.actionSystem.AnAction)7 PsiFile (com.intellij.psi.PsiFile)6 IdeView (com.intellij.ide.IdeView)5 ActionManager (com.intellij.openapi.actionSystem.ActionManager)5 Editor (com.intellij.openapi.editor.Editor)5 File (java.io.File)5 Module (com.intellij.openapi.module.Module)4 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)4 PsiDirectory (com.intellij.psi.PsiDirectory)4 Course (com.jetbrains.edu.learning.courseFormat.Course)4 StudyEditor (com.jetbrains.edu.learning.editor.StudyEditor)4 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)3 NotNull (org.jetbrains.annotations.NotNull)3 Before (org.junit.Before)3