Search in sources :

Example 6 with Balloon

use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.

the class CheckRegExpForm method setBalloonState.

void setBalloonState(RegExpMatchResult result) {
    mySampleText.setBackground(result == RegExpMatchResult.MATCHES ? BACKGROUND_COLOR_MATCH : BACKGROUND_COLOR_NOMATCH);
    switch(result) {
        case MATCHES:
            myMessage.setText("Matches!");
            break;
        case NO_MATCH:
            myMessage.setText("No match");
            break;
        case TIMEOUT:
            myMessage.setText("Pattern is too complex");
            break;
        case BAD_REGEXP:
            myMessage.setText("Bad pattern");
            break;
    }
    myRootPanel.revalidate();
    Balloon balloon = JBPopupFactory.getInstance().getParentBalloonFor(myRootPanel);
    if (balloon != null && !balloon.isDisposed())
        balloon.revalidate();
}
Also used : Balloon(com.intellij.openapi.ui.popup.Balloon)

Example 7 with Balloon

use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.

the class SearchForUsagesRunnable method searchUsages.

private void searchUsages(@NotNull final AtomicBoolean findStartedBalloonShown) {
    ProgressIndicator indicator = ProgressWrapper.unwrap(ProgressManager.getInstance().getProgressIndicator());
    assert indicator != null : "must run find usages under progress";
    TooManyUsagesStatus.createFor(indicator);
    Alarm findUsagesStartedBalloon = new Alarm();
    findUsagesStartedBalloon.addRequest(() -> {
        notifyByFindBalloon(null, MessageType.WARNING, myProcessPresentation, myProject, Collections.singletonList(StringUtil.escapeXml(UsageViewManagerImpl.getProgressTitle(myPresentation))));
        findStartedBalloonShown.set(true);
    }, 300, ModalityState.NON_MODAL);
    UsageSearcher usageSearcher = mySearcherFactory.create();
    usageSearcher.generate(usage -> {
        ProgressIndicator indicator1 = ProgressWrapper.unwrap(ProgressManager.getInstance().getProgressIndicator());
        assert indicator1 != null : "must run find usages under progress";
        if (indicator1.isCanceled())
            return false;
        if (!UsageViewManagerImpl.isInScope(usage, mySearchScopeToWarnOfFallingOutOf)) {
            myOutOfScopeUsages.incrementAndGet();
            return true;
        }
        boolean incrementCounter = !UsageViewManager.isSelfUsage(usage, mySearchFor);
        if (incrementCounter) {
            final int usageCount = myUsageCountWithoutDefinition.incrementAndGet();
            if (usageCount == 1 && !myProcessPresentation.isShowPanelIfOnlyOneUsage()) {
                myFirstUsage.compareAndSet(null, usage);
            }
            final UsageViewImpl usageView = getUsageView(indicator1);
            TooManyUsagesStatus tooManyUsagesStatus = TooManyUsagesStatus.getFrom(indicator1);
            if (usageCount > UsageLimitUtil.USAGES_LIMIT && tooManyUsagesStatus.switchTooManyUsagesStatus()) {
                UsageViewManagerImpl.showTooManyUsagesWarning(myProject, tooManyUsagesStatus, indicator1, myPresentation, usageCount, usageView);
            }
            tooManyUsagesStatus.pauseProcessingIfTooManyUsages();
            if (usageView != null) {
                ApplicationManager.getApplication().runReadAction(() -> usageView.appendUsage(usage));
            }
        }
        return !indicator1.isCanceled();
    });
    if (getUsageView(indicator) != null) {
        ApplicationManager.getApplication().invokeLater(() -> myUsageViewManager.showToolWindow(true), myProject.getDisposed());
    }
    Disposer.dispose(findUsagesStartedBalloon);
    ApplicationManager.getApplication().invokeLater(() -> {
        if (findStartedBalloonShown.get()) {
            Balloon balloon = ToolWindowManager.getInstance(myProject).getToolWindowBalloon(ToolWindowId.FIND);
            if (balloon != null) {
                balloon.hide();
            }
        }
    }, myProject.getDisposed());
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) Alarm(com.intellij.util.Alarm) Balloon(com.intellij.openapi.ui.popup.Balloon) TooManyUsagesStatus(com.intellij.openapi.progress.util.TooManyUsagesStatus)

