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

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

Introduction

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

Prototype

void hide();

Source Link

Usage

From source file:com.intellij.execution.testframework.ResetConfigurationModuleAdapter.java

License:Apache License

@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
    final Module moduleByName = ModuleManager.getInstance(myProject).findModuleByName(e.getDescription());
    if (moduleByName != null) {
        myConfiguration.getConfigurationModule().setModule(moduleByName);
        try {//from  w  w  w .ja v  a  2  s  .  c o m
            Executor executor = myIsDebug ? DefaultDebugExecutor.getDebugExecutorInstance()
                    : DefaultRunExecutor.getRunExecutorInstance();
            ExecutionEnvironmentBuilder.create(myProject, executor, myConfiguration).contentToReuse(null)
                    .buildAndExecute();
            Balloon balloon = myToolWindowManager.getToolWindowBalloon(myTestRunDebugId);
            if (balloon != null) {
                balloon.hide();
            }
        } catch (ExecutionException e1) {
            LOG.error(e1);
        }
    }
}

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

License:Apache License

private static void requestBalloonHiding(final Balloon object) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override/*from   w w w .  ja  v a2 s  .c om*/
        public void run() {
            object.hide();
        }
    });
}

From source file:com.intellij.notification.Notification.java

License:Apache License

public void hideBalloon() {
    if (myBalloonRef != null) {
        final Balloon balloon = myBalloonRef.get();
        if (balloon != null) {
            balloon.hide();
        }//from   ww w.  jav a  2s  .c om
        myBalloonRef = null;
    }
}

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

License:Apache License

public static void hideToolWindowBalloon(@NotNull final String id, @NotNull final Project project) {
    invokeLaterIfProjectAlive(project, new Runnable() {
        @Override//from   www  .j  a  va 2 s  .co m
        public void run() {
            Balloon balloon = ToolWindowManager.getInstance(project).getToolWindowBalloon(id);
            if (balloon != null) {
                balloon.hide();
            }
        }
    });
}

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);//  w w w .j  a  v a  2  s  .c  om
    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.NotificationPopup.java

License:Apache License

public NotificationPopup(final JComponent owner, final JComponent content, Color backgroud,
        final boolean useDefaultPreferredSize, ActionListener clickHandler, boolean closeOnClick) {
    final IdeFrame frame = findFrame(owner);
    if (frame == null || !((Window) frame).isShowing() || frame.getBalloonLayout() == null) {
        final FramelessNotificationPopup popup = new FramelessNotificationPopup(owner, content, backgroud,
                useDefaultPreferredSize, clickHandler);

        myImpl = new Impl() {
            public void addListener(JBPopupListener listener) {
                popup.getPopup().addListener(listener);
            }//from  ww w.  j  a  va 2s. c om

            public void hide() {
                popup.getPopup().cancel();
            }
        };
    } else {
        final Wrapper wrapper = new NonOpaquePanel(content) {
            @Override
            public Dimension getPreferredSize() {
                final Dimension size = super.getPreferredSize();
                if (useDefaultPreferredSize) {
                    if (size.width > 400 || size.height > 200) {
                        size.width = 400;
                        size.height = 200;
                    }
                }
                return size;
            }
        };

        final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(wrapper).setFadeoutTime(5000)
                .setHideOnClickOutside(false).setHideOnFrameResize(false).setHideOnKeyOutside(false)
                .setCloseButtonEnabled(true).setFillColor(backgroud).setShowCallout(false)
                .setClickHandler(clickHandler, closeOnClick).createBalloon();

        BalloonLayout layout = frame.getBalloonLayout();
        assert layout != null;

        layout.add(balloon);

        myImpl = new Impl() {
            public void addListener(JBPopupListener listener) {
                balloon.addListener(listener);
            }

            public void hide() {
                balloon.hide();
            }
        };
    }
}

From source file:com.intellij.usages.impl.SearchForUsagesRunnable.java

License:Apache License

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(new Runnable() {
        @Override// w  w  w  . j a va  2  s .c  om
        public void run() {
            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(new Processor<Usage>() {
        @Override
        public boolean process(final Usage usage) {
            ProgressIndicator indicator = ProgressWrapper
                    .unwrap(ProgressManager.getInstance().getProgressIndicator());
            assert indicator != null : "must run find usages under progress";
            if (indicator.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(indicator);

                TooManyUsagesStatus tooManyUsagesStatus;
                if (usageCount > UsageLimitUtil.USAGES_LIMIT
                        && (tooManyUsagesStatus = TooManyUsagesStatus.getFrom(indicator))
                                .switchTooManyUsagesStatus()) {
                    UsageViewManagerImpl.showTooManyUsagesWarning(myProject, tooManyUsagesStatus, indicator,
                            myPresentation, usageCount, usageView);
                }

                if (usageView != null) {
                    ApplicationManager.getApplication().runReadAction(new Runnable() {
                        @Override
                        public void run() {
                            usageView.appendUsage(usage);
                        }
                    });
                }
            }
            return !indicator.isCanceled();
        }
    });
    if (getUsageView(indicator) != null) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
                myUsageViewManager.showToolWindow(true);
            }
        }, myProject.getDisposed());
    }
    Disposer.dispose(findUsagesStartedBalloon);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            if (findStartedBalloonShown.get()) {
                Balloon balloon = ToolWindowManager.getInstance(myProject)
                        .getToolWindowBalloon(ToolWindowId.FIND);
                if (balloon != null) {
                    balloon.hide();
                }
            }
        }
    }, myProject.getDisposed());
}

