Search in sources :

Example 86 with DefaultActionGroup

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

the class ListenerNavigateButton method buildNavigateActionGroup.

private static DefaultActionGroup buildNavigateActionGroup(RadComponent component, final PsiField boundField) {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    final EventSetDescriptor[] eventSetDescriptors;
    try {
        BeanInfo beanInfo = Introspector.getBeanInfo(component.getComponentClass());
        eventSetDescriptors = beanInfo.getEventSetDescriptors();
    } catch (IntrospectionException e) {
        LOG.error(e);
        return null;
    }
    PsiFile boundClassFile = boundField.getContainingFile();
    if (boundClassFile == null) {
        return null;
    }
    final LocalSearchScope scope = new LocalSearchScope(boundClassFile);
    ReferencesSearch.search(boundField, scope).forEach(ref -> {
        final PsiElement element = ref.getElement();
        if (element.getParent() instanceof PsiReferenceExpression) {
            PsiReferenceExpression refExpr = (PsiReferenceExpression) element.getParent();
            if (refExpr.getParent() instanceof PsiMethodCallExpression) {
                PsiMethodCallExpression methodCall = (PsiMethodCallExpression) refExpr.getParent();
                final PsiElement psiElement = refExpr.resolve();
                if (psiElement instanceof PsiMethod) {
                    PsiMethod method = (PsiMethod) psiElement;
                    for (EventSetDescriptor eventSetDescriptor : eventSetDescriptors) {
                        if (Comparing.equal(eventSetDescriptor.getAddListenerMethod().getName(), method.getName())) {
                            final String eventName = eventSetDescriptor.getName();
                            final PsiExpression[] args = methodCall.getArgumentList().getExpressions();
                            if (args.length > 0) {
                                addListenerRef(actionGroup, eventName, args[0]);
                            }
                        }
                    }
                }
            }
        }
        return true;
    });
    return actionGroup;
}
Also used : LocalSearchScope(com.intellij.psi.search.LocalSearchScope) BeanInfo(java.beans.BeanInfo) IntrospectionException(java.beans.IntrospectionException) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) EventSetDescriptor(java.beans.EventSetDescriptor)

Example 87 with DefaultActionGroup

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

the class ListenerNavigateButton method showNavigatePopup.

