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

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

Introduction

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

Prototype

public static boolean isPopupPlace(@NotNull String place) 

Source Link

Usage

From source file:com.google.gct.idea.appengine.action.NewEndpointFromClassAction.java

License:Apache License

@Override
public void update(AnActionEvent e) {
    if (ActionPlaces.isPopupPlace(e.getPlace())) {
        e.getPresentation().setVisible(shouldDisplayAction(e));
    }
}

From source file:com.intellij.codeInsight.actions.GenerateDTDAction.java

License:Apache License

public void update(AnActionEvent event) {
    super.update(event);
    if (ActionPlaces.isPopupPlace(event.getPlace())) {
        Presentation presentation = event.getPresentation();
        presentation.setVisible(presentation.isEnabled());
    }//from   www . j  a v a  2  s . c  o  m
}

From source file:com.intellij.codeInspection.i18n.I18nizeAction.java

License:Apache License

@Override
public void update(AnActionEvent e) {
    boolean active = getHandler(e) != null;
    if (ActionPlaces.isPopupPlace(e.getPlace())) {
        e.getPresentation().setVisible(active);
    } else {/*from   www.  j ava 2  s.  c o m*/
        e.getPresentation().setEnabled(active);
    }
}

From source file:com.intellij.compiler.actions.CompileAction.java

License:Apache License

public void update(AnActionEvent event) {
    super.update(event);
    Presentation presentation = event.getPresentation();
    if (!presentation.isEnabled()) {
        return;/*w  ww .j  a  v a  2s  . co m*/
    }
    DataContext dataContext = event.getDataContext();

    presentation.setText(ActionsBundle.actionText(IdeActions.ACTION_COMPILE));
    presentation.setVisible(true);

    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        presentation.setEnabled(false);
        return;
    }

    final Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext);

    final VirtualFile[] files = getCompilableFiles(project,
            PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext));
    if (module == null && files.length == 0) {
        presentation.setEnabled(false);
        presentation.setVisible(!ActionPlaces.isPopupPlace(event.getPlace()));
        return;
    }

    String elementDescription = null;
    if (module != null) {
        elementDescription = CompilerBundle.message("action.compile.description.module", module.getName());
    } else {
        PsiPackage aPackage = null;
        if (files.length == 1) {
            final PsiDirectory directory = PsiManager.getInstance(project).findDirectory(files[0]);
            if (directory != null) {
                aPackage = PsiPackageManager.getInstance(project).findAnyPackage(directory);
            }
        } else {
            PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
            if (element instanceof PsiPackage) {
                aPackage = (PsiPackage) element;
            }
        }

        if (aPackage != null) {
            String name = aPackage.getQualifiedName();
            if (name.length() == 0) {
                //noinspection HardCodedStringLiteral
                name = "<default>";
            }
            elementDescription = "'" + name + "'";
        } else if (files.length == 1) {
            final VirtualFile file = files[0];
            FileType fileType = file.getFileType();
            if (CompilerManager.getInstance(project).isCompilableFileType(fileType)
                    || isCompilableResourceFile(project, file)) {
                elementDescription = "'" + file.getName() + "'";
            } else {
                if (!ActionPlaces.MAIN_MENU.equals(event.getPlace())) {
                    // the action should be invisible in popups for non-java files
                    presentation.setEnabled(false);
                    presentation.setVisible(false);
                    return;
                }
            }
        } else {
            elementDescription = CompilerBundle.message("action.compile.description.selected.files");
        }
    }

    if (elementDescription == null) {
        presentation.setEnabled(false);
        return;
    }

    presentation.setText(createPresentationText(elementDescription), true);
    presentation.setEnabled(true);
}

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

License:Apache License

public void update(AnActionEvent event) {
    boolean toEnable = getPlace(event) != null;

    if (ActionPlaces.isPopupPlace(event.getPlace())) {
        event.getPresentation().setVisible(toEnable);
    } else {//from   w  ww  .  j av a2  s.  co m
        event.getPresentation().setEnabled(toEnable);
    }
}

From source file:com.intellij.diff.actions.BaseShowDiffAction.java

License:Apache License

@Override
public void update(@NotNull AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    boolean canShow = isAvailable(e);
    if (ActionPlaces.isPopupPlace(e.getPlace())) {
        presentation.setVisible(canShow);
    } else {/*  w  w w. j  av  a 2 s.com*/
        presentation.setVisible(true);
        presentation.setEnabled(canShow);
    }
}

From source file:com.intellij.find.actions.FindInPathAction.java

License:Apache License

static void doUpdate(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    Project project = e.getData(CommonDataKeys.PROJECT);
    presentation.setEnabled(project != null);
    if (ActionPlaces.isPopupPlace(e.getPlace())) {
        presentation.setVisible(isValidSearchScope(e));
    }/*from w ww  . j a  va  2 s . c o  m*/
}

From source file:com.intellij.find.actions.FindUsagesInFileAction.java

License:Apache License

public static void updateFindUsagesAction(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    boolean enabled = isEnabled(dataContext);
    presentation.setVisible(enabled || !ActionPlaces.isPopupPlace(event.getPlace()));
    presentation.setEnabled(enabled);/*from   www .  j a  va2s.  co  m*/
}

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

License:Apache License

public void update(AnActionEvent event) {
    DataContext dataContext = event.getDataContext();
    final Navigatable target = getTarget(dataContext);
    boolean enabled = target != null;
    if (ActionPlaces.isPopupPlace(event.getPlace())) {
        event.getPresentation().setVisible(enabled);
    } else {//from  w  ww .  ja  v a 2  s.c om
        event.getPresentation().setEnabled(enabled);
    }
    if (target != null && target instanceof NavigatableWithText) {
        //as myFocusEditor is always ignored - Main Menu|View always contains 2 actions with the same name and actually same behaviour
        if (!myFocusEditor) {
            event.getPresentation().setVisible(false);
            return;
        }
        final String navigateActionText = ((NavigatableWithText) target).getNavigateActionText(myFocusEditor);
        if (navigateActionText != null) {
            event.getPresentation().setText(navigateActionText);
        } else {
            event.getPresentation().setText(getTemplatePresentation().getText());
        }
    } else {
        event.getPresentation().setText(getTemplatePresentation().getText());
    }
}

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

License:Apache License

public void update(final AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    final DataContext dataContext = event.getDataContext();
    final EditorWindow editorWindow = EditorWindow.DATA_KEY.getData(dataContext);
    final boolean inSplitter = editorWindow != null && editorWindow.inSplitter();
    presentation.setText(getPresentationText(inSplitter));
    final Project project = event.getData(CommonDataKeys.PROJECT);
    boolean enabled = (project != null && isActionEnabled(project, event));
    if (ActionPlaces.isPopupPlace(event.getPlace())) {
        presentation.setVisible(enabled);
    } else {/*from   www  .  ja  v a  2s  .  c  om*/
        presentation.setEnabled(enabled);
    }
}