mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: require explicit 'animated' parameter for scrolling
This commit is contained in:
@@ -629,7 +629,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase {
|
||||
|
||||
assert next != null;
|
||||
|
||||
DiffUtil.scrollToLineAnimated(myEditor, next.getLine1());
|
||||
DiffUtil.scrollEditor(myEditor, next.getLine1(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -661,7 +661,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase {
|
||||
|
||||
if (prev == null) prev = diffChanges.get(diffChanges.size() - 1);
|
||||
|
||||
DiffUtil.scrollToLineAnimated(myEditor, prev.getLine1());
|
||||
DiffUtil.scrollEditor(myEditor, prev.getLine1(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1006,7 +1006,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase {
|
||||
DiffUtil.scrollToPoint(myEditor, myEditorPosition.myPoints[0]);
|
||||
}
|
||||
else {
|
||||
DiffUtil.scrollToCaret(myEditor);
|
||||
DiffUtil.scrollToCaret(myEditor, false);
|
||||
}
|
||||
myShouldScroll = false;
|
||||
}
|
||||
@@ -1024,7 +1024,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase {
|
||||
|
||||
private boolean doScrollToLine(@NotNull Side side, @NotNull LogicalPosition position) {
|
||||
int onesideLine = transferLineToOneside(side, position.line);
|
||||
DiffUtil.scrollEditor(myEditor, onesideLine, position.column);
|
||||
DiffUtil.scrollEditor(myEditor, onesideLine, position.column, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1045,7 +1045,7 @@ public class OnesideDiffViewer extends TextDiffViewerBase {
|
||||
throw new IllegalArgumentException(scrollToChangePolicy.name());
|
||||
}
|
||||
|
||||
DiffUtil.scrollEditor(myEditor, targetChange.getLine1());
|
||||
DiffUtil.scrollEditor(myEditor, targetChange.getLine1(), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -392,6 +392,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
@Override
|
||||
protected boolean doScrollToChange(@NotNull ScrollToPolicy scrollToPolicy) {
|
||||
if (myDiffChanges.isEmpty()) return false;
|
||||
if (myEditor1 == null || myEditor2 == null) return true;
|
||||
|
||||
SimpleDiffChange targetChange;
|
||||
switch (scrollToPolicy) {
|
||||
@@ -405,13 +406,19 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
throw new IllegalArgumentException(scrollToPolicy.name());
|
||||
}
|
||||
|
||||
EditorEx editor = getCurrentEditor();
|
||||
int line = targetChange.getStartLine(getCurrentSide());
|
||||
DiffUtil.scrollEditor(editor, line);
|
||||
doScrollToChange(targetChange, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doScrollToChange(@NotNull SimpleDiffChange change, boolean animated) {
|
||||
if (myEditor1 == null || myEditor2 == null) return;
|
||||
|
||||
EditorEx editor = getCurrentEditor();
|
||||
int line = change.getStartLine(getCurrentSide());
|
||||
DiffUtil.scrollEditor(editor, line, animated);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doScrollToContext(@NotNull DiffNavigationContext context) {
|
||||
if (myEditor2 == null) return false;
|
||||
@@ -522,8 +529,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
}
|
||||
|
||||
assert next != null;
|
||||
|
||||
DiffUtil.scrollToLineAnimated(editor, next.getStartLine(getCurrentSide()));
|
||||
doScrollToChange(next, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -559,8 +565,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
}
|
||||
|
||||
assert prev != null;
|
||||
|
||||
DiffUtil.scrollToLineAnimated(editor, prev.getStartLine(getCurrentSide()));
|
||||
doScrollToChange(prev, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-7
@@ -340,13 +340,17 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
|
||||
throw new IllegalArgumentException(scrollToPolicy.name());
|
||||
}
|
||||
|
||||
EditorEx editor = getCurrentEditor();
|
||||
int line = targetChange.getStartLine(getCurrentSide());
|
||||
DiffUtil.scrollEditor(editor, line);
|
||||
doScrollToChange(targetChange, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doScrollToChange(@NotNull SimpleThreesideDiffChange change, boolean animated) {
|
||||
EditorEx editor = getCurrentEditor();
|
||||
int line = change.getStartLine(getCurrentSide());
|
||||
DiffUtil.scrollEditor(editor, line, animated);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private IgnorePolicy getIgnorePolicy() {
|
||||
IgnorePolicy policy = getTextSettings().getIgnorePolicy();
|
||||
@@ -427,8 +431,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
|
||||
}
|
||||
|
||||
assert next != null;
|
||||
|
||||
DiffUtil.scrollToLineAnimated(editor, getCurrentStartLine(next));
|
||||
doScrollToChange(next, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -464,8 +467,7 @@ public class SimpleThreesideDiffViewer extends ThreesideTextDiffViewer {
|
||||
}
|
||||
|
||||
assert prev != null;
|
||||
|
||||
DiffUtil.scrollToLineAnimated(editor, getCurrentStartLine(prev));
|
||||
doScrollToChange(prev, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -90,7 +90,9 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
|
||||
super(context, request);
|
||||
|
||||
List<DiffContent> contents = myRequest.getContents();
|
||||
myActualContents = ContainerUtil.newArrayList((DocumentContent)contents.get(0), (DocumentContent)contents.get(1), (DocumentContent)contents.get(2));
|
||||
myActualContents = ContainerUtil.newArrayList((DocumentContent)contents.get(0),
|
||||
(DocumentContent)contents.get(1),
|
||||
(DocumentContent)contents.get(2));
|
||||
|
||||
|
||||
myEditors = createEditors();
|
||||
@@ -285,7 +287,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
|
||||
@CalledInAwt
|
||||
protected void scrollToLine(@NotNull ThreeSide side, int line) {
|
||||
Editor editor = side.select(myEditors);
|
||||
DiffUtil.scrollEditor(editor, line);
|
||||
DiffUtil.scrollEditor(editor, line, false);
|
||||
myCurrentSide = side;
|
||||
}
|
||||
|
||||
@@ -515,7 +517,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
|
||||
}
|
||||
}
|
||||
else {
|
||||
DiffUtil.scrollToCaret(getCurrentEditor());
|
||||
DiffUtil.scrollToCaret(getCurrentEditor(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -527,7 +529,7 @@ public abstract class ThreesideTextDiffViewer extends TextDiffViewerBase {
|
||||
if (side.select(myEditors) == null) return false;
|
||||
|
||||
myCurrentSide = side;
|
||||
DiffUtil.scrollEditor(getCurrentEditor(), line);
|
||||
DiffUtil.scrollEditor(getCurrentEditor(), line, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -334,7 +334,7 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase {
|
||||
protected void scrollToLine(@NotNull Side side, int line) {
|
||||
Editor editor = side.select(myEditor1, myEditor2);
|
||||
if (editor == null) return;
|
||||
DiffUtil.scrollEditor(editor, line);
|
||||
DiffUtil.scrollEditor(editor, line, false);
|
||||
myCurrentSide = side;
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase {
|
||||
}
|
||||
}
|
||||
else {
|
||||
DiffUtil.scrollToCaret(getCurrentEditor());
|
||||
DiffUtil.scrollToCaret(getCurrentEditor(), false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -581,7 +581,7 @@ public abstract class TwosideTextDiffViewer extends TextDiffViewerBase {
|
||||
if (side.select(myEditor1, myEditor2) == null) return false;
|
||||
|
||||
myCurrentSide = side;
|
||||
DiffUtil.scrollEditor(getCurrentEditor(), line);
|
||||
DiffUtil.scrollEditor(getCurrentEditor(), line, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,27 +191,15 @@ public class DiffUtil {
|
||||
// Scrolling
|
||||
//
|
||||
|
||||
public static void scrollEditor(@Nullable final Editor editor, int line) {
|
||||
scrollEditor(editor, line, 0);
|
||||
public static void scrollEditor(@Nullable final Editor editor, int line, boolean animated) {
|
||||
scrollEditor(editor, line, 0, animated);
|
||||
}
|
||||
|
||||
public static void scrollEditor(@Nullable final Editor editor, int line, int column) {
|
||||
scrollEditor(editor, new LogicalPosition(line, column));
|
||||
}
|
||||
|
||||
public static void scrollEditor(@Nullable final Editor editor, @NotNull LogicalPosition position) {
|
||||
public static void scrollEditor(@Nullable final Editor editor, int line, int column, boolean animated) {
|
||||
if (editor == null) return;
|
||||
editor.getCaretModel().removeSecondaryCarets();
|
||||
editor.getCaretModel().moveToLogicalPosition(position);
|
||||
scrollToCaret(editor);
|
||||
}
|
||||
|
||||
public static void scrollToLineAnimated(@Nullable final Editor editor, int line) {
|
||||
if (editor == null) return;
|
||||
editor.getCaretModel().removeSecondaryCarets();
|
||||
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(line, 0));
|
||||
ScrollingModel scrollingModel = editor.getScrollingModel();
|
||||
scrollingModel.scrollToCaret(ScrollType.CENTER);
|
||||
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(line, column));
|
||||
scrollToCaret(editor, animated);
|
||||
}
|
||||
|
||||
public static void scrollToPoint(@Nullable Editor editor, @NotNull Point point) {
|
||||
@@ -222,11 +210,11 @@ public class DiffUtil {
|
||||
editor.getScrollingModel().enableAnimation();
|
||||
}
|
||||
|
||||
public static void scrollToCaret(@Nullable Editor editor) {
|
||||
public static void scrollToCaret(@Nullable Editor editor, boolean animated) {
|
||||
if (editor == null) return;
|
||||
editor.getScrollingModel().disableAnimation();
|
||||
if (!animated) editor.getScrollingModel().disableAnimation();
|
||||
editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
|
||||
editor.getScrollingModel().enableAnimation();
|
||||
if (!animated) editor.getScrollingModel().enableAnimation();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user