com.intellij.openapi.editor.event.VisibleAreaListener Java Examples
The following examples show how to use
com.intellij.openapi.editor.event.VisibleAreaListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParameterInfoTaskRunnerUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * @param progressTitle null means no loading panel should be shown */ static <T> void runTask(Project project, NonBlockingReadAction<T> nonBlockingReadAction, Consumer<T> continuationConsumer, @Nullable String progressTitle, Editor editor) { AtomicReference<CancellablePromise<?>> cancellablePromiseRef = new AtomicReference<>(); Consumer<Boolean> stopAction = startProgressAndCreateStopAction(editor.getProject(), progressTitle, cancellablePromiseRef, editor); final VisibleAreaListener visibleAreaListener = new CancelProgressOnScrolling(cancellablePromiseRef); editor.getScrollingModel().addVisibleAreaListener(visibleAreaListener); final Component focusOwner = getFocusOwner(project); cancellablePromiseRef.set(nonBlockingReadAction.finishOnUiThread(ModalityState.defaultModalityState(), continuation -> { CancellablePromise<?> promise = cancellablePromiseRef.get(); if (promise != null && promise.isSucceeded() && Objects.equals(focusOwner, getFocusOwner(project))) { continuationConsumer.accept(continuation); } }).expireWith(editor instanceof DesktopEditorImpl ? ((DesktopEditorImpl)editor).getDisposable() : project).submit(AppExecutorUtil.getAppExecutorService()).onProcessed(ignore -> { stopAction.accept(false); editor.getScrollingModel().removeVisibleAreaListener(visibleAreaListener); })); }
Example #2
Source File: ScrollingModelImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void stateChanged(ChangeEvent event) { Rectangle viewRect = getVisibleArea(); VisibleAreaEvent visibleAreaEvent = new VisibleAreaEvent(myEditor, myLastViewRect, viewRect); if (!myViewportPositioned && viewRect.height > 0) { myViewportPositioned = true; if (adjustVerticalOffsetIfNecessary()) { return; } } myLastViewRect = viewRect; for (VisibleAreaListener listener : myVisibleAreaListeners) { listener.visibleAreaChanged(visibleAreaEvent); } }
Example #3
Source File: DiffSplitter.java From consulo with Apache License 2.0 | 4 votes |
@Override public VisibleAreaListener getVisibleAreaListener() { return myVisibleAreaListener; }
Example #4
Source File: HorizontalDiffSplitter.java From consulo with Apache License 2.0 | 4 votes |
@Override public VisibleAreaListener getVisibleAreaListener() { return null; }
Example #5
Source File: DiffPanelImpl.java From consulo with Apache License 2.0 | 4 votes |
public DiffPanelImpl(final Window owner, @Nonnull Project project, boolean enableToolbar, boolean horizontal, int diffDividerPolygonsOffset, DiffTool parentTool) { myProject = project; myIsHorizontal = horizontal; myParentTool = parentTool; myOptions = new DiffPanelOptions(this); myPanel = new DiffPanelOuterComponent(TextDiffType.DIFF_TYPES, null); myPanel.disableToolbar(!enableToolbar); if (enableToolbar) myPanel.resetToolbar(); myOwnerWindow = owner; myIsSyncScroll = true; final boolean v = !horizontal; myLeftSide = new DiffSideView(this, new CustomLineBorder(1, 0, v ? 0 : 1, v ? 0 : 1)); myRightSide = new DiffSideView(this, new CustomLineBorder(v ? 0 : 1, v ? 0 : 1, 1, 0)); myLeftSide.becomeMaster(); myDiffUpdater = new Rediffers(this); myDiffDividerPolygonsOffset = diffDividerPolygonsOffset; myData = createDiffPanelState(this); if (horizontal) { mySplitter = new DiffSplitter(myLeftSide.getComponent(), myRightSide.getComponent(), new DiffDividerPaint(this, FragmentSide.SIDE1, diffDividerPolygonsOffset), myData); } else { mySplitter = new HorizontalDiffSplitter(myLeftSide.getComponent(), myRightSide.getComponent()); } myPanel.insertDiffComponent(mySplitter.getComponent(), new MyScrollingPanel()); myDataProvider = new MyGenericDataProvider(this); myPanel.setDataProvider(myDataProvider); final ComparisonPolicy comparisonPolicy = getComparisonPolicy(); final ComparisonPolicy defaultComparisonPolicy = DiffManagerImpl.getInstanceEx().getComparisonPolicy(); final HighlightMode highlightMode = getHighlightMode(); final HighlightMode defaultHighlightMode = DiffManagerImpl.getInstanceEx().getHighlightMode(); if (defaultComparisonPolicy != null && comparisonPolicy != defaultComparisonPolicy) { setComparisonPolicy(defaultComparisonPolicy); } if (defaultHighlightMode != null && highlightMode != defaultHighlightMode) { setHighlightMode(defaultHighlightMode); } myVisibleAreaListener = new VisibleAreaListener() { @Override public void visibleAreaChanged(VisibleAreaEvent e) { Editor editor1 = getEditor1(); if (editor1 != null) { editor1.getComponent().repaint(); } Editor editor2 = getEditor2(); if (editor2 != null) { editor2.getComponent().repaint(); } } }; registerActions(); }
Example #6
Source File: DiffPanelImpl.java From consulo with Apache License 2.0 | 4 votes |
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); } }); }
Example #7
Source File: TextComponentScrollingModel.java From consulo with Apache License 2.0 | 4 votes |
@Override public void addVisibleAreaListener(@Nonnull final VisibleAreaListener listener) { throw new UnsupportedOperationException("Not implemented"); }
Example #8
Source File: TextComponentScrollingModel.java From consulo with Apache License 2.0 | 4 votes |
@Override public void removeVisibleAreaListener(@Nonnull final VisibleAreaListener listener) { throw new UnsupportedOperationException("Not implemented"); }
Example #9
Source File: ScrollingModelImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public void addVisibleAreaListener(@Nonnull VisibleAreaListener listener) { myVisibleAreaListeners.add(listener); }
Example #10
Source File: ScrollingModelImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public void removeVisibleAreaListener(@Nonnull VisibleAreaListener listener) { boolean success = myVisibleAreaListeners.remove(listener); LOG.assertTrue(success); }
Example #11
Source File: ScrollingModel.java From consulo with Apache License 2.0 | votes |
void addVisibleAreaListener(@Nonnull VisibleAreaListener listener);
Example #12
Source File: ScrollingModel.java From consulo with Apache License 2.0 | votes |
void removeVisibleAreaListener(@Nonnull VisibleAreaListener listener);
Example #13
Source File: DiffSplitterI.java From consulo with Apache License 2.0 | votes |
VisibleAreaListener getVisibleAreaListener();