Search in sources :

Example 41 with DefaultActionGroup

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

the class GpuMonitorView method getToolbarActions.

@Override
@NotNull
public ActionGroup getToolbarActions() {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new RecordingAction(this));
    group.add(new Separator());
    group.add(new BrowserHelpAction("GPU monitor", PROFILING_URL));
    return group;
}
Also used : BrowserHelpAction(com.android.tools.idea.actions.BrowserHelpAction) RecordingAction(com.android.tools.idea.monitor.actions.RecordingAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) Separator(com.intellij.openapi.actionSystem.Separator) NotNull(org.jetbrains.annotations.NotNull)

Example 42 with DefaultActionGroup

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

the class MonitorPanel method setupToolbar.

@NotNull
private ActionToolbarImpl setupToolbar(@NotNull ActionGroup actions, @NotNull BaseMonitorView monitor) {
    DefaultActionGroup viewActions = new DefaultActionGroup();
    viewActions.addAll(actions);
    viewActions.add(new MonitorMoveAction(this, monitor, -1));
    viewActions.add(new MonitorMoveAction(this, monitor, 1));
    viewActions.add(new MinimizeAction(this, monitor));
    ActionToolbarImpl toolbar = new ActionToolbarImpl(ActionPlaces.UNKNOWN, viewActions, true, false, DataManager.getInstance(), ActionManagerEx.getInstanceEx(), KeymapManagerEx.getInstanceEx());
    toolbar.setBorder(BorderFactory.createEmptyBorder());
    toolbar.setMinimumSize(new Dimension(0, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.height));
    toolbar.setPreferredSize(new Dimension(Integer.MAX_VALUE, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.height));
    toolbar.setMaximumSize(toolbar.getPreferredSize());
    return toolbar;
}
Also used : ActionToolbarImpl(com.intellij.openapi.actionSystem.impl.ActionToolbarImpl) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NotNull(org.jetbrains.annotations.NotNull)

Example 43 with DefaultActionGroup

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

the class GitBranchPopupActions method createActions.

ActionGroup createActions(@Nullable DefaultActionGroup toInsert, @NotNull String repoInfo, boolean firstLevelGroup) {
    DefaultActionGroup popupGroup = new DefaultActionGroup(null, false);
    List<GitRepository> repositoryList = Collections.singletonList(myRepository);
    popupGroup.addAction(new GitNewBranchAction(myProject, repositoryList));
    popupGroup.addAction(new CheckoutRevisionActions(myProject, repositoryList));
    if (toInsert != null) {
        popupGroup.addAll(toInsert);
    }
    popupGroup.addSeparator("Local Branches" + repoInfo);
    List<BranchActionGroup> localBranchActions = myRepository.getBranches().getLocalBranches().stream().sorted().filter(branch -> !branch.equals(myRepository.getCurrentBranch())).map(branch -> new LocalBranchActions(myProject, repositoryList, branch.getName(), myRepository)).collect(toList());
    // if there are only a few local favorites -> show all;  for remotes it's better to show only favorites; 
    wrapWithMoreActionIfNeeded(myProject, popupGroup, ContainerUtil.sorted(localBranchActions, FAVORITE_BRANCH_COMPARATOR), getNumOfTopShownBranches(localBranchActions), firstLevelGroup ? GitBranchPopup.SHOW_ALL_LOCALS_KEY : null, firstLevelGroup);
    popupGroup.addSeparator("Remote Branches" + repoInfo);
    List<BranchActionGroup> remoteBranchActions = myRepository.getBranches().getRemoteBranches().stream().sorted().map(remoteBranch -> new RemoteBranchActions(myProject, repositoryList, remoteBranch.getName(), myRepository)).collect(toList());
    wrapWithMoreActionIfNeeded(myProject, popupGroup, ContainerUtil.sorted(remoteBranchActions, FAVORITE_BRANCH_COMPARATOR), getNumOfTopShownBranches(remoteBranchActions), firstLevelGroup ? GitBranchPopup.SHOW_ALL_REMOTES_KEY : null);
    return popupGroup;
}
Also used : BranchActionGroupPopup.wrapWithMoreActionIfNeeded(com.intellij.dvcs.ui.BranchActionGroupPopup.wrapWithMoreActionIfNeeded) ContainerUtil(com.intellij.util.containers.ContainerUtil) GitBranchUtil(git4idea.branch.GitBranchUtil) GitNewBranchOptions(git4idea.branch.GitNewBranchOptions) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) GitStatisticsCollectorKt.reportUsage(git4idea.GitStatisticsCollectorKt.reportUsage) GitRepository(git4idea.repo.GitRepository) BranchActionGroup(com.intellij.dvcs.ui.BranchActionGroup) HEAD(git4idea.GitUtil.HEAD) PopupElementWithAdditionalInfo(com.intellij.dvcs.ui.PopupElementWithAdditionalInfo) GitBrancher(git4idea.branch.GitBrancher) 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) GitNewBranchNameValidator(git4idea.validators.GitNewBranchNameValidator) LOCAL(git4idea.branch.GitBranchType.LOCAL) Nullable(org.jetbrains.annotations.Nullable) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ServiceManager(com.intellij.openapi.components.ServiceManager) NewBranchAction(com.intellij.dvcs.ui.NewBranchAction) StreamEx(one.util.streamex.StreamEx) REMOTE(git4idea.branch.GitBranchType.REMOTE) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) NotNull(org.jetbrains.annotations.NotNull) FAVORITE_BRANCH_COMPARATOR(com.intellij.dvcs.ui.BranchActionUtil.FAVORITE_BRANCH_COMPARATOR) Collections(java.util.Collections) GitRepository(git4idea.repo.GitRepository) BranchActionGroup(com.intellij.dvcs.ui.BranchActionGroup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 44 with DefaultActionGroup

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

the class SurroundWithTemplateHandler method invoke.

@Override
public void invoke(@NotNull final Project project, @NotNull final Editor editor, @NotNull PsiFile file) {
    if (!EditorModificationUtil.checkModificationAllowed(editor))
        return;
    DefaultActionGroup group = createActionGroup(project, editor, file);
    if (group == null)
        return;
    final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(CodeInsightBundle.message("templates.select.template.chooser.title"), group, DataManager.getInstance().getDataContext(editor.getContentComponent()), JBPopupFactory.ActionSelectionAid.MNEMONICS, false);
    popup.showInBestPositionFor(editor);
}
Also used : ListPopup(com.intellij.openapi.ui.popup.ListPopup) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup)

