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

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

Introduction

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

Prototype

String EDITOR_POPUP

To view the source code for com.intellij.openapi.actionSystem ActionPlaces EDITOR_POPUP.

Click Source Link

Usage

From source file:cn.fishy.plugin.idea.ponytail.Console.java

License:Apache License

private Editor createLogEditor() {
    final Editor editor = ConsoleViewUtil.setupConsoleEditor(project, false, false);
    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);

    final ClearLogAction clearLog = new ClearLogAction(this);
    clearLog.registerCustomShortcutSet(/* w  w  w .jav a 2  s  . c o m*/
            ActionManager.getInstance().getAction(IdeActions.CONSOLE_CLEAR_ALL).getShortcutSet(),
            editor.getContentComponent());

    final EditorMouseListener listener = new EditorPopupHandler() {
        public void invokePopup(final EditorMouseEvent event) {
            final ActionManager actionManager = ActionManager.getInstance();
            final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP,
                    createPopupActions(actionManager, clearLog));
            final MouseEvent mouseEvent = event.getMouseEvent();
            menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
        }
    };
    editor.addEditorMouseListener(listener);
    /*Disposer.register(this, new Disposable() {
    @Override
    public void dispose() {
        EditorFactory.getInstance().releaseEditor(editor);
    }
    });*/
    return editor;
}

From source file:com.headwire.aem.tooling.intellij.console.ConsoleLogConsole.java

License:Apache License

private Editor createLogEditor() {
    Project project = myProjectModel.getProject();
    final Editor editor = ConsoleViewUtil.setupConsoleEditor(project, false, false);
    myProjectModel.getProject().getMessageBus().connect().subscribe(ProjectManager.TOPIC,
            new ProjectManagerAdapter() {
                @Override//from  w  w w .  j  av a  2  s .c  o m
                public void projectClosed(Project project) {
                    if (project == myProjectModel.getProject()) {
                        EditorFactory.getInstance().releaseEditor(editor);
                    }
                }
            });

    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);

    final ClearLogAction clearLog = new ClearLogAction(this);
    clearLog.registerCustomShortcutSet(
            ActionManager.getInstance().getAction(IdeActions.CONSOLE_CLEAR_ALL).getShortcutSet(),
            editor.getContentComponent());

    editor.addEditorMouseListener(new EditorPopupHandler() {
        public void invokePopup(final EditorMouseEvent event) {
            final ActionManager actionManager = ActionManager.getInstance();
            final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP,
                    createPopupActions(actionManager, clearLog));
            final MouseEvent mouseEvent = event.getMouseEvent();
            menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
        }
    });
    return editor;
}

From source file:com.intellij.execution.impl.ConsoleViewImpl.java

License:Apache License

private void popupInvoked(MouseEvent mouseEvent) {
    final ActionManager actionManager = ActionManager.getInstance();
    final HyperlinkInfo info = myHyperlinks != null
            ? myHyperlinks.getHyperlinkInfoByPoint(mouseEvent.getPoint())
            : null;//from  ww w  .ja va 2 s.c  o m
    ActionGroup group = null;
    if (info instanceof HyperlinkWithPopupMenuInfo) {
        group = ((HyperlinkWithPopupMenuInfo) info).getPopupMenuGroup(mouseEvent);
    }
    if (group == null) {
        group = (ActionGroup) actionManager.getAction(CONSOLE_VIEW_POPUP_MENU);
    }
    final ConsoleActionsPostProcessor[] postProcessors = Extensions
            .getExtensions(ConsoleActionsPostProcessor.EP_NAME);
    AnAction[] result = group.getChildren(null);

    for (ConsoleActionsPostProcessor postProcessor : postProcessors) {
        result = postProcessor.postProcessPopupActions(this, result);
    }
    final DefaultActionGroup processedGroup = new DefaultActionGroup(result);
    final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, processedGroup);
    menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
}

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

License:Apache License

@Override
public void update(final AnActionEvent event) {
    final Presentation presentation = event.getPresentation();
    final Project project = event.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        presentation.setEnabled(false);/*from w  w w  .j  av  a  2  s .  com*/
        return;
    }
    if (ActionPlaces.EDITOR_POPUP.equals(event.getPlace())
            || ActionPlaces.EDITOR_TAB_POPUP.equals(event.getPlace())) {
        presentation.setText(IdeBundle.message("action.close"));
    }
    EditorWindow window = event.getData(EditorWindow.DATA_KEY);
    if (window == null) {
        window = getEditorManager(project).getActiveWindow().getResult();
    }
    presentation.setEnabled(window != null && window.getTabCount() > 0);
}

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

License:Apache License

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    CopyProvider provider = PlatformDataKeys.COPY_PROVIDER.getData(dataContext);
    presentation.setEnabled(provider != null && provider.isCopyEnabled(dataContext));
    if (event.getPlace().equals(ActionPlaces.EDITOR_POPUP) && provider != null) {
        presentation.setVisible(provider.isCopyVisible(dataContext));
    } else {//from w  w w.ja v a2 s . c  o m
        presentation.setVisible(true);
    }
}

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

