Search in sources :

Example 46 with Presentation

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

the class HideToolWindowAction method update.

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    Project project = event.getProject();
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }
    ToolWindowManagerEx toolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
    String id = toolWindowManager.getActiveToolWindowId();
    if (id == null) {
        id = toolWindowManager.getLastActiveToolWindowId();
    }
    presentation.setEnabled(shouldBeHiddenByShortCut(toolWindowManager, id));
}
Also used : Project(com.intellij.openapi.project.Project) Presentation(com.intellij.openapi.actionSystem.Presentation) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Example 47 with Presentation

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

the class OpenSelectedProjectsAction method update.

@Override
public void update(AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    List<AnAction> selectedElements = getSelectedElements(e);
    boolean hasProject = false;
    boolean hasGroup = false;
    for (AnAction element : selectedElements) {
        if (element instanceof ReopenProjectAction) {
            hasProject = true;
        }
        if (element instanceof ProjectGroupActionGroup) {
            hasGroup = true;
        }
        if (hasGroup && hasProject) {
            e.getPresentation().setEnabled(false);
            return;
        }
    }
    if (ActionPlaces.WELCOME_SCREEN.equals(e.getPlace())) {
        presentation.setEnabledAndVisible(true);
        if (selectedElements.size() == 1 && selectedElements.get(0) instanceof ProjectGroupActionGroup) {
            presentation.setText("Open All Projects in Group");
        } else {
            presentation.setText("Open Selected");
        }
    } else {
        presentation.setEnabledAndVisible(false);
    }
}
Also used : ReopenProjectAction(com.intellij.ide.ReopenProjectAction) ProjectGroupActionGroup(com.intellij.ide.ProjectGroupActionGroup) Presentation(com.intellij.openapi.actionSystem.Presentation) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 48 with Presentation

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

the class StartUseVcsAction method update.

@Override
public void update(final AnActionEvent e) {
    final VcsDataWrapper data = new VcsDataWrapper(e);
    final boolean enabled = data.enabled();
    final Presentation presentation = e.getPresentation();
    presentation.setEnabled(enabled);
    presentation.setVisible(enabled);
    if (enabled) {
        presentation.setText(VcsBundle.message("action.enable.version.control.integration.text"));
    }
}
Also used : Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 49 with Presentation

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

the class ShowHideRecycledAction method update.

@Override
public void update(@NotNull final AnActionEvent e) {
    super.update(e);
    final Project project = getEventProject(e);
    final Presentation presentation = e.getPresentation();
    presentation.setEnabledAndVisible(project != null);
    if (project != null) {
        final boolean fromContextMenu = ShelvedChangesViewManager.SHELF_CONTEXT_MENU.equals(e.getPlace());
        presentation.setText(ShelveChangesManager.getInstance(project).isShowRecycled() && !fromContextMenu ? "Hide Already Unshelved" : "Show Already Unshelved");
        presentation.setIcon(fromContextMenu ? null : AllIcons.Vcs.Patch_applied);
    }
}
Also used : Project(com.intellij.openapi.project.Project) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 50 with Presentation

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

the class CleanUnshelvedAction method update.

@Override
public void update(@NotNull final AnActionEvent e) {
    super.update(e);
    final Project project = getEventProject(e);
    final Presentation presentation = e.getPresentation();
    if (project == null) {
        presentation.setEnabledAndVisible(false);
        return;
    }
    presentation.setVisible(true);
    presentation.setEnabled(!ShelveChangesManager.getInstance(project).getRecycledShelvedChangeLists().isEmpty());
}
Also used : Project(com.intellij.openapi.project.Project) 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