Example usage for com.intellij.openapi.actionSystem Anchor FIRST

List of usage examples for com.intellij.openapi.actionSystem Anchor FIRST

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem Anchor FIRST.

Prototype

Anchor FIRST

To view the source code for com.intellij.openapi.actionSystem Anchor FIRST.

Click Source Link

Document

Anchor type that specifies the action to be the first in the list at the moment of addition.

Usage

From source file:com.intellij.spellchecker.actions.SpellingPopupActionGroup.java

License:Apache License

@NotNull
private static AnAction[] findActions(@NotNull AnActionEvent e) {
    PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
    Project project = e.getData(LangDataKeys.PROJECT);
    Editor editor = e.getData(LangDataKeys.EDITOR);
    if (psiFile != null && project != null && editor != null) {
        List<HighlightInfo.IntentionActionDescriptor> quickFixes = QuickFixAction.getAvailableActions(editor,
                psiFile, -1);/*ww  w . j a v a  2  s . co m*/
        Map<Anchor, List<AnAction>> children = new HashMap<Anchor, List<AnAction>>();
        ArrayList<AnAction> first = new ArrayList<AnAction>();
        children.put(Anchor.FIRST, first);
        ArrayList<AnAction> last = new ArrayList<AnAction>();
        children.put(Anchor.LAST, last);
        extractActions(quickFixes, children);
        if (first.size() > 0 && last.size() > 0) {
            first.add(new Separator());
        }
        first.addAll(last);
        if (first.size() > 0) {
            return first.toArray(new AnAction[first.size()]);
        }
    }

    return AnAction.EMPTY_ARRAY;
}

From source file:com.intellij.spellchecker.quickfixes.ChangeTo.java

License:Apache License

@NotNull
public Anchor getPopupActionAnchor() {
    return Anchor.FIRST;
}

From source file:jetbrains.communicator.jabber.JabberIdeaUI.java

License:Apache License

public void initPerProject(MutablePicoContainer projectLevelContainer) {
    StatusToolbar statusToolbar = ((StatusToolbar) projectLevelContainer
            .getComponentInstanceOfType(StatusToolbar.class));
    if (statusToolbar != null) {
        statusToolbar.addToolbarCommand(JabberConnectionCommand.class);
    }/*from   ww w .  j av  a  2 s  .com*/
    if (!ourInitialized && ApplicationManager.getApplication() != null && !Pico.isUnitTest()) {
        DefaultActionGroup group = ((DefaultActionGroup) ActionManager.getInstance()
                .getAction("IDEtalk.OptionsGroup"));
        if (group != null) {
            group.add(new EditJabberSettingsAction(), new Constraints(Anchor.FIRST, ""));
        }
        ourInitialized = true;
    }
}

From source file:org.intellij.spellChecker.actions.SpellingPopupActionGroup.java

License:Apache License

@NotNull
private static AnAction[] findActions(@NotNull AnActionEvent e) {
    PsiFile psiFile = e.getData(DataKeys.PSI_FILE);
    Project project = e.getData(DataKeys.PROJECT);
    Editor editor = e.getData(DataKeys.EDITOR);
    if (psiFile != null && project != null && editor != null) {
        List<HighlightInfo.IntentionActionDescriptor> quickFixes = QuickFixAction.getAvailableActions(editor,
                psiFile, -1);/*from ww  w. ja v  a  2s.  c  o m*/
        Map<Anchor, List<AnAction>> children = new HashMap<Anchor, List<AnAction>>();
        ArrayList<AnAction> first = new ArrayList<AnAction>();
        children.put(Anchor.FIRST, first);
        ArrayList<AnAction> last = new ArrayList<AnAction>();
        children.put(Anchor.LAST, last);
        extractActions(quickFixes, children);
        if (first.size() > 0 && last.size() > 0) {
            first.add(new Separator());
        }
        first.addAll(last);
        if (first.size() > 0) {
            return first.toArray(new AnAction[first.size()]);
        }
    }
    return AnAction.EMPTY_ARRAY;
}

From source file:org.metaborg.intellij.idea.actions.ActionUtils.java

License:Apache License

/**
 * Gets an object that specifies where the action is positioned.
 *
 * @param relativeToActionId The action ID relative to which to position the action;
 *                           or <code>null</code> to position the action at the start or end.
 * @param anchor The anchor indicating where to position the action;
 *               or <code>null</code> to position the action after or at the end.
 * @return The {@link Constraints}./*from   ww  w .  j a v  a 2  s  . c om*/
 */
private Constraints getActionConstraints(@Nullable final String relativeToActionId,
        @Nullable final Anchor anchor) {
    if (relativeToActionId != null && anchor != null) {
        return new Constraints(anchor, relativeToActionId);
    } else if (relativeToActionId != null) {
        return new Constraints(Anchor.AFTER, relativeToActionId);
    } else if (anchor == Anchor.BEFORE || anchor == Anchor.FIRST) {
        return Constraints.FIRST;
    } else {
        return Constraints.LAST;
    }
}