From source file:com.intellij.xdebugger.impl.ui.DebuggerUIUtil.java

License:Apache License

public static void showXBreakpointEditorBalloon(final Project project, @Nullable final Point point,
        final JComponent component, final boolean showAllOptions, final XBreakpoint breakpoint) {
    final XBreakpointManager breakpointManager = XDebuggerManager.getInstance(project).getBreakpointManager();
    final XLightBreakpointPropertiesPanel<XBreakpointBase<?, ?, ?>> propertiesPanel = new XLightBreakpointPropertiesPanel<XBreakpointBase<?, ?, ?>>(
            project, breakpointManager, (XBreakpointBase) breakpoint, showAllOptions);

    final Ref<Balloon> balloonRef = Ref.create(null);
    final Ref<Boolean> isLoading = Ref.create(Boolean.FALSE);
    final Ref<Boolean> moreOptionsRequested = Ref.create(Boolean.FALSE);

    propertiesPanel.setDelegate(new XLightBreakpointPropertiesPanel.Delegate() {
        @Override/* w  ww . j a  v  a2s. c o m*/
        public void showMoreOptions() {
            if (!isLoading.get()) {
                propertiesPanel.saveProperties();
            }
            if (!balloonRef.isNull()) {
                balloonRef.get().hide();
            }
            showXBreakpointEditorBalloon(project, point, component, true, breakpoint);
            moreOptionsRequested.set(true);
        }
    });

    isLoading.set(Boolean.TRUE);
    propertiesPanel.loadProperties();
    isLoading.set(Boolean.FALSE);

    if (moreOptionsRequested.get()) {
        return;
    }

    Runnable showMoreOptions = new Runnable() {
        @Override
        public void run() {
            propertiesPanel.saveProperties();
            propertiesPanel.dispose();
            BreakpointsDialogFactory.getInstance(project).showDialog(breakpoint);
        }
    };

    final JComponent mainPanel = propertiesPanel.getMainPanel();
    final Balloon balloon = showBreakpointEditor(project, mainPanel, point, component, showMoreOptions,
            breakpoint);
    balloonRef.set(balloon);

    final XBreakpointListener<XBreakpoint<?>> breakpointListener = new XBreakpointAdapter<XBreakpoint<?>>() {
        @Override
        public void breakpointRemoved(@NotNull XBreakpoint<?> removedBreakpoint) {
            if (removedBreakpoint.equals(breakpoint)) {
                balloon.hide();
            }
        }
    };

    balloon.addListener(new JBPopupListener.Adapter() {
        @Override
        public void onClosed(LightweightWindowEvent event) {
            propertiesPanel.saveProperties();
            propertiesPanel.dispose();
            breakpointManager.removeBreakpointListener(breakpointListener);
        }
    });

    breakpointManager.addBreakpointListener(breakpointListener);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            IdeFocusManager.findInstance().requestFocus(mainPanel, true);
        }
    });
}

From source file:com.intellij.xdebugger.impl.ui.DebuggerUIUtil.java

License:Apache License

public static Balloon showBreakpointEditor(Project project, final JComponent mainPanel, final Point whereToShow,
        final JComponent component, @Nullable final Runnable showMoreOptions, Object breakpoint) {
    final BreakpointEditor editor = new BreakpointEditor();
    editor.setPropertiesPanel(mainPanel);
    editor.setShowMoreOptionsLink(true);

    final JPanel panel = editor.getMainPanel();
    final Balloon balloon = JBPopupFactory.getInstance().createDialogBalloonBuilder(panel, null)
            .setHideOnClickOutside(true).setCloseButtonEnabled(false).setAnimationCycle(0)
            .setBlockClicksThroughBalloon(true).createBalloon();

    editor.setDelegate(new BreakpointEditor.Delegate() {
        @Override/*from   w  ww  . j  a va  2  s . co m*/
        public void done() {
            balloon.hide();
        }

        @Override
        public void more() {
            assert showMoreOptions != null;
            balloon.hide();
            showMoreOptions.run();
        }
    });

    if (whereToShow == null) {
        balloon.showInCenterOf(component);
    } else {
        //todo[kb] modify and move to BalloonImpl?
        final Window window = SwingUtilities.windowForComponent(component);
        final RelativePoint p = new RelativePoint(component, whereToShow);
        if (window != null) {
            final RelativePoint point = new RelativePoint(window, new Point(0, 0));
            if (p.getScreenPoint().getX() - point.getScreenPoint().getX() < 40) { // triangle + offsets is ~40px
                p.getPoint().x += 40;
            }
        }
        balloon.show(p, Balloon.Position.below);
    }

    BreakpointsDialogFactory.getInstance(project).setBalloonToHide(balloon, breakpoint);

    return balloon;
}

From source file:io.flutter.run.FlutterReloadManager.java

License:Open Source License

private void removeRunNotifications(FlutterApp app) {
    final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
    final Balloon balloon = ToolWindowManager.getInstance(myProject).getToolWindowBalloon(toolWindowId);
    if (balloon != null) {
        balloon.hide();
    }/*from  w w  w.  j  a  v  a2  s . c om*/
}