Search in sources :

Example 16 with CustomShortcutSet

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

the class FrameDiffTool method show.

public void show(DiffRequest request) {
    Collection hints = request.getHints();
    boolean shouldOpenDialog = shouldOpenDialog(hints);
    if (shouldOpenDialog) {
        final DialogBuilder builder = new DialogBuilder(request.getProject());
        DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, builder.getWindow(), builder, true);
        if (diffPanel == null) {
            Disposer.dispose(builder);
            return;
        }
        final Runnable onOkRunnable = request.getOnOkRunnable();
        if (onOkRunnable != null) {
            builder.setOkOperation(() -> {
                builder.getDialogWrapper().close(0);
                onOkRunnable.run();
            });
        } else {
            builder.removeAllActions();
        }
        builder.setCenterPanel(diffPanel.getComponent());
        builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent());
        builder.setTitle(request.getWindowTitle());
        builder.setDimensionServiceKey(request.getGroupKey());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                builder.getDialogWrapper().close(0);
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        showDiffDialog(builder, hints);
    } else {
        final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
        DiffPanelImpl diffPanel = createDiffPanelIfShouldShow(request, frameWrapper.getFrame(), frameWrapper, true);
        if (diffPanel == null) {
            Disposer.dispose(frameWrapper);
            return;
        }
        frameWrapper.setTitle(request.getWindowTitle());
        DiffUtil.initDiffFrame(diffPanel.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                frameWrapper.getFrame().dispose();
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        frameWrapper.show();
    }
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) DiffPanelImpl(com.intellij.openapi.diff.impl.DiffPanelImpl) Collection(java.util.Collection) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) FrameWrapper(com.intellij.openapi.ui.FrameWrapper) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 17 with CustomShortcutSet

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

the class MultiLevelDiffTool method show.

@Override
public void show(DiffRequest request) {
    Collection hints = request.getHints();
    boolean shouldOpenDialog = FrameDiffTool.shouldOpenDialog(hints);
    if (shouldOpenDialog) {
        final DialogBuilder builder = new DialogBuilder(request.getProject());
        final CompositeDiffPanel diffPanel = createPanel(request, builder.getWindow(), builder);
        if (diffPanel == null) {
            Disposer.dispose(builder);
            return;
        }
        final Runnable onOkRunnable = request.getOnOkRunnable();
        if (onOkRunnable != null) {
            builder.setOkOperation(() -> {
                builder.getDialogWrapper().close(0);
                onOkRunnable.run();
            });
        } else {
            builder.removeAllActions();
        }
        builder.setCenterPanel(diffPanel.getComponent());
        builder.setPreferredFocusComponent(diffPanel.getPreferredFocusedComponent());
        builder.setTitle(request.getWindowTitle());
        builder.setDimensionServiceKey(request.getGroupKey());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                builder.getDialogWrapper().close(0);
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        diffPanel.setDiffRequest(request);
        FrameDiffTool.showDiffDialog(builder, hints);
    } else {
        final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
        final CompositeDiffPanel diffPanel = createPanel(request, frameWrapper.getFrame(), frameWrapper);
        if (diffPanel == null) {
            Disposer.dispose(frameWrapper);
            return;
        }
        frameWrapper.setTitle(request.getWindowTitle());
        diffPanel.setDiffRequest(request);
        DiffUtil.initDiffFrame(request.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());
        new AnAction() {

            public void actionPerformed(final AnActionEvent e) {
                Disposer.dispose(frameWrapper);
            }
        }.registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("CloseContent")), diffPanel.getComponent());
        frameWrapper.show();
    }
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) DialogBuilder(com.intellij.openapi.ui.DialogBuilder) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) FrameWrapper(com.intellij.openapi.ui.FrameWrapper) CompositeDiffPanel(com.intellij.openapi.diff.impl.CompositeDiffPanel) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 18 with CustomShortcutSet

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

the class ImportUsageFilteringRuleProvider method createFilteringActions.

