@Nullable JBTabs getTabsAt(RelativePoint point) { Point thisPoint = point.getPoint(this); Component c = SwingUtilities.getDeepestComponentAt(this, thisPoint.x, thisPoint.y); while (c != null) { if (c instanceof JBTabs) { return (JBTabs) c; } c = c.getParent(); } return null; }
@Override public void setLocation(@NotNull RelativePoint point) { if (isRealPopup()) { myPopup.setLocation(point.getScreenPoint()); } else { if (myCurrentIdeTooltip != null) { Point screenPoint = point.getScreenPoint(); if (!screenPoint.equals( new RelativePoint(myCurrentIdeTooltip.getComponent(), myCurrentIdeTooltip.getPoint()) .getScreenPoint())) { myCurrentIdeTooltip.setPoint(point.getPoint()); myCurrentIdeTooltip.setComponent(point.getComponent()); IdeTooltipManager.getInstance().show(myCurrentIdeTooltip, true, false); } } else { Point targetPoint = point.getPoint(myComponent.getParent()); myComponent.setLocation(targetPoint); myComponent.revalidate(); myComponent.repaint(); } } }
@Override public boolean update(DnDEvent aEvent) { aEvent.hideHighlighter(); aEvent.setDropPossible(false, ""); Object attached = aEvent.getAttachedObject(); if (!(attached instanceof ChangeListDragBean)) return false; final ChangeListDragBean dragBean = (ChangeListDragBean) attached; if (dragBean.getSourceComponent() != ChangesListView.this) return false; dragBean.setTargetNode(null); RelativePoint dropPoint = aEvent.getRelativePoint(); Point onTree = dropPoint.getPoint(ChangesListView.this); final TreePath dropPath = getPathForLocation(onTree.x, onTree.y); if (dropPath == null) return false; ChangesBrowserNode dropNode = (ChangesBrowserNode) dropPath.getLastPathComponent(); while (!((ChangesBrowserNode) dropNode.getParent()).isRoot()) { dropNode = (ChangesBrowserNode) dropNode.getParent(); } if (!dropNode.canAcceptDrop(dragBean)) { return false; } final Rectangle tableCellRect = getPathBounds(new TreePath(dropNode.getPath())); if (fitsInBounds(tableCellRect)) { aEvent.setHighlighting( new RelativeRectangle(ChangesListView.this, tableCellRect), DnDEvent.DropTargetHighlightingType.RECTANGLE); } aEvent.setDropPossible(true); dragBean.setTargetNode(dropNode); return false; }
public void navigate(int injectedOffset) { if (myAction.isShowInBalloon()) { final JComponent component = myAction.createBalloonComponent(myNewFile); if (component != null) { final Balloon balloon = JBPopupFactory.getInstance() .createBalloonBuilder(component) .setShadow(true) .setAnimationCycle(0) .setHideOnClickOutside(true) .setHideOnKeyOutside(true) .setHideOnAction(false) .setFillColor(UIUtil.getControlColor()) .createBalloon(); new AnAction() { @Override public void actionPerformed(AnActionEvent e) { balloon.hide(); } }.registerCustomShortcutSet(CommonShortcuts.ESCAPE, component); Disposer.register(myNewFile.getProject(), balloon); final Balloon.Position position = QuickEditAction.getBalloonPosition(myEditor); RelativePoint point = JBPopupFactory.getInstance().guessBestPopupLocation(myEditor); if (position == Balloon.Position.above) { final Point p = point.getPoint(); point = new RelativePoint( point.getComponent(), new Point(p.x, p.y - myEditor.getLineHeight())); } balloon.show(point, position); } } else { final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(myProject); final FileEditor[] editors = fileEditorManager.getEditors(myNewVirtualFile); if (editors.length == 0) { final EditorWindow curWindow = fileEditorManager.getCurrentWindow(); mySplittedWindow = curWindow.split(SwingConstants.HORIZONTAL, false, myNewVirtualFile, true); } Editor editor = fileEditorManager.openTextEditor( new OpenFileDescriptor(myProject, myNewVirtualFile, injectedOffset), true); // fold missing values if (editor != null) { editor.putUserData(QuickEditAction.QUICK_EDIT_HANDLER, this); final FoldingModel foldingModel = editor.getFoldingModel(); foldingModel.runBatchFoldingOperation( () -> { for (RangeMarker o : ContainerUtil.reverse(((DocumentEx) myNewDocument).getGuardedBlocks())) { String replacement = o.getUserData(REPLACEMENT_KEY); if (StringUtil.isEmpty(replacement)) continue; FoldRegion region = foldingModel.addFoldRegion(o.getStartOffset(), o.getEndOffset(), replacement); if (region != null) region.setExpanded(false); } }); } SwingUtilities.invokeLater( () -> myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE)); } }