Example usage for com.intellij.openapi.actionSystem ActionPlaces isMainMenuOrActionSearch

List of usage examples for com.intellij.openapi.actionSystem ActionPlaces isMainMenuOrActionSearch

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem ActionPlaces isMainMenuOrActionSearch.

Prototype

public static boolean isMainMenuOrActionSearch(String place) 

Source Link

Usage

From source file:com.google.idea.blaze.base.buildmap.OpenCorrespondingBuildFile.java

License:Open Source License

@Override
protected void doUpdate(@NotNull AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    DataContext dataContext = e.getDataContext();
    VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    boolean visible = (project != null && virtualFile != null);
    boolean enabled = getBuildFile(project, virtualFile) != null;
    presentation.setVisible(visible || ActionPlaces.isMainMenuOrActionSearch(e.getPlace()));
    presentation.setEnabled(enabled);/*from  ww  w . j av  a  2  s.c om*/
}

From source file:com.google.idea.blaze.base.ide.NewBlazeRuleAction.java

License:Open Source License

@Override
protected void doUpdate(@NotNull AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    boolean enabled = (project != null && file != null
            && Blaze.getBuildSystemProvider(project).isBuildFile(file.getName()));
    presentation.setVisible(enabled || ActionPlaces.isMainMenuOrActionSearch(event.getPlace()));
    presentation.setEnabled(enabled);/*from w w w  . j av  a 2 s.  c o m*/
    presentation.setText(getText(project));
}

From source file:com.intellij.debugger.actions.ForceEarlyReturnAction.java

License:Apache License

public void update(@NotNull AnActionEvent e) {
    boolean enable = false;

    JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e);
    if (stackFrame != null && stackFrame.getDescriptor().getUiIndex() == 0) {
        enable = stackFrame.getStackFrameProxy().getVirtualMachine().canForceEarlyReturn();
    }//www .j av a  2s .  c  o m

    if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())
            || ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) {
        e.getPresentation().setEnabled(enable);
    } else {
        e.getPresentation().setVisible(enable);
    }
}

From source file:com.intellij.execution.actions.RunConfigurationsComboBoxAction.java

License:Apache License

@RequiredDispatchThread
@Override//from ww  w .  j a  v a2s  .com
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) {
        presentation.setDescription(ExecutionBundle.message("choose.run.configuration.action.description"));
    }
    try {
        if (project == null || project.isDisposed() || !project.isInitialized()) {
            updatePresentation(null, null, null, presentation);
            presentation.setEnabled(false);
        } else {
            updatePresentation(ExecutionTargetManager.getActiveTarget(project),
                    RunManagerEx.getInstanceEx(project).getSelectedConfiguration(), project, presentation);
            presentation.setEnabled(true);
        }
    } catch (IndexNotReadyException e1) {
        presentation.setEnabled(false);
    }
}

From source file:com.intellij.ide.actions.ExternalJavaDocAction.java

License:Apache License

@Override
public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    PsiElement element = getElement(dataContext, editor);
    final PsiElement originalElement = getOriginalElement(CommonDataKeys.PSI_FILE.getData(dataContext), editor);
    DocumentationManager.storeOriginalElement(CommonDataKeys.PROJECT.getData(dataContext), originalElement,
            element);// w w w.j a va  2  s .  c  o m
    final DocumentationProvider provider = DocumentationManager.getProviderFromElement(element);
    boolean enabled;
    if (provider instanceof ExternalDocumentationProvider) {
        final ExternalDocumentationProvider edProvider = (ExternalDocumentationProvider) provider;
        enabled = edProvider.hasDocumentationFor(element, originalElement)
                || edProvider.canPromptToConfigureDocumentation(element);
    } else {
        final List<String> urls = provider.getUrlFor(element, originalElement);
        enabled = urls != null && !urls.isEmpty();
    }
    if (editor != null) {
        presentation.setEnabled(enabled);
        if (ActionPlaces.isMainMenuOrActionSearch(event.getPlace())) {
            presentation.setVisible(true);
        } else {
            presentation.setVisible(enabled);
        }
    } else {
        presentation.setEnabled(enabled);
        presentation.setVisible(true);
    }
}

From source file:io.flutter.run.FlutterPopFrameAction.java

License:Open Source License

public void update(@NotNull AnActionEvent e) {
    final DartVmServiceStackFrame frame = getStackFrame(e);
    final boolean enabled = frame != null && frame.canDrop();

    if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())
            || ActionPlaces.DEBUGGER_TOOLBAR.equals(e.getPlace())) {
        e.getPresentation().setEnabled(enabled);
    } else {//from w ww . j  a v a  2 s  .  co  m
        e.getPresentation().setVisible(enabled);
    }
}

From source file:org.sonarlint.intellij.actions.SonarAnalyzeEditorFileAction.java

License:Open Source License

/**
 * Whether the analysis should be lauched in the background.
 * Analysis should be run in background in the following cases:
 *  - Keybinding used (place = MainMenu)
 *  - Macro used (place = unknown)/* ww w. j ava2 s.c  o m*/
 *  - Action used, ctrl+shift+A (place = GoToAction)
 */
private static boolean executeBackground(AnActionEvent e) {
    return ActionPlaces.isMainMenuOrActionSearch(e.getPlace()) || ActionPlaces.UNKNOWN.equals(e.getPlace());
}