Java Code Examples for com.intellij.openapi.editor.Editor#getContentComponent()
The following examples show how to use
com.intellij.openapi.editor.Editor#getContentComponent() .
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: MergePanel2.java From consulo with Apache License 2.0 | 6 votes |
@Override public void scrollEditors() { Editor centerEditor = getEditor(1); JComponent centerComponent = centerEditor.getContentComponent(); if (centerComponent.isShowing()) { IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(centerComponent); } int[] toLeft = getPrimaryBeginnings(myDividers[0].getPaint()); int[] toRight = getPrimaryBeginnings(myDividers[1].getPaint()); int line; if (toLeft.length > 0 && toRight.length > 0) { line = Math.min(toLeft[0], toRight[0]); } else if (toLeft.length > 0) { line = toLeft[0]; } else if (toRight.length > 0) { line = toRight[0]; } else { return; } SyncScrollSupport.scrollEditor(centerEditor, line); }
Example 2
Source File: PopupFactoryImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public RelativePoint guessBestPopupLocation(@Nonnull DataContext dataContext) { Component component = dataContext.getData(PlatformDataKeys.CONTEXT_COMPONENT); JComponent focusOwner = component instanceof JComponent ? (JComponent)component : null; if (focusOwner == null) { Project project = dataContext.getData(CommonDataKeys.PROJECT); JFrame frame = project == null ? null : WindowManager.getInstance().getFrame(project); focusOwner = frame == null ? null : frame.getRootPane(); if (focusOwner == null) { throw new IllegalArgumentException("focusOwner cannot be null"); } } final Point point = dataContext.getData(PlatformDataKeys.CONTEXT_MENU_POINT); if (point != null) { return new RelativePoint(focusOwner, point); } Editor editor = dataContext.getData(CommonDataKeys.EDITOR); if (editor != null && focusOwner == editor.getContentComponent()) { return guessBestPopupLocation(editor); } return guessBestPopupLocation(focusOwner); }
Example 3
Source File: MarkersPanel.java From emacsIDEAs with Apache License 2.0 | 5 votes |
private void setupLocationAndBoundsOfPanel(Editor editor) { this.setLocation(0, 0); Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); JComponent parent = editor.getContentComponent(); int x = (int) (parent.getLocation().getX() + visibleArea.getX() + editor.getScrollingModel().getHorizontalScrollOffset()); this.setBounds(x, (int) (visibleArea.getY()), (int) visibleArea.getWidth(), (int) visibleArea.getHeight()); }
Example 4
Source File: TestDataProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override public Object getData(@Nonnull Key<?> dataId) { if (myProject.isDisposed()) { throw new RuntimeException("TestDataProvider is already disposed for " + myProject + "\n" + "If you closed a project in test, please reset IdeaTestApplication.setDataProvider."); } if (CommonDataKeys.PROJECT == dataId) { return myProject; } else if (PlatformDataKeys.EDITOR == dataId || OpenFileDescriptor.NAVIGATE_IN_EDITOR == dataId) { return FileEditorManager.getInstance(myProject).getSelectedTextEditor(); } else { Editor editor = (Editor)getData(PlatformDataKeys.EDITOR); if (editor != null) { FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject); Object managerData = manager.getData(dataId, editor, editor.getCaretModel().getCurrentCaret()); if (managerData != null) { return managerData; } JComponent component = editor.getContentComponent(); if (component instanceof EditorComponentImpl) { return ((EditorComponentImpl)component).getData(dataId); } } return null; } }
Example 5
Source File: PopupFactoryImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public RelativePoint guessBestPopupLocation(@Nonnull Editor editor) { Point p = getVisibleBestPopupLocation(editor); if (p == null) { final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); p = new Point(visibleArea.x + visibleArea.width / 3, visibleArea.y + visibleArea.height / 2); } return new RelativePoint(editor.getContentComponent(), p); }
Example 6
Source File: DebuggerUIUtil.java From consulo with Apache License 2.0 | 5 votes |
@Deprecated public static RelativePoint calcPopupLocation(@Nonnull Editor editor, final int line) { Point p = editor.logicalPositionToXY(new LogicalPosition(line + 1, 0)); final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); if (!visibleArea.contains(p)) { p = new Point((visibleArea.x + visibleArea.width) / 2, (visibleArea.y + visibleArea.height) / 2); } return new RelativePoint(editor.getContentComponent(), p); }
Example 7
Source File: PropertyEditorPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
PropertyBalloonPositionTracker(Editor editor, TextRange range) { super(editor.getContentComponent()); myEditor = editor; myRange = range; }
Example 8
Source File: PropertyEditorPanel.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
PropertyBalloonPositionTracker(Editor editor, TextRange range) { super(editor.getContentComponent()); myEditor = editor; myRange = range; }
Example 9
Source File: DiffSideView.java From consulo with Apache License 2.0 | 4 votes |
public JComponent getFocusableComponent() { Editor editor = getEditor(); return editor != null ? editor.getContentComponent() : MOCK_COMPONENT; }
Example 10
Source File: HintHint.java From consulo with Apache License 2.0 | 4 votes |
public HintHint(Editor editor, Point point) { this(editor.getContentComponent(), point); }
Example 11
Source File: DebuggerUIUtil.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public static RelativePoint getPositionForPopup(@Nonnull Editor editor, int line) { Point p = editor.logicalPositionToXY(new LogicalPosition(line + 1, 0)); return editor.getScrollingModel().getVisibleArea().contains(p) ? new RelativePoint(editor.getContentComponent(), p) : null; }
Example 12
Source File: XDebuggerExpressionEditor.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nullable public JComponent getPreferredFocusedComponent() { final Editor editor = myEditorTextField.getEditor(); return editor != null ? editor.getContentComponent() : null; }
Example 13
Source File: IntentionHintComponent.java From consulo with Apache License 2.0 | 4 votes |
@Nullable private static Point getHintPosition(Editor editor) { if (ApplicationManager.getApplication().isUnitTestMode()) return new Point(); final int offset = editor.getCaretModel().getOffset(); final VisualPosition pos = editor.offsetToVisualPosition(offset); int line = pos.line; final Point position = editor.visualPositionToXY(new VisualPosition(line, 0)); LOG.assertTrue(editor.getComponent().isDisplayable()); JComponent convertComponent = editor.getContentComponent(); Point realPoint; final boolean oneLineEditor = editor.isOneLineMode(); if (oneLineEditor) { // place bulb at the corner of the surrounding component final JComponent contentComponent = editor.getContentComponent(); Container ancestorOfClass = SwingUtilities.getAncestorOfClass(JComboBox.class, contentComponent); if (ancestorOfClass != null) { convertComponent = (JComponent)ancestorOfClass; } else { ancestorOfClass = SwingUtilities.getAncestorOfClass(JTextField.class, contentComponent); if (ancestorOfClass != null) { convertComponent = (JComponent)ancestorOfClass; } } realPoint = new Point(-(AllIcons.Actions.RealIntentionBulb.getIconWidth() / 2) - 4, -(AllIcons.Actions.RealIntentionBulb.getIconHeight() / 2)); } else { Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); if (position.y < visibleArea.y || position.y >= visibleArea.y + visibleArea.height) return null; // try to place bulb on the same line int yShift = -(NORMAL_BORDER_SIZE + AllIcons.Actions.RealIntentionBulb.getIconHeight()); if (canPlaceBulbOnTheSameLine(editor)) { yShift = -(NORMAL_BORDER_SIZE + (AllIcons.Actions.RealIntentionBulb.getIconHeight() - editor.getLineHeight()) / 2 + 3); } else if (position.y < visibleArea.y + editor.getLineHeight()) { yShift = editor.getLineHeight() - NORMAL_BORDER_SIZE; } final int xShift = AllIcons.Actions.RealIntentionBulb.getIconWidth(); realPoint = new Point(Math.max(0, visibleArea.x - xShift), position.y + yShift); } Point location = SwingUtilities.convertPoint(convertComponent, realPoint, editor.getComponent().getRootPane().getLayeredPane()); return new Point(location.x, location.y); }
Example 14
Source File: LivePreview.java From consulo with Apache License 2.0 | 4 votes |
ReplacementBalloonPositionTracker(Editor editor) { super(editor.getContentComponent()); myEditor = editor; }
Example 15
Source File: NavBarPanel.java From consulo with Apache License 2.0 | 4 votes |
public void showHint(@Nullable final Editor editor, final DataContext dataContext) { myModel.updateModel(dataContext); if (myModel.isEmpty()) return; final JPanel panel = new JPanel(new BorderLayout()); panel.add(this); panel.setOpaque(true); panel.setBackground(UIUtil.getListBackground()); myHint = new LightweightHint(panel) { @Override public void hide() { super.hide(); cancelPopup(); Disposer.dispose(NavBarPanel.this); } }; myHint.setForceShowAsPopup(true); myHint.setFocusRequestor(this); final KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); myUpdateQueue.rebuildUi(); if (editor == null) { myContextComponent = dataContext.getData(PlatformDataKeys.CONTEXT_COMPONENT); getHintContainerShowPoint().doWhenDone((Consumer<RelativePoint>)relativePoint -> { final Component owner = focusManager.getFocusOwner(); final Component cmp = relativePoint.getComponent(); if (cmp instanceof JComponent && cmp.isShowing()) { myHint.show((JComponent)cmp, relativePoint.getPoint().x, relativePoint.getPoint().y, owner instanceof JComponent ? (JComponent)owner : null, new HintHint(relativePoint.getComponent(), relativePoint.getPoint())); } }); } else { myHintContainer = editor.getContentComponent(); getHintContainerShowPoint().doWhenDone((Consumer<RelativePoint>)rp -> { Point p = rp.getPointOn(myHintContainer).getPoint(); final HintHint hintInfo = new HintHint(editor, p); HintManagerImpl.getInstanceImpl().showEditorHint(myHint, editor, p, HintManager.HIDE_BY_ESCAPE, 0, true, hintInfo); }); } rebuildAndSelectTail(true); }