use of com.intellij.openapi.editor.ScrollingModel in project intellij-community by JetBrains.
the class RemoveMiddlemanHandler method invoke.
public void invoke(@NotNull Project project, Editor editor, PsiFile file, DataContext dataContext) {
final ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
if (!(element instanceof PsiField)) {
CommonRefactoringUtil.showErrorHint(project, editor, RefactorJBundle.message("cannot.perform.the.refactoring") + RefactorJBundle.message("the.caret.should.be.positioned.at.the.name.of.the.field.to.be.refactored"), REFACTORING_NAME, getHelpID());
return;
}
invoke((PsiField) element, editor);
}
use of com.intellij.openapi.editor.ScrollingModel in project intellij-community by JetBrains.
the class SyncScrollSupport method scrollEditor.
public static void scrollEditor(@NotNull Editor editor, int logicalLine) {
editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalLine, 0));
ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.disableAnimation();
scrollingModel.scrollToCaret(ScrollType.CENTER);
scrollingModel.enableAnimation();
}
use of com.intellij.openapi.editor.ScrollingModel in project intellij-community by JetBrains.
the class CaretVisualPositionKeeper method restoreOriginalLocation.
public void restoreOriginalLocation() {
for (Map.Entry<Editor, Integer> e : myCaretRelativeVerticalPositions.entrySet()) {
Editor editor = e.getKey();
int relativePosition = e.getValue();
Point caretLocation = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
int scrollOffset = caretLocation.y - relativePosition;
ScrollingModel scrollingModel = editor.getScrollingModel();
Rectangle targetArea = scrollingModel.getVisibleAreaOnScrollingFinished();
// when animated scrolling is in progress, we'll not stop it immediately
boolean useAnimation = !targetArea.equals(scrollingModel.getVisibleArea());
if (!useAnimation)
scrollingModel.disableAnimation();
scrollingModel.scroll(targetArea.x, scrollOffset);
if (!useAnimation)
scrollingModel.enableAnimation();
}
}
use of com.intellij.openapi.editor.ScrollingModel in project intellij-community by JetBrains.
the class DiffPanelImpl method onContentChangedIn.
public void onContentChangedIn(EditorSource source) {
myDiffUpdater.contentRemoved(source);
final EditorEx editor = source.getEditor();
if (myIsHorizontal && source.getSide() == FragmentSide.SIDE1 && editor != null) {
editor.setVerticalScrollbarOrientation(EditorEx.VERTICAL_SCROLLBAR_LEFT);
}
DiffSideView viewSide = getSideView(source.getSide());
viewSide.setEditorSource(getProject(), source);
Disposer.dispose(myScrollSupport);
if (editor == null) {
if (!myDisposed) {
rediff();
}
return;
}
final MouseListener mouseListener = PopupHandler.installUnknownPopupHandler(editor.getContentComponent(), new MergeActionGroup(this, source.getSide()), ActionManager.getInstance());
myDiffUpdater.contentAdded(source);
editor.getSettings().setLineNumbersShown(true);
editor.getSettings().setFoldingOutlineShown(false);
editor.getFoldingModel().setFoldingEnabled(false);
((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);
Editor editor1 = getEditor(FragmentSide.SIDE1);
Editor editor2 = getEditor(FragmentSide.SIDE2);
if (editor1 != null && editor2 != null && myIsSyncScroll) {
myScrollSupport.install(new EditingSides[] { this });
}
final VisibleAreaListener visibleAreaListener = mySplitter.getVisibleAreaListener();
final ScrollingModel scrollingModel = editor.getScrollingModel();
if (visibleAreaListener != null) {
scrollingModel.addVisibleAreaListener(visibleAreaListener);
scrollingModel.addVisibleAreaListener(myVisibleAreaListener);
}
myFontSizeSynchronizer.synchronize(editor);
source.addDisposable(new Disposable() {
public void dispose() {
myFontSizeSynchronizer.stopSynchronize(editor);
}
});
source.addDisposable(new Disposable() {
public void dispose() {
if (visibleAreaListener != null) {
scrollingModel.removeVisibleAreaListener(visibleAreaListener);
scrollingModel.removeVisibleAreaListener(myVisibleAreaListener);
}
editor.getContentComponent().removeMouseListener(mouseListener);
}
});
}
use of com.intellij.openapi.editor.ScrollingModel in project intellij-community by JetBrains.
the class SyncScrollSupport method doScrollVertically.
private static void doScrollVertically(@NotNull Editor editor, int offset, boolean animated) {
ScrollingModel model = editor.getScrollingModel();
if (!animated)
model.disableAnimation();
model.scrollVertically(offset);
if (!animated)
model.enableAnimation();
}
Aggregations