Example 8 with Balloon

use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.

the class BalloonImpl method createComponent.

private void createComponent() {
    myComp = new MyComponent(myContent, this, myShadowBorderProvider != null ? null : myShowPointer ? myPosition.createBorder(this) : getPointlessBorder());
    if (myActionProvider == null) {
        final Consumer<MouseEvent> listener = event -> {
            SwingUtilities.invokeLater(() -> hide());
        };
        myActionProvider = new ActionProvider() {

            private ActionButton myCloseButton;

            @NotNull
            @Override
            public List<ActionButton> createActions() {
                myCloseButton = new CloseButton(listener);
                return Collections.singletonList(myCloseButton);
            }

            @Override
            public void layout(@NotNull Rectangle lpBounds) {
                if (!myCloseButton.isVisible()) {
                    return;
                }
                Icon icon = getCloseButton();
                int iconWidth = icon.getIconWidth();
                int iconHeight = icon.getIconHeight();
                Rectangle r = new Rectangle(lpBounds.x + lpBounds.width - iconWidth + (int) (iconWidth * 0.3), lpBounds.y - (int) (iconHeight * 0.3), iconWidth, iconHeight);
                Insets border = getShadowBorderInsets();
                r.x -= border.left;
                r.y -= border.top;
                myCloseButton.setBounds(r);
            }
        };
    }
    myComp.clear();
    myComp.myAlpha = isAnimationEnabled() ? 0f : -1;
    myComp.setBorder(new EmptyBorder(getShadowBorderInsets()));
    myLayeredPane.add(myComp);
    // the second balloon must be over the first one
    myLayeredPane.setLayer(myComp, getLayer(), 0);
    myPosition.updateBounds(this);
    if (myBlockClicks) {
        myComp.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                e.consume();
            }

            @Override
            public void mousePressed(MouseEvent e) {
                e.consume();
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                e.consume();
            }
        });
    }
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) AccessibleContextUtil(com.intellij.util.ui.accessibility.AccessibleContextUtil) Wrapper(com.intellij.ui.components.panels.Wrapper) AllIcons(com.intellij.icons.AllIcons) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Area(java.awt.geom.Area) Rectangle2D(java.awt.geom.Rectangle2D) HashSet(com.intellij.util.containers.HashSet) FocusRequestor(com.intellij.openapi.wm.FocusRequestor) ShadowBorderPainter(com.intellij.openapi.ui.impl.ShadowBorderPainter) Balloon(com.intellij.openapi.ui.popup.Balloon) RGBImageFilter(java.awt.image.RGBImageFilter) LightweightWindowEvent(com.intellij.openapi.ui.popup.LightweightWindowEvent) IdeGlassPaneUtil(com.intellij.openapi.wm.IdeGlassPaneUtil) NonOpaquePanel(com.intellij.ui.components.panels.NonOpaquePanel) BufferedImage(java.awt.image.BufferedImage) com.intellij.ide(com.intellij.ide) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) com.intellij.util.ui(com.intellij.util.ui) java.awt.event(java.awt.event) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ApplicationManager(com.intellij.openapi.application.ApplicationManager) EmptyBorder(javax.swing.border.EmptyBorder) Registry(com.intellij.openapi.util.registry.Registry) GeneralPath(java.awt.geom.GeneralPath) NotNull(org.jetbrains.annotations.NotNull) RelativePoint(com.intellij.ui.awt.RelativePoint) ImageFilter(java.awt.image.ImageFilter) Consumer(com.intellij.util.Consumer) DataContext(com.intellij.openapi.actionSystem.DataContext) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig) ScreenReader(com.intellij.util.ui.accessibility.ScreenReader) ActionManager(com.intellij.openapi.actionSystem.ActionManager) AnActionListener(com.intellij.openapi.actionSystem.ex.AnActionListener) JdkConstants(org.intellij.lang.annotations.JdkConstants) JBPopupListener(com.intellij.openapi.ui.popup.JBPopupListener) AnAction(com.intellij.openapi.actionSystem.AnAction) java.awt(java.awt) MnemonicHelper(com.intellij.openapi.MnemonicHelper) ObjectUtils(com.intellij.util.ObjectUtils) IdeGlassPaneEx(com.intellij.openapi.wm.impl.IdeGlassPaneEx) Collections(java.util.Collections) Alarm(com.intellij.util.Alarm) javax.swing(javax.swing) NotNull(org.jetbrains.annotations.NotNull) List(java.util.List) EmptyBorder(javax.swing.border.EmptyBorder)

