From 896f579e73ab880bfd36730ad109f957f7625faa Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Sat, 8 Sep 2012 12:37:19 +0400 Subject: [PATCH] IDEA-91177 There are no keyboard shortcuts for switching between panes and to apply diffs in differences viewer --- .../openapi/diff/impl/DiffPanelImpl.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java index 8b10264ac8cc..f008799a852d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java @@ -17,10 +17,7 @@ package com.intellij.openapi.diff.impl; import com.intellij.ide.actions.EditSourceAction; import com.intellij.openapi.Disposable; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.CommonShortcuts; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -40,6 +37,7 @@ import com.intellij.openapi.diff.impl.splitter.LineBlocks; import com.intellij.openapi.diff.impl.util.*; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.ScrollingModel; import com.intellij.openapi.editor.event.VisibleAreaEvent; import com.intellij.openapi.editor.event.VisibleAreaListener; @@ -158,9 +156,24 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid } } }; + registerActions(); + } + private void registerActions() { // EditSourceAction is not enabled in modal context, so we need to register it here explicitly new EditSourceAction().registerCustomShortcutSet(CommonShortcuts.getEditSource(), myPanel, this); + + //control+tab switches editors + new AnAction(){ + @Override + public void actionPerformed(AnActionEvent e) { + if (getEditor1() != null && getEditor2() != null) { + Editor focus = getEditor1().getContentComponent().hasFocus() ? getEditor2() : getEditor1(); + IdeFocusManager.getGlobalInstance().requestFocus(focus.getContentComponent(), true); + focus.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); + } + } + }.registerCustomShortcutSet(CustomShortcutSet.fromString("control TAB"), myPanel, this); } protected DiffPanelState createDiffPanelState(@NotNull Disposable parentDisposable) {