@Override protected void paintComponent(@NotNull Graphics g) { super.paintComponent(g); if (UIUtil.isUnderDarcula()) { g.setColor(UIUtil.getControlColor().brighter()); g.fillRect(0, 0, getWidth(), getHeight()); } }
private static Color getButtonBackgroundColor() { Color color; if (isUsingDarculaUIFlavor()) { color = UIManager.getColor("ComboBox.darcula.arrowFillColor"); } else { color = UIManager.getColor("ComboBox.buttonBackground"); } return color == null ? UIUtil.getControlColor() : color; }
private void doPaint(Graphics g) { GraphicsUtil.setupAntialiasing(g); final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText()); final Dimension size = getSize(); if (isSmallVariant()) { final Graphics2D g2 = (Graphics2D) g; g2.setColor(UIUtil.getControlColor()); final int w = getWidth(); final int h = getHeight(); if (getModel().isArmed() && getModel().isPressed()) { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getControlColor(), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.8))); } else { g2.setPaint( new GradientPaint( 0, 0, ColorUtil.shift(UIUtil.getControlColor(), 1.1), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.9))); } g2.fillRect(2, 0, w - 2, h); GraphicsUtil.setupAntialiasing(g2); if (!myMouseInside) { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getBorderColor(), 0, h, UIUtil.getBorderColor().darker())); // g2.setColor(UIUtil.getBorderColor()); } else { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getBorderColor().darker(), 0, h, UIUtil.getBorderColor().darker().darker())); } g2.drawRect(2, 0, w - 3, h - 1); final Icon icon = getIcon(); int x = 7; if (icon != null) { icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2); x += icon.getIconWidth() + 3; } if (!StringUtil.isEmpty(getText())) { final Font font = getFont(); g2.setFont(font); g2.setColor(UIManager.getColor("Panel.foreground")); g2.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1); } } else { super.paintComponent(g); } final Insets insets = super.getInsets(); final Icon icon = isEnabled() ? ARROW_ICON : DISABLED_ARROW_ICON; final int x; if (isEmpty) { x = (size.width - icon.getIconWidth()) / 2; } else { if (isSmallVariant()) { x = size.width - icon.getIconWidth() - insets.right + 1; } else { x = size.width - icon.getIconWidth() - insets.right + (UIUtil.isUnderNimbusLookAndFeel() ? -3 : 2); } } if (UIUtil.isUnderDarcula()) { g.setXORMode(new Color(208, 188, 159)); } icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2); g.setPaintMode(); }
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)); } }