Search in sources :

Example 1 with FocusDiffSide

use of com.intellij.openapi.diff.impl.util.FocusDiffSide in project intellij-community by JetBrains.

the class DiffWalkerAction method update.

public void update(AnActionEvent event) {
    FocusDiffSide side = DiffUtil.getFocusDiffSide(event.getDataContext());
    Presentation presentation = event.getPresentation();
    if (side == null) {
        presentation.setEnabled(false);
    } else {
        presentation.setEnabled(getLineNumberToGo(side) >= 0 || event.getInputEvent() instanceof KeyEvent);
    }
}
Also used : KeyEvent(java.awt.event.KeyEvent) Presentation(com.intellij.openapi.actionSystem.Presentation) FocusDiffSide(com.intellij.openapi.diff.impl.util.FocusDiffSide)

Example 2 with FocusDiffSide

use of com.intellij.openapi.diff.impl.util.FocusDiffSide in project intellij-community by JetBrains.

the class DiffWalkerAction method actionPerformed.

public void actionPerformed(AnActionEvent event) {
    FocusDiffSide side = DiffUtil.getFocusDiffSide(event.getDataContext());
    if (side == null)
        return;
    int line = getLineNumberToGo(side);
    Editor editor = side.getEditor();
    if (line >= 0 && editor != null) {
        LogicalPosition pos = new LogicalPosition(line, 0);
        editor.getCaretModel().removeSecondaryCarets();
        editor.getCaretModel().moveToLogicalPosition(pos);
        editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
    }
}
Also used : LogicalPosition(com.intellij.openapi.editor.LogicalPosition) Editor(com.intellij.openapi.editor.Editor) FocusDiffSide(com.intellij.openapi.diff.impl.util.FocusDiffSide)

Aggregations

FocusDiffSide (com.intellij.openapi.diff.impl.util.FocusDiffSide)2 Presentation (com.intellij.openapi.actionSystem.Presentation)1 Editor (com.intellij.openapi.editor.Editor)1 LogicalPosition (com.intellij.openapi.editor.LogicalPosition)1 KeyEvent (java.awt.event.KeyEvent)1