Search in sources :

Example 51 with Presentation

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

the class DetachExternalProjectAction method update.

@Override
public void update(@NotNull AnActionEvent e) {
    super.update(e);
    if (this.getClass() != DetachExternalProjectAction.class)
        return;
    ProjectSystemId systemId = getSystemId(e);
    final String systemIdName = systemId != null ? systemId.getReadableName() : "external";
    Presentation presentation = e.getPresentation();
    presentation.setText(ExternalSystemBundle.message("action.detach.external.project.text", systemIdName));
}
Also used : ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 52 with Presentation

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

the class MarkObjectAction method update.

@Override
public void update(AnActionEvent event) {
    Project project = event.getData(CommonDataKeys.PROJECT);
    boolean enabled = false;
    Presentation presentation = event.getPresentation();
    boolean hidden = true;
    if (project != null) {
        for (DebuggerSupport support : DebuggerSupport.getDebuggerSupports()) {
            MarkObjectActionHandler handler = support.getMarkObjectHandler();
            hidden &= handler.isHidden(project, event);
            if (handler.isEnabled(project, event)) {
                enabled = true;
                String text;
                if (handler.isMarked(project, event)) {
                    text = ActionsBundle.message("action.Debugger.MarkObject.unmark.text");
                } else {
                    text = ActionsBundle.message("action.Debugger.MarkObject.text");
                }
                presentation.setText(text);
                break;
            }
        }
    }
    presentation.setVisible(!hidden && (!ActionPlaces.isPopupPlace(event.getPlace()) || enabled));
    presentation.setEnabled(enabled);
}
Also used : Project(com.intellij.openapi.project.Project) Presentation(com.intellij.openapi.actionSystem.Presentation) DebuggerSupport(com.intellij.xdebugger.impl.DebuggerSupport)

Example 53 with Presentation

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

the class ShowLibraryFramesAction method update.

@Override
public void update(@NotNull final AnActionEvent e) {
    super.update(e);
    Presentation presentation = e.getPresentation();
    Object isSupported = presentation.getClientProperty(IS_LIBRARY_FRAME_FILTER_SUPPORTED);
    XDebugSession session = e.getData(XDebugSession.DATA_KEY);
    if (isSupported == null) {
        if (session == null) {
            // if session is null and isSupported is null - just return, it means that action created initially not in the xdebugger tab
            presentation.setVisible(false);
            return;
        }
        isSupported = session.getDebugProcess().isLibraryFrameFilterSupported();
        presentation.putClientProperty(IS_LIBRARY_FRAME_FILTER_SUPPORTED, isSupported);
    }
    if (Boolean.TRUE.equals(isSupported)) {
        presentation.setVisible(true);
        final boolean shouldShow = !Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY));
        presentation.setText(shouldShow ? ourTextWhenShowIsOn : ourTextWhenShowIsOff);
    } else {
        presentation.setVisible(false);
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 54 with Presentation

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

the class GenerateCoverageReportAction method update.

public void update(final AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();
    presentation.setEnabled(false);
    presentation.setVisible(false);
    final Project project = e.getProject();
    if (project != null) {
        final CoverageSuitesBundle currentSuite = CoverageDataManager.getInstance(project).getCurrentSuitesBundle();
        if (currentSuite != null) {
            final CoverageEngine coverageEngine = currentSuite.getCoverageEngine();
            if (coverageEngine.isReportGenerationAvailable(project, dataContext, currentSuite)) {
                presentation.setEnabled(true);
                presentation.setVisible(true);
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Presentation(com.intellij.openapi.actionSystem.Presentation) CoverageEngine(com.intellij.coverage.CoverageEngine) CoverageSuitesBundle(com.intellij.coverage.CoverageSuitesBundle)

Example 55 with Presentation

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

the class ImportTree method createIncludeAction.

public AnAction createIncludeAction() {
    return new AnAction(CvsBundle.message("import.wizard.include.to.import.action.name"), null, IconUtil.getAddIcon()) {

        public void update(AnActionEvent e) {
            final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
            final Presentation presentation = e.getPresentation();
            presentation.setEnabled(isAtLeastOneFileExcluded(selectedFiles));
        }

        public void actionPerformed(AnActionEvent e) {
            final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
            for (VirtualFile selectedFile : selectedFiles) {
                include(selectedFile);
            }
            myWizard.updateStep();
            myFileSystemTree.getTree().repaint();
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Presentation(com.intellij.openapi.actionSystem.Presentation) AnAction(com.intellij.openapi.actionSystem.AnAction)

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