License:Apache License

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    CutProvider provider = PlatformDataKeys.CUT_PROVIDER.getData(dataContext);
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    presentation.setEnabled(/*from ww w .jav  a 2s. co  m*/
            project != null && project.isOpen() && provider != null && provider.isCutEnabled(dataContext));
    if (event.getPlace().equals(ActionPlaces.EDITOR_POPUP) && provider != null) {
        presentation.setVisible(provider.isCutVisible(dataContext));
    } else {
        presentation.setVisible(true);
    }
}

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

License:Apache License

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();

    PasteProvider provider = PlatformDataKeys.PASTE_PROVIDER.getData(dataContext);
    presentation.setEnabled(provider != null && provider.isPastePossible(dataContext));
    if (event.getPlace().equals(ActionPlaces.EDITOR_POPUP) && provider != null) {
        presentation.setVisible(presentation.isEnabled());
    } else {/*from   w w w  .j a  v a  2 s  .c o  m*/
        presentation.setVisible(true);
    }
}

From source file:com.intellij.refactoring.actions.RenameFileAction.java

License:Apache License

public void update(AnActionEvent e) {
    PsiFile file = e.getData(LangDataKeys.PSI_FILE);
    Presentation presentation = e.getPresentation();
    boolean enabled = file instanceof PsiClassOwner && e.getPlace() != ActionPlaces.EDITOR_POPUP
            && e.getData(CommonDataKeys.PROJECT) != null;
    presentation.setEnabled(enabled);/* www .ja  va2  s.  c  o m*/
    presentation.setVisible(enabled);
    if (enabled) {
        presentation.setText(RENAME_FILE);
        presentation.setDescription("Rename selected file");
    }
}

From source file:com.intellij.tools.BaseExternalToolsGroup.java

License:Apache License

private boolean isToolVisible(T tool, String context) {
    if (!tool.isEnabled())
        return false;
    if (ActionPlaces.EDITOR_POPUP.equals(context) || ActionPlaces.EDITOR_TAB_POPUP.equals(context)) {
        return tool.isShownInEditor();
    } else if (ActionPlaces.PROJECT_VIEW_POPUP.equals(context) || ActionPlaces.COMMANDER_POPUP.equals(context)
            || ActionPlaces.J2EE_VIEW_POPUP.equals(context)
            || ActionPlaces.TYPE_HIERARCHY_VIEW_POPUP.equals(context)
            || ActionPlaces.CALL_HIERARCHY_VIEW_POPUP.equals(context)
            || ActionPlaces.METHOD_HIERARCHY_VIEW_POPUP.equals(context)
            || ActionPlaces.FAVORITES_VIEW_POPUP.equals(context)
            || ActionPlaces.SCOPE_VIEW_POPUP.equals(context) || ActionPlaces.NAVIGATION_BAR.equals(context)) {
        return tool.isShownInProjectViews();
    } else if (ActionPlaces.MAIN_MENU.equals(context)) {
        return tool.isShownInMainMenu();
    } else if (ActionPlaces.USAGE_VIEW_POPUP.equals(context)) {
        return tool.isShownInSearchResultsPopup();
    }/*from   w  ww  . j  a va  2s.  c  om*/
    return false;
}

From source file:com.mediaworx.intellij.opencmsplugin.actions.tools.ActionTools.java

License:Open Source License

/**
 * Sets the text for the event's action depending on the user's selection in the project tree. E.g. if the user
 * selects mutiple files the resulting text is "[textPrefix] selected Files", if the user selects multiple folders
 * and one file the resulting text is "[textPrefix] selected Folders/File", if the user selects modules only the
 * resulting text is "[textPrefix] selected Modules".
 * @param event the action event provided by IntelliJ
 * @param plugin the current OpenCms plugin instance
 * @param textPrefix the text prefix to use
 *///from   w  w w .j  a v a 2  s. c  o m
public static void setSelectionSpecificActionText(AnActionEvent event, OpenCmsPlugin plugin,
        String textPrefix) {
    boolean enableAction = false;
    String actionPlace = event.getPlace();

    VirtualFile[] selectedFiles = event.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
    FileTypeCounter fileTypeCounter = new FileTypeCounter(plugin);

    if (selectedFiles != null && selectedFiles.length > 0) {
        fileTypeCounter.count(selectedFiles);
        if (fileTypeCounter.hasEntities()) {
            enableAction = true;
        }
    }

    if (!actionPlace.equals(ActionPlaces.EDITOR_POPUP) && !actionPlace.equals(ActionPlaces.EDITOR_TAB_POPUP)) {
        String actionText = textPrefix + " selected " + fileTypeCounter.getEntityNames();
        event.getPresentation().setText(actionText);
    }

    if (enableAction) {
        event.getPresentation().setEnabled(true);
    } else {
        event.getPresentation().setEnabled(false);
    }
}