Example usage for com.intellij.openapi.ui.popup Balloon setAnimationEnabled

List of usage examples for com.intellij.openapi.ui.popup Balloon setAnimationEnabled

Introduction

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

Prototype

void setAnimationEnabled(boolean enabled);

Source Link

Usage

From source file:com.igormaznitsa.ideamindmap.utils.IdeaUtils.java

License:Apache License

public static void showPopup(@Nonnull final String text, @Nonnull final MessageType type) {
    SwingUtils.safeSwing(new Runnable() {
        @Override//www .  j ava2s.  co  m
        public void run() {
            final JBPopupFactory factory = JBPopupFactory.getInstance();
            final BalloonBuilder builder = factory
                    .createHtmlTextBalloonBuilder(StringEscapeUtils.escapeHtml(text), type, null);
            final Balloon balloon = builder.createBalloon();
            balloon.setAnimationEnabled(true);
            final Component frame = WindowManager.getInstance().findVisibleFrame();
            if (frame != null)
                balloon.show(new RelativePoint(frame, new Point(frame.getWidth(), frame.getHeight())),
                        Balloon.Position.below);
        }
    });
}

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 w  ww  . j  a va  2  s .c o  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.kstenschke.clearcache.ClearCacheAction.java

License:Apache License

/**
 * @param   event    ActionSystem event//from  w  w  w . j ava2s . c o m
 */
public void actionPerformed(AnActionEvent event) {
    String[] cachePaths = {};

    String cachePathsPrefString = ClearCachePreferences.getPaths();
    if (cachePathsPrefString != null && !cachePathsPrefString.isEmpty()) {
        cachePaths = StringHelper.extractTreePathStringsFromPref(cachePathsPrefString);
    }

    if (cachePaths == null || cachePaths.length == 0) {
        JOptionPane.showMessageDialog(null, "Please configure cache path(s) in the plugin preferences.");
    } else {
        Integer[] amountDeleted = this.clearFoldersContent(cachePaths);

        Balloon.Position pos = Balloon.Position.below;
        String balloonText = "Deleted " + amountDeleted[0] + " directories and " + amountDeleted[1] + " files";

        BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(balloonText, null,
                new Color(245, 245, 245), null);
        Balloon balloon = builder.createBalloon();
        balloon.setAnimationEnabled(true);

        Component eventComponent = event.getInputEvent().getComponent();
        Point componentLocation = eventComponent.getLocation();
        Integer x = new Double(componentLocation.getX()).intValue() + eventComponent.getWidth() + 40;
        Integer y = new Double(componentLocation.getY()).intValue() + eventComponent.getHeight() + 42;
        RelativePoint balloonPosition = new RelativePoint(new Point(x, y));

        balloon.show(balloonPosition, pos);
    }
}

From source file:com.kstenschke.sweep.SweepAction.java

License:Apache License

/**
 * @param event    ActionSystem event//from  www.j  a  v  a2s.  c  om
 */
public void actionPerformed(AnActionEvent event) {
    String[] sweepPaths = {};

    String sweepPathsPrefString = SweepPreferences.getPaths();
    if (sweepPathsPrefString != null && !sweepPathsPrefString.isEmpty()) {
        sweepPaths = StringHelper.extractTreePathStringsFromPref(sweepPathsPrefString);
    }

    if (sweepPaths == null || sweepPaths.length == 0) {
        JOptionPane.showMessageDialog(null, "Please configure path(s) to be swept in the plugin preferences.");
    } else {
        Integer[] amountDeleted = this.sweepFoldersContent(sweepPaths);

        Balloon.Position pos = Balloon.Position.below;
        String balloonText = "Deleted " + amountDeleted[1] + " files / " + amountDeleted[0] + " directories";

        JBColor backgroundColor = new JBColor(new Color(245, 245, 245), new Color(60, 63, 65));
        BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(balloonText, null,
                backgroundColor, null);
        Balloon balloon = builder.createBalloon();
        balloon.setAnimationEnabled(true);

        Component eventComponent = event.getInputEvent().getComponent();
        Point componentLocation = eventComponent.getLocation();
        Integer x = new Double(componentLocation.getX()).intValue() + eventComponent.getWidth() + 40;
        Integer y = new Double(componentLocation.getY()).intValue() + eventComponent.getHeight() + 42;
        RelativePoint balloonPosition = new RelativePoint(new Point(x, y));

        balloon.show(balloonPosition, pos);

        VirtualFileManager.getInstance().asyncRefresh(null);
    }
}