Example 45 with DefaultActionGroup

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

the class ContentEntryTreeEditor method setContentEntryEditor.

/**
   * @param contentEntryEditor : null means to clear the editor
   */
public void setContentEntryEditor(final ContentEntryEditor contentEntryEditor) {
    if (myContentEntryEditor != null && myContentEntryEditor.equals(contentEntryEditor)) {
        return;
    }
    if (myFileSystemTree != null) {
        Disposer.dispose(myFileSystemTree);
        myFileSystemTree = null;
    }
    if (myContentEntryEditor != null) {
        myContentEntryEditor.removeContentEntryEditorListener(myContentEntryEditorListener);
        myContentEntryEditor = null;
    }
    if (contentEntryEditor == null) {
        ((DefaultTreeModel) myTree.getModel()).setRoot(EMPTY_TREE_ROOT);
        myTreePanel.setVisible(false);
        if (myFileSystemTree != null) {
            Disposer.dispose(myFileSystemTree);
        }
        return;
    }
    myTreePanel.setVisible(true);
    myContentEntryEditor = contentEntryEditor;
    myContentEntryEditor.addContentEntryEditorListener(myContentEntryEditorListener);
    final ContentEntry entry = contentEntryEditor.getContentEntry();
    assert entry != null : contentEntryEditor;
    final VirtualFile file = entry.getFile();
    if (file != null) {
        myDescriptor.setRoots(file);
    } else {
        String path = VfsUtilCore.urlToPath(entry.getUrl());
        myDescriptor.setTitle(FileUtil.toSystemDependentName(path));
    }
    final Runnable init = () -> {
        //noinspection ConstantConditions
        myFileSystemTree.updateTree();
        myFileSystemTree.select(file, null);
    };
    myFileSystemTree = new FileSystemTreeImpl(myProject, myDescriptor, myTree, getContentEntryCellRenderer(), init, null) {

        @Override
        protected AbstractTreeBuilder createTreeBuilder(JTree tree, DefaultTreeModel treeModel, AbstractTreeStructure treeStructure, Comparator<NodeDescriptor> comparator, FileChooserDescriptor descriptor, final Runnable onInitialized) {
            return new MyFileTreeBuilder(tree, treeModel, treeStructure, comparator, descriptor, onInitialized);
        }
    };
    myFileSystemTree.showHiddens(true);
    Disposer.register(myProject, myFileSystemTree);
    final NewFolderAction newFolderAction = new MyNewFolderAction();
    final DefaultActionGroup mousePopupGroup = new DefaultActionGroup();
    mousePopupGroup.add(myEditingActionsGroup);
    mousePopupGroup.addSeparator();
    mousePopupGroup.add(newFolderAction);
    myFileSystemTree.registerMouseListener(mousePopupGroup);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) AbstractTreeBuilder(com.intellij.ide.util.treeView.AbstractTreeBuilder) NodeDescriptor(com.intellij.ide.util.treeView.NodeDescriptor) FileSystemTreeImpl(com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl) NewFolderAction(com.intellij.openapi.fileChooser.actions.NewFolderAction) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) ContentEntry(com.intellij.openapi.roots.ContentEntry) AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure)

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