public static void showNavigatePopup(final RadComponent component, final boolean showIfEmpty) {
    final DefaultActionGroup actionGroup = prepareActionGroup(component);
    if (actionGroup != null && actionGroup.getChildrenCount() == 0 && showIfEmpty) {
        actionGroup.add(new MyNavigateAction(UIDesignerBundle.message("navigate.to.listener.empty"), null));
    }
    if (actionGroup != null && actionGroup.getChildrenCount() > 0) {
        final DataContext context = DataManager.getInstance().getDataContext(component.getDelegee());
        final JBPopupFactory factory = JBPopupFactory.getInstance();
        final ListPopup popup = factory.createActionGroupPopup(UIDesignerBundle.message("navigate.to.listener.title"), actionGroup, context, JBPopupFactory.ActionSelectionAid.NUMBERING, true);
        FormEditingUtil.showPopupUnderComponent(popup, component);
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) ListPopup(com.intellij.openapi.ui.popup.ListPopup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 88 with DefaultActionGroup

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

the class GitBranchPopup method createRepositoriesActions.

@NotNull
@Override
protected DefaultActionGroup createRepositoriesActions() {
    DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
    popupGroup.addSeparator("Repositories");
    List<ActionGroup> rootActions = DvcsUtil.sortRepositories(myRepositoryManager.getRepositories()).stream().map(repo -> new RootAction<>(repo, highlightCurrentRepo() ? myCurrentRepository : null, new GitBranchPopupActions(repo.getProject(), repo).createActions(), GitBranchUtil.getDisplayableBranchText(repo))).collect(toList());
    wrapWithMoreActionIfNeeded(myProject, popupGroup, rootActions, rootActions.size() > MAX_NUM ? DEFAULT_NUM : MAX_NUM, SHOW_ALL_REPOSITORIES);
    return popupGroup;
}
Also used : GitRepositoryManager(git4idea.repo.GitRepositoryManager) BranchActionGroupPopup.wrapWithMoreActionIfNeeded(com.intellij.dvcs.ui.BranchActionGroupPopup.wrapWithMoreActionIfNeeded) GitVcsSettings(git4idea.config.GitVcsSettings) ContainerUtil(com.intellij.util.containers.ContainerUtil) RootAction(com.intellij.dvcs.ui.RootAction) GitBranchUtil(git4idea.branch.GitBranchUtil) AbstractRepositoryManager(com.intellij.dvcs.repo.AbstractRepositoryManager) GitUtil(git4idea.GitUtil) DvcsUtil(com.intellij.dvcs.DvcsUtil) Project(com.intellij.openapi.project.Project) GitRepository(git4idea.repo.GitRepository) BranchActionGroup(com.intellij.dvcs.ui.BranchActionGroup) DvcsBranchPopup(com.intellij.dvcs.branch.DvcsBranchPopup) DEFAULT_NUM(com.intellij.dvcs.branch.DvcsBranchPopup.MyMoreIndex.DEFAULT_NUM) AnAction(com.intellij.openapi.actionSystem.AnAction) BranchActionUtil.getNumOfTopShownBranches(com.intellij.dvcs.ui.BranchActionUtil.getNumOfTopShownBranches) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) MAX_NUM(com.intellij.dvcs.branch.DvcsBranchPopup.MyMoreIndex.MAX_NUM) ContainerUtil.map(com.intellij.util.containers.ContainerUtil.map) NotNull(org.jetbrains.annotations.NotNull) FAVORITE_BRANCH_COMPARATOR(com.intellij.dvcs.ui.BranchActionUtil.FAVORITE_BRANCH_COMPARATOR) Condition(com.intellij.openapi.util.Condition) javax.swing(javax.swing) RootAction(com.intellij.dvcs.ui.RootAction) BranchActionGroup(com.intellij.dvcs.ui.BranchActionGroup) ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NotNull(org.jetbrains.annotations.NotNull)

Example 89 with DefaultActionGroup

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

the class ProjectLevelVcsManagerImpl method getOrCreateConsoleContent.

private Content getOrCreateConsoleContent(final ContentManager contentManager) {
    final String displayName = VcsBundle.message("vcs.console.toolwindow.display.name");
    Content content = contentManager.findContent(displayName);
    if (content == null) {
        releaseConsole();
        myConsole = TextConsoleBuilderFactory.getInstance().createBuilder(myProject).getConsole();
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(myConsole.getComponent(), BorderLayout.CENTER);
        ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, new DefaultActionGroup(myConsole.createConsoleActions()), false);
        panel.add(toolbar.getComponent(), BorderLayout.WEST);
        content = ContentFactory.SERVICE.getInstance().createContent(panel, displayName, true);
        content.setDisposer(myConsoleDisposer);
        contentManager.addContent(content);
        for (Pair<String, ConsoleViewContentType> pair : myPendingOutput) {
            printToConsole(pair.first, pair.second);
        }
        myPendingOutput.clear();
    }
    return content;
}
Also used : Content(com.intellij.ui.content.Content) ActionToolbar(com.intellij.openapi.actionSystem.ActionToolbar) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType)

Example 90 with DefaultActionGroup

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

the class RemoteFilePanel method initToolbar.

private void initToolbar(Project project) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new RefreshRemoteFileAction(myVirtualFile));
    for (RemoteFileEditorActionProvider actionProvider : RemoteFileEditorActionProvider.EP_NAME.getExtensions()) {
        group.addAll(actionProvider.createToolbarActions(project, myVirtualFile));
    }
    final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    myToolbarPanel.add(actionToolbar.getComponent(), BorderLayout.CENTER);
}
Also used : ActionToolbar(com.intellij.openapi.actionSystem.ActionToolbar) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Aggregations

DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)109 NotNull (org.jetbrains.annotations.NotNull)38 AnAction (com.intellij.openapi.actionSystem.AnAction)22 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)16 Nullable (org.jetbrains.annotations.Nullable)11 ActionManager (com.intellij.openapi.actionSystem.ActionManager)8 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)7 Separator (com.intellij.openapi.actionSystem.Separator)7 ListPopup (com.intellij.openapi.ui.popup.ListPopup)7 Content (com.intellij.ui.content.Content)6 BrowserHelpAction (com.android.tools.idea.actions.BrowserHelpAction)5 Project (com.intellij.openapi.project.Project)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 List (java.util.List)5 RecordingAction (com.android.tools.idea.monitor.actions.RecordingAction)4 ActionToolbar (com.intellij.openapi.actionSystem.ActionToolbar)4 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)4 javax.swing (javax.swing)4 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)3 CommonActionsManager (com.intellij.ide.CommonActionsManager)3