Search in sources :

Example 26 with Presentation

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

the class StudyCheckAction method updateDescription.

private static void updateDescription(AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    final Project project = e.getProject();
    if (project != null) {
        final StudyEditor studyEditor = StudyUtils.getSelectedStudyEditor(project);
        if (studyEditor != null) {
            final Task task = studyEditor.getTaskFile().getTask();
            if (task.isTheoryTask()) {
                presentation.setText(getTextWithShortcuts("Get Next Recommendation"));
            } else {
                presentation.setText(getTextWithShortcuts(TEXT));
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) Task(com.jetbrains.edu.learning.courseFormat.Task) StudyEditor(com.jetbrains.edu.learning.editor.StudyEditor) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 27 with Presentation

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

the class StudyFillPlaceholdersAction method update.

@Override
public void update(AnActionEvent e) {
    StudyUtils.updateAction(e);
    final Project project = e.getProject();
    if (project != null) {
        Course course = StudyTaskManager.getInstance(project).getCourse();
        Presentation presentation = e.getPresentation();
        if (course != null && !EduNames.STUDY.equals(course.getCourseMode())) {
            presentation.setEnabled(false);
            presentation.setVisible(true);
            return;
        }
        StudyEditor studyEditor = StudyUtils.getSelectedStudyEditor(project);
        StudyState studyState = new StudyState(studyEditor);
        if (!studyState.isValid()) {
            presentation.setEnabledAndVisible(false);
            return;
        }
        TaskFile taskFile = studyState.getTaskFile();
        if (taskFile.getActivePlaceholders().isEmpty()) {
            presentation.setEnabledAndVisible(false);
        }
    }
}
Also used : TaskFile(com.jetbrains.edu.learning.courseFormat.TaskFile) Project(com.intellij.openapi.project.Project) StudyState(com.jetbrains.edu.learning.StudyState) StudyEditor(com.jetbrains.edu.learning.editor.StudyEditor) Course(com.jetbrains.edu.learning.courseFormat.Course) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 28 with Presentation

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

the class ThumbnailViewActionUtil method setEnabled.

/**
     * Enable or disable current action from event.
     *
     * @param e Action event
     * @return Enabled value
     */
public static boolean setEnabled(AnActionEvent e) {
    ThumbnailView thumbnailView = getVisibleThumbnailView(e);
    Presentation presentation = e.getPresentation();
    presentation.setEnabled(thumbnailView != null);
    return presentation.isEnabled();
}
Also used : ThumbnailView(org.intellij.images.thumbnail.ThumbnailView) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 29 with Presentation

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

the class InterruptThreadAction method update.

public void update(AnActionEvent e) {
    final DebuggerTreeNodeImpl[] selectedNodes = getSelectedNodes(e.getDataContext());
    boolean visible = false;
    boolean enabled = false;
    if (selectedNodes != null && selectedNodes.length > 0) {
        visible = true;
        enabled = true;
        for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
            final NodeDescriptorImpl threadDescriptor = selectedNode.getDescriptor();
            if (!(threadDescriptor instanceof ThreadDescriptorImpl)) {
                visible = false;
                break;
            }
        }
        if (visible) {
            for (DebuggerTreeNodeImpl selectedNode : selectedNodes) {
                final ThreadDescriptorImpl threadDescriptor = (ThreadDescriptorImpl) selectedNode.getDescriptor();
                if (threadDescriptor.isFrozen() || threadDescriptor.isSuspended()) {
                    enabled = false;
                    break;
                }
            }
        }
    }
    final Presentation presentation = e.getPresentation();
    presentation.setText(DebuggerBundle.message("action.interrupt.thread.text"));
    presentation.setEnabledAndVisible(visible && enabled);
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) Presentation(com.intellij.openapi.actionSystem.Presentation) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Example 30 with Presentation

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

the class ThreadDumpAction method update.

public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    Project project = e.getProject();
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    DebuggerSession debuggerSession = (DebuggerManagerEx.getInstanceEx(project)).getContext().getDebuggerSession();
    presentation.setEnabled(debuggerSession != null && debuggerSession.isAttached());
}
Also used : Project(com.intellij.openapi.project.Project) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) 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