mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
F4 works in diff window (IDEA-42035)
This commit is contained in:
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
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.application.Application;
|
||||
@@ -55,6 +57,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.ui.EditorNotificationPanel;
|
||||
import com.intellij.ui.PopupHandler;
|
||||
import com.intellij.util.containers.CacheOneStepIterator;
|
||||
@@ -154,6 +157,9 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// EditSourceAction is not enabled in modal context, so we need to register it here explicitly
|
||||
new EditSourceAction().registerCustomShortcutSet(CommonShortcuts.getEditSource(), myPanel, this);
|
||||
}
|
||||
|
||||
protected DiffPanelState createDiffPanelState(@NotNull Disposable parentDisposable) {
|
||||
@@ -728,6 +734,12 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
|
||||
if (FocusDiffSide.DATA_KEY.is(dataId)) {
|
||||
return myDiffPanel.myCurrentSide == null ? null : myFocusDiffSide;
|
||||
}
|
||||
if (PlatformDataKeys.NAVIGATABLE.is(dataId)) {
|
||||
final DiffSideView currentSide = myDiffPanel.myCurrentSide;
|
||||
if (currentSide != null) {
|
||||
return new DiffNavigatable(currentSide);
|
||||
}
|
||||
}
|
||||
|
||||
return super.getData(dataId);
|
||||
}
|
||||
@@ -744,4 +756,30 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
|
||||
myLabel.setText("<html>Coulnd't find context for patch. Some fragments were applied at the best possible place. <b>Please check carefully.</b></html>");
|
||||
}
|
||||
}
|
||||
|
||||
private class DiffNavigatable implements Navigatable {
|
||||
private final DiffSideView mySide;
|
||||
|
||||
public DiffNavigatable(DiffSideView side) {
|
||||
mySide = side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigateToSource() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigate(boolean requestFocus) {
|
||||
final OpenFileDescriptor descriptor = mySide.getCurrentOpenFileDescriptor();
|
||||
if (descriptor != null) {
|
||||
showSource(descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.util.ui.ScrollUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -138,6 +139,16 @@ public class DiffSideView {
|
||||
myLineMarker.hide();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public OpenFileDescriptor getCurrentOpenFileDescriptor() {
|
||||
final EditorEx editor = myEditorSource.getEditor();
|
||||
final DiffContent content = myEditorSource.getContent();
|
||||
if (content == null || editor == null) {
|
||||
return null;
|
||||
}
|
||||
return content.getOpenFileDescriptor(editor.getCaretModel().getOffset());
|
||||
}
|
||||
|
||||
private static class MouseLineNumberListener {
|
||||
private static final Cursor HAND__CURSOR = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
|
||||
private final Editor myEditor;
|
||||
|
||||
Reference in New Issue
Block a user