Example 9 with Balloon

use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.

the class BalloonLayoutImpl method add.

@Override
public void add(@NotNull final Balloon balloon, @Nullable Object layoutData) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    Balloon merge = merge(layoutData);
    if (merge == null) {
        if (getVisibleCount() > 0 && layoutData instanceof BalloonLayoutData && ((BalloonLayoutData) layoutData).groupId != null) {
            int index = -1;
            int count = 0;
            for (int i = 0, size = myBalloons.size(); i < size; i++) {
                BalloonLayoutData ld = myLayoutData.get(myBalloons.get(i));
                if (ld != null && ld.groupId != null) {
                    if (index == -1) {
                        index = i;
                    }
                    count++;
                }
            }
            if (count > 0 && count == getVisibleCount()) {
                remove(myBalloons.get(index));
            }
        }
        myBalloons.add(balloon);
    } else {
        int index = myBalloons.indexOf(merge);
        remove(merge);
        myBalloons.add(index, balloon);
    }
    if (layoutData instanceof BalloonLayoutData) {
        BalloonLayoutData balloonLayoutData = (BalloonLayoutData) layoutData;
        balloonLayoutData.closeAll = myCloseAll;
        balloonLayoutData.doLayout = myLayoutRunnable;
        myLayoutData.put(balloon, balloonLayoutData);
    }
    Disposer.register(balloon, new Disposable() {

        public void dispose() {
            clearNMore(balloon);
            remove(balloon, false);
            queueRelayout();
        }
    });
    if (myLafListener == null && layoutData != null) {
        myLafListener = new LafManagerListener() {

            @Override
            public void lookAndFeelChanged(LafManager source) {
                for (BalloonLayoutData layoutData : myLayoutData.values()) {
                    if (layoutData.lafHandler != null) {
                        layoutData.lafHandler.run();
                    }
                }
            }
        };
        LafManager.getInstance().addLafManagerListener(myLafListener);
    }
    calculateSize();
    relayout();
    if (!balloon.isDisposed()) {
        balloon.show(myLayeredPane);
    }
    fireRelayout();
}
Also used : Disposable(com.intellij.openapi.Disposable) Balloon(com.intellij.openapi.ui.popup.Balloon) LafManager(com.intellij.ide.ui.LafManager) LafManagerListener(com.intellij.ide.ui.LafManagerListener)

Example 10 with Balloon

use of com.intellij.openapi.ui.popup.Balloon in project intellij-community by JetBrains.

the class BalloonLayoutImpl method calculateSize.

private void calculateSize() {
    myWidth = null;
    for (Balloon balloon : myBalloons) {
        BalloonLayoutData layoutData = myLayoutData.get(balloon);
        if (layoutData != null) {
            layoutData.height = balloon.getPreferredSize().height;
        }
    }
    myWidth = BalloonLayoutConfiguration.FixedWidth;
}
Also used : Balloon(com.intellij.openapi.ui.popup.Balloon)

Aggregations

Balloon (com.intellij.openapi.ui.popup.Balloon)40 RelativePoint (com.intellij.ui.awt.RelativePoint)14 BalloonBuilder (com.intellij.openapi.ui.popup.BalloonBuilder)11 IdeFrame (com.intellij.openapi.wm.IdeFrame)5 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)4 Disposable (com.intellij.openapi.Disposable)3 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)3 LightweightWindowEvent (com.intellij.openapi.ui.popup.LightweightWindowEvent)3 BalloonImpl (com.intellij.ui.BalloonImpl)3 HyperlinkEvent (javax.swing.event.HyperlinkEvent)3 Executor (com.intellij.execution.Executor)2 Notification (com.intellij.notification.Notification)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 BalloonLayout (com.intellij.ui.BalloonLayout)2 Alarm (com.intellij.util.Alarm)2 java.awt (java.awt)2 MouseEvent (java.awt.event.MouseEvent)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2