com.intellij.openapi.editor.event.VisibleAreaEvent Java Examples

The following examples show how to use com.intellij.openapi.editor.event.VisibleAreaEvent. 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: SyncScrollSupport.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void visibleAreaChanged(VisibleAreaEvent e) {
  if (!myScrollable.isSyncScrollEnabled() || isDuringSyncScroll()) return;

  enterDisableScrollSection();
  try {
    if (e.getEditor() == Side.LEFT.select(myEditors)) {
      myHelper1.visibleAreaChanged(e);
    }
    else if (e.getEditor() == Side.RIGHT.select(myEditors)) {
      myHelper2.visibleAreaChanged(e);
    }
  }
  finally {
    exitDisableScrollSection();
  }
}
 
Example #2
Source File: SyncScrollSupport.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void visibleAreaChanged(VisibleAreaEvent e) {
  if (isDuringSyncScroll()) return;

  enterDisableScrollSection();
  try {
    if (e.getEditor() == ThreeSide.LEFT.select(myEditors)) {
      if (myScrollable12.isSyncScrollEnabled()) {
        myHelper12.visibleAreaChanged(e);
        if (myScrollable23.isSyncScrollEnabled()) myHelper23.visibleAreaChanged(e);
      }
    }
    else if (e.getEditor() == ThreeSide.BASE.select(myEditors)) {
      if (myScrollable12.isSyncScrollEnabled()) myHelper21.visibleAreaChanged(e);
      if (myScrollable23.isSyncScrollEnabled()) myHelper23.visibleAreaChanged(e);
    }
    else if (e.getEditor() == ThreeSide.RIGHT.select(myEditors)) {
      if (myScrollable23.isSyncScrollEnabled()) {
        myHelper32.visibleAreaChanged(e);
        if (myScrollable12.isSyncScrollEnabled()) myHelper21.visibleAreaChanged(e);
      }
    }
  }
  finally {
    exitDisableScrollSection();
  }
}
 
Example #3
Source File: GTMVisibleAreaListener.java    From gtm-jetbrains-plugin with MIT License 5 votes vote down vote up
@Override
public void visibleAreaChanged(VisibleAreaEvent visibleAreaEvent) {
    final FileDocumentManager instance = FileDocumentManager.getInstance();
    final VirtualFile file = instance.getFile(visibleAreaEvent.getEditor().getDocument());
    if (file != null) {
        GTMRecord.record(file.getPath(), visibleAreaEvent.getEditor().getProject());
    }
}
 
Example #4
Source File: CustomVisibleAreaListener.java    From jetbrains-wakatime with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void visibleAreaChanged(VisibleAreaEvent visibleAreaEvent) {
    FileDocumentManager instance = FileDocumentManager.getInstance();
    VirtualFile file = instance.getFile(visibleAreaEvent.getEditor().getDocument());
    Project project = visibleAreaEvent.getEditor().getProject();
    WakaTime.appendHeartbeat(file, project, false);
}
 
Example #5
Source File: SyncScrollSupport.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void visibleAreaChanged(VisibleAreaEvent e) {
  if (((FoldingModelImpl)getSlave().getFoldingModel()).isInBatchFoldingOperation()) return;

  Rectangle newRectangle = e.getNewRectangle();
  Rectangle oldRectangle = e.getOldRectangle();
  if (oldRectangle == null) return;

  if (newRectangle.x != oldRectangle.x) syncHorizontalScroll(false);
  if (newRectangle.y != oldRectangle.y) syncVerticalScroll(false);
}
 
Example #6
Source File: SyncScrollSupport.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void visibleAreaChanged(VisibleAreaEvent e) {
  if (!myEnabled || myDuringVerticalScroll) return;
  Rectangle newRectangle = e.getNewRectangle();
  Rectangle oldRectangle = e.getOldRectangle();
  if (newRectangle == null || oldRectangle == null) return;
  myDuringVerticalScroll = true;
  try {
    for (ScrollingContext context : myScrollContexts) {
      syncVerticalScroll(context, newRectangle, oldRectangle);
      syncHorizontalScroll(context, newRectangle, oldRectangle);
    }
  }
  finally { myDuringVerticalScroll = false; }
}
 
Example #7
Source File: ScrollingModelImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #8
Source File: CancelProgressOnScrolling.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void visibleAreaChanged(@Nonnull VisibleAreaEvent e) {
  Rectangle oldRect = e.getOldRectangle();
  Rectangle newRect = e.getNewRectangle();
  CancellablePromise<?> promise = myCancellablePromiseRef.get();
  if (oldRect != null && (oldRect.x != newRect.x || oldRect.y != newRect.y) && promise != null) {
    promise.cancel();
  }
}
 
Example #9
Source File: LocalViewPortChangeHandler.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Generates a ViewPortActivity for the viewport change represented by the given activities. The
 * used line range is calculated using logical positions.
 *
 * <p>Calls {@link EditorManager#generateViewport(IFile, LineRange)} to create and dispatch the
 * activity.
 *
 * <p>This method relies on the EditorPool to filter editor events.
 *
 * @param event the event to react to
 * @see VisibleAreaListener#visibleAreaChanged(VisibleAreaEvent)
 * @see LogicalPosition
 */
private void generateViewportActivity(@NotNull VisibleAreaEvent event) {
  assert enabled : "the visible area listener was triggered while it was disabled";

  Editor editor = event.getEditor();
  Rectangle newVisibleRectangle = event.getNewRectangle();

  IFile file = editorManager.getFileForOpenEditor(editor.getDocument());

  if (file == null) {
    if (log.isTraceEnabled()) {
      VirtualFile virtualFile = DocumentAPI.getVirtualFile(editor.getDocument());

      log.trace(
          "Ignoring local view port change for "
              + virtualFile
              + " as the editor is not known to the editor pool.");
    }

    return;
  }

  if (newVisibleRectangle.x < 0
      || newVisibleRectangle.y < 0
      || newVisibleRectangle.width < 0
      || newVisibleRectangle.height < 0) {

    if (log.isTraceEnabled()) {
      log.trace(
          "Ignoring local viewport change for "
              + file
              + " as the new visible rectangle does not have valid dimensions: "
              + newVisibleRectangle);
    }

    return;
  }

  LineRange newVisibleLineRange = EditorAPI.getLocalViewPortRange(editor, newVisibleRectangle);

  editorManager.generateViewport(file, newVisibleLineRange);
}
 
Example #10
Source File: TwosideTextDiffViewer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void visibleAreaChanged(VisibleAreaEvent e) {
  if (mySyncScrollSupport != null) mySyncScrollSupport.visibleAreaChanged(e);
  myContentPanel.repaint();
}
 
Example #11
Source File: ThreesideTextDiffViewer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void visibleAreaChanged(VisibleAreaEvent e) {
  if (mySyncScrollSupport != null) mySyncScrollSupport.visibleAreaChanged(e);
  myContentPanel.repaint();
}
 
Example #12
Source File: DiffSplitter.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void visibleAreaChanged(VisibleAreaEvent e) {
  redrawDiffs();
}
 
Example #13
Source File: DiffPanelImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
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 #14
Source File: DiffDivider.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void visibleAreaChanged(VisibleAreaEvent e) {
  repaint();
}
 
Example #15
Source File: EditorView.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void visibleAreaChanged(@Nonnull VisibleAreaEvent e) {
  checkFontRenderContext(null);
}