Example usage for com.intellij.openapi.ui.popup BalloonBuilder setFillColor

List of usage examples for com.intellij.openapi.ui.popup BalloonBuilder setFillColor

Introduction

In this page you can find the example usage for com.intellij.openapi.ui.popup BalloonBuilder setFillColor.

Prototype

@NotNull
    BalloonBuilder setFillColor(@NotNull Color color);

Source Link

Usage

From source file:com.intellij.find.impl.livePreview.LivePreview.java

License:Apache License

private void showBalloon(Editor editor, String replacementPreviewText) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        myReplacementPreviewText = replacementPreviewText;
        return;//from   w  w  w .  j a v  a 2s  . c o  m
    }

    ReplacementView replacementView = new ReplacementView(replacementPreviewText);

    BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(replacementView);
    balloonBuilder.setFadeoutTime(0);
    balloonBuilder.setFillColor(IdeTooltipManager.GRAPHITE_COLOR);
    balloonBuilder.setAnimationCycle(0);
    balloonBuilder.setHideOnClickOutside(false);
    balloonBuilder.setHideOnKeyOutside(false);
    balloonBuilder.setHideOnAction(false);
    balloonBuilder.setCloseButtonEnabled(true);
    myReplacementBalloon = balloonBuilder.createBalloon();

    myReplacementBalloon.show(new ReplacementBalloonPositionTracker(editor), Balloon.Position.above);
}

From source file:com.intellij.notification.impl.NotificationsManagerImpl.java

License:Apache License

public static Balloon createBalloon(@NotNull final IdeFrame window, final Notification notification,
        final boolean showCallout, final boolean hideOnClickOutside) {
    final JEditorPane text = new JEditorPane();
    text.setEditorKit(UIUtil.getHTMLEditorKit());

    final HyperlinkListener listener = NotificationsUtil.wrapListener(notification);
    if (listener != null) {
        text.addHyperlinkListener(listener);
    }//from   www.jav a  2  s  .co m

    final JLabel label = new JLabel(NotificationsUtil.buildHtml(notification, null));
    text.setText(NotificationsUtil.buildHtml(notification,
            "width:" + Math.min(350, label.getPreferredSize().width) + "px;"));
    text.setEditable(false);
    text.setOpaque(false);

    if (UIUtil.isUnderNimbusLookAndFeel()) {
        text.setBackground(UIUtil.TRANSPARENT_COLOR);
    }

    text.setBorder(null);

    final JPanel content = new NonOpaquePanel(
            new BorderLayout((int) (label.getIconTextGap() * 1.5), (int) (label.getIconTextGap() * 1.5)));

    if (text.getCaret() != null) {
        text.setCaretPosition(0);
    }
    JScrollPane pane = ScrollPaneFactory.createScrollPane(text,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    pane.setBorder(null);
    pane.setOpaque(false);
    pane.getViewport().setOpaque(false);
    content.add(pane, BorderLayout.CENTER);

    final NonOpaquePanel north = new NonOpaquePanel(new BorderLayout());
    north.add(new JLabel(NotificationsUtil.getIcon(notification)), BorderLayout.NORTH);
    content.add(north, BorderLayout.WEST);

    content.setBorder(new EmptyBorder(2, 4, 2, 4));

    Dimension preferredSize = text.getPreferredSize();
    text.setSize(preferredSize);

    Dimension paneSize = new Dimension(text.getPreferredSize());
    int maxHeight = Math.min(400, window.getComponent().getHeight() - 20);
    int maxWidth = Math.min(600, window.getComponent().getWidth() - 20);
    if (paneSize.height > maxHeight) {
        pane.setPreferredSize(
                new Dimension(Math.min(maxWidth, paneSize.width + UIUtil.getScrollBarWidth()), maxHeight));
    } else if (paneSize.width > maxWidth) {
        pane.setPreferredSize(new Dimension(maxWidth, paneSize.height + UIUtil.getScrollBarWidth()));
    }

    final BalloonBuilder builder = JBPopupFactory.getInstance().createBalloonBuilder(content);
    builder.setFillColor(new JBColor(Gray._234, Gray._92)).setCloseButtonEnabled(true)
            .setShowCallout(showCallout).setShadow(false).setHideOnClickOutside(hideOnClickOutside)
            .setHideOnAction(hideOnClickOutside).setHideOnKeyOutside(hideOnClickOutside)
            .setHideOnFrameResize(false).setBorderColor(new JBColor(Gray._180, Gray._110));

    final Balloon balloon = builder.createBalloon();
    balloon.setAnimationEnabled(false);
    notification.setBalloon(balloon);
    return balloon;
}

From source file:com.intellij.ui.GotItMessage.java

License:Apache License

public void show(RelativePoint point, Balloon.Position position) {
    final GotItPanel panel = new GotItPanel();
    panel.myTitle.setText(myTitle);//from  ww w. jav a 2 s.  c o  m
    panel.myMessage.setText(myMessage);

    panel.myButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    final BalloonBuilder builder = JBPopupFactory.getInstance().createBalloonBuilder(panel.myRoot);
    if (myDisposable != null) {
        builder.setDisposable(myDisposable);
    }

    final Balloon balloon = builder.setFillColor(UIUtil.getListBackground()).setHideOnClickOutside(false)
            .setHideOnAction(false).setHideOnFrameResize(false).setHideOnKeyOutside(false)
            .setShowCallout(myShowCallout).setBlockClicksThroughBalloon(true).createBalloon();
    panel.myButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            balloon.hide();
            if (myCallback != null) {
                myCallback.run();
            }
        }
    });

    balloon.show(point, position);
}

From source file:com.intellij.ui.popup.PopupFactoryImpl.java

License:Apache License

@NotNull
@Override//from   w w w . j  a  va  2s . c o  m
public BalloonBuilder createHtmlTextBalloonBuilder(@NotNull final String htmlContent, @Nullable final Icon icon,
        final Color fillColor, @Nullable final HyperlinkListener listener) {

    JEditorPane text = IdeTooltipManager.initPane(htmlContent, new HintHint().setAwtTooltip(true), null);

    if (listener != null) {
        text.addHyperlinkListener(listener);
    }
    text.setEditable(false);
    NonOpaquePanel.setTransparent(text);
    text.setBorder(null);

    JLabel label = new JLabel();
    final JPanel content = new NonOpaquePanel(
            new BorderLayout((int) (label.getIconTextGap() * 1.5), (int) (label.getIconTextGap() * 1.5)));

    final NonOpaquePanel textWrapper = new NonOpaquePanel(new GridBagLayout());
    JScrollPane scrolledText = new JScrollPane(text);
    scrolledText.setBackground(fillColor);
    scrolledText.getViewport().setBackground(fillColor);
    scrolledText.getViewport().setBorder(null);
    scrolledText.setBorder(null);
    textWrapper.add(scrolledText);
    content.add(textWrapper, BorderLayout.CENTER);

    final NonOpaquePanel north = new NonOpaquePanel(new BorderLayout());
    north.add(new JLabel(icon), BorderLayout.NORTH);
    content.add(north, BorderLayout.WEST);

    content.setBorder(new EmptyBorder(2, 4, 2, 4));

    final BalloonBuilder builder = createBalloonBuilder(content);

    builder.setFillColor(fillColor);

    return builder;
}