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(); } }
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(); } }
@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()); } }
@Override public void visibleAreaChanged(VisibleAreaEvent e) { 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); }
@Override public void visibleAreaChanged(VisibleAreaEvent e) { if (mySyncScrollSupport != null) mySyncScrollSupport.visibleAreaChanged(e); if (Registry.is("diff.divider.repainting.fix")) { myContentPanel.repaint(); } else { myContentPanel.repaintDivider(); } }
@Override public void visibleAreaChanged(VisibleAreaEvent e) { if (mySyncScrollSupport != null) mySyncScrollSupport.visibleAreaChanged(e); if (Registry.is("diff.divider.repainting.fix")) { myContentPanel.repaint(); } else { myContentPanel.repaintDivider(mySide); } }
@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; } }
public ScrollingModelImpl(EditorImpl editor) { myEditor = editor; myEditor.getScrollPane().getViewport().addChangeListener(new ChangeListener() { private Rectangle myLastViewRect; @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); } } }); myDocumentListener = new DocumentAdapter() { @Override public void beforeDocumentChange(DocumentEvent e) { cancelAnimatedScrolling(true); } }; myEditor.getDocument().addDocumentListener(myDocumentListener); }
private void initListenerIfNecessary() { // We can't attach the listener during this object initialization because there is a big chance that the editor is in incomplete // state there (e.g. it's scrolling model is not initialized yet). if (myVisualAreaListenerAttached) { return; } myVisualAreaListenerAttached = true; myEditor.getScrollingModel().addVisibleAreaListener(new VisibleAreaListener() { @Override public void visibleAreaChanged(VisibleAreaEvent e) { updateLastTopLeftCornerOffset(); } }); updateLastTopLeftCornerOffset(); }
public void visibleAreaChanged(VisibleAreaEvent e) { if (myDuringVerticalScroll) return; Rectangle newRectangle = e.getNewRectangle(); Rectangle oldRectangle = e.getOldRectangle(); if (newRectangle == null || oldRectangle == null) return; myDuringVerticalScroll = true; try { for (Pair<FragmentSide, EditingSides> context : myScrollContexts) { syncVerticalScroll(context, newRectangle, oldRectangle); syncHorizontalScroll(context, newRectangle, oldRectangle); } } finally { myDuringVerticalScroll = false; } }
@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); }
@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); }
@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); } }
public void visibleAreaChanged(VisibleAreaEvent e) { redrawDiffs(); }
public DiffPanelImpl(final Window owner, @NotNull 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); ComparisonPolicy comparisonPolicy = getComparisonPolicy(); if (comparisonPolicy != DiffManagerImpl.getInstanceEx().getComparisonPolicy()) { setComparisonPolicy(comparisonPolicy); } HighlightMode highlightMode = getHighlightMode(); if (highlightMode != DiffManagerImpl.getInstanceEx().getHighlightMode()) { setHighlightMode(highlightMode); } 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(); }
public void visibleAreaChanged(VisibleAreaEvent e) { repaint(); }
@Override public void visibleAreaChanged(VisibleAreaEvent event) { Editor masterEditor = event.getEditor(); try { // Disable while we move things. Must remember to always add it back on. // Doing everything on this thread and not with SwingUtilities to ensure single threaded. masterEditor.getScrollingModel().removeVisibleAreaListener(this); VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(masterEditor.getDocument()); List<Editor> allTheseShowingEditors = new ArrayList<>(); for (Editor e : EditorFactory.getInstance().getEditors(masterEditor.getDocument())) { if (e.getComponent().isShowing()) { allTheseShowingEditors.add(e); } } if (allTheseShowingEditors.size() < 2) { logger.info("visibleAreaChanged: <2 showing editors for file=" + (virtualFile != null ? virtualFile.getCanonicalPath() : "<null>") + " editors=" + listShortObjects(allTheseShowingEditors)); return; } // sort all editors by their location on the screen Left to Right, Top to Bottom. Collections.sort(allTheseShowingEditors, (e1, e2) -> { if (!e1.getComponent().isShowing() || !e2.getComponent().isShowing()) { return 0; // don't try to look when not on the screen. } Point e1Location = e1.getComponent().getLocationOnScreen(); Point e2Location = e2.getComponent().getLocationOnScreen(); if (e1Location.getX() != e2Location.getX()) { return (int) (e1Location.getX() - e2Location.getX()); } return (int) (e1Location.getY() - e2Location.getY()); }); syncJoinedTabScrolling(virtualFile.getCanonicalPath(), masterEditor, allTheseShowingEditors); } finally { // Re-enable listener. masterEditor.getScrollingModel().addVisibleAreaListener(this); } }
public DiffPanelImpl(final Window owner, 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(UIUtil.getBorderColor(), 1, 0, v ? 0 : 1, v ? 0 : 1)); myRightSide = new DiffSideView(this, new CustomLineBorder(UIUtil.getBorderColor(), v ? 0 : 1, v ? 0 : 1, 1, 0)); myLeftSide.becomeMaster(); myDiffUpdater = new Rediffers(this); 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(); if (defaultComparisonPolicy != null && comparisonPolicy != defaultComparisonPolicy) { setComparisonPolicy(defaultComparisonPolicy); } 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(); }
public void onEditorAreaChanged(VisibleAreaEvent e) { if (myInScrolling) return; recalculateMaxValues(); }
@Override public void visibleAreaChanged(VisibleAreaEvent e) { adjustTo(myIdx); }
@Override public void visibleAreaChanged(VisibleAreaEvent e) { if (mySyncScrollSupport != null) mySyncScrollSupport.visibleAreaChanged(e); myContentPanel.repaint(); }
@Override public void visibleAreaChanged(VisibleAreaEvent e) { redrawDiffs(); }
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(); }
@Override public void visibleAreaChanged(VisibleAreaEvent e) { checkFontRenderContext(null); }