@Override
@NotNull
public AnAction[] createFilteringActions(@NotNull final UsageView view) {
    final UsageViewImpl impl = (UsageViewImpl) view;
    if (view.getPresentation().isCodeUsages()) {
        final JComponent component = view.getComponent();
        final ShowImportsAction showImportsAction = new ShowImportsAction(impl);
        showImportsAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)), component, view);
        return new AnAction[] { showImportsAction };
    } else {
        return AnAction.EMPTY_ARRAY;
    }
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with CustomShortcutSet

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

the class UsageFilteringRuleProviderImpl method createFilteringActions.

@Override
@NotNull
public AnAction[] createFilteringActions(@NotNull UsageView view) {
    final UsageViewImpl impl = (UsageViewImpl) view;
    if (!view.getPresentation().isCodeUsages()) {
        return AnAction.EMPTY_ARRAY;
    }
    final JComponent component = view.getComponent();
    final ShowReadAccessUsagesAction read = new ShowReadAccessUsagesAction();
    read.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK)), component, impl);
    final ShowWriteAccessUsagesAction write = new ShowWriteAccessUsagesAction();
    write.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK)), component, impl);
    return new AnAction[] { read, write };
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Example 20 with CustomShortcutSet

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

the class UsageGroupingRuleProviderImpl method createGroupingActions.

@Override
@NotNull
public AnAction[] createGroupingActions(UsageView view) {
    UsageViewImpl impl = (UsageViewImpl) view;
    JComponent component = impl.getComponent();
    GroupByModuleTypeAction groupByModuleTypeAction = supportsModuleRule() ? new GroupByModuleTypeAction(impl) : null;
    if (groupByModuleTypeAction != null) {
        groupByModuleTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)), component, impl);
    }
    GroupByFileStructureAction groupByFileStructureAction = createGroupByFileStructureAction(impl);
    GroupByScopeAction groupByScopeAction = supportsScopesRule() ? new GroupByScopeAction(impl) : null;
    GroupByPackageAction groupByPackageAction = new GroupByPackageAction(impl);
    groupByPackageAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)), component, impl);
    ArrayList<AnAction> result = ContainerUtil.newArrayList();
    if (view.getPresentation().isUsageTypeFilteringAvailable()) {
        GroupByUsageTypeAction groupByUsageTypeAction = new GroupByUsageTypeAction(impl);
        groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component, impl);
        ContainerUtil.addIfNotNull(result, groupByUsageTypeAction);
        ContainerUtil.addIfNotNull(result, groupByScopeAction);
        ContainerUtil.addIfNotNull(result, groupByModuleTypeAction);
        ContainerUtil.addIfNotNull(result, groupByPackageAction);
        ContainerUtil.addIfNotNull(result, groupByFileStructureAction);
    } else {
        ContainerUtil.addIfNotNull(result, groupByScopeAction);
        ContainerUtil.addIfNotNull(result, groupByModuleTypeAction);
        ContainerUtil.addIfNotNull(result, groupByPackageAction);
        ContainerUtil.addIfNotNull(result, groupByFileStructureAction);
    }
    return result.toArray(new AnAction[result.size()]);
}
Also used : CustomShortcutSet(com.intellij.openapi.actionSystem.CustomShortcutSet) AnAction(com.intellij.openapi.actionSystem.AnAction) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)23 AnAction (com.intellij.openapi.actionSystem.AnAction)13 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)13 NotNull (org.jetbrains.annotations.NotNull)4 Nullable (org.jetbrains.annotations.Nullable)4 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)3 KeyEvent (java.awt.event.KeyEvent)3 Disposable (com.intellij.openapi.Disposable)2 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)2 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)2 FileChooser (com.intellij.openapi.fileChooser.FileChooser)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 StdFileTypes (com.intellij.openapi.fileTypes.StdFileTypes)2 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)2 Project (com.intellij.openapi.project.Project)2 DialogBuilder (com.intellij.openapi.ui.DialogBuilder)2 FrameWrapper (com.intellij.openapi.ui.FrameWrapper)2 Messages (com.intellij.openapi.ui.Messages)2 TreePath (javax.swing.tree.TreePath)2