List of usage examples for com.intellij.openapi.ui.popup Balloon isDisposed
boolean isDisposed();
From source file:com.android.tools.idea.gradle.editor.ui.ReferencedValuesGradleEditorComponent.java
License:Apache License
public ReferencedValuesGradleEditorComponent() { super(new GridBagLayout()); final JBLabel label = new JBLabel("<~>"); label.setCursor(new Cursor(Cursor.HAND_CURSOR)); setBackground(GradleEditorUiConstants.BACKGROUND_COLOR); TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme() .getAttributes(EditorColors.FOLDED_TEXT_ATTRIBUTES); if (attributes != null) { Color color = attributes.getForegroundColor(); if (color != null) { label.setForeground(color);// ww w. j a v a 2 s.c o m } } add(label, new GridBag()); label.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { WeakReference<Project> projectRef = myProjectRef; if (projectRef == null) { return; } Project project = projectRef.get(); if (project == null) { return; } final Ref<Balloon> balloonRef = new Ref<Balloon>(); Content content = new Content(project, new Runnable() { @Override public void run() { Balloon balloon = balloonRef.get(); if (balloon != null && !balloon.isDisposed()) { Disposer.dispose(balloon); balloonRef.set(null); } } }); BalloonBuilder builder = JBPopupFactory.getInstance().createBalloonBuilder(content) .setDisposable(project).setShowCallout(false) .setAnimationCycle(GradleEditorUiConstants.ANIMATION_TIME_MILLIS) .setFillColor(JBColor.border()); Balloon balloon = builder.createBalloon(); balloonRef.set(balloon); balloon.show(new RelativePoint(label, new Point(label.getWidth() / 2, label.getHeight())), Balloon.Position.atRight); } }); }
From source file:com.intellij.notification.impl.NotificationsManagerImpl.java
License:Apache License
@Nullable private static Balloon notifyByBalloon(final Notification notification, final NotificationDisplayType displayType, @Nullable final Project project) { if (isDummyEnvironment()) return null; Window window = findWindowForBalloon(project); if (window instanceof IdeFrame) { final ProjectManager projectManager = ProjectManager.getInstance(); final boolean noProjects = projectManager.getOpenProjects().length == 0; final boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects; final Balloon balloon = createBalloon((IdeFrame) window, notification, false, false); Disposer.register(project != null ? project : ApplicationManager.getApplication(), balloon); if (notification.isExpired()) { return null; }//ww w. ja v a 2 s. com BalloonLayout layout = ((IdeFrame) window).getBalloonLayout(); if (layout == null) return null; layout.add(balloon); ((BalloonImpl) balloon).startFadeoutTimer(0); if (NotificationDisplayType.BALLOON == displayType) { FrameStateManager.getInstance().getApplicationActive().doWhenDone(new Runnable() { @Override public void run() { if (balloon.isDisposed()) { return; } if (!sticky) { ((BalloonImpl) balloon).startFadeoutTimer(0); ((BalloonImpl) balloon).setHideOnClickOutside(true); } else //noinspection ConstantConditions if (noProjects) { projectManager.addProjectManagerListener(new ProjectManagerAdapter() { @Override public void projectOpened(Project project) { projectManager.removeProjectManagerListener(this); if (!balloon.isDisposed()) { ((BalloonImpl) balloon).startFadeoutTimer(300); } } }); } } }); } return balloon; } return null; }
From source file:com.intellij.ui.popup.BalloonPopupBuilderImpl.java
License:Apache License
@NotNull @Override/* w w w. j a v a2 s .c o m*/ public Balloon createBalloon() { final BalloonImpl result = new BalloonImpl(myContent, myBorder, myBorderInsets, myFill, myHideOnMouseOutside, myHideOnKeyOutside, myHideOnAction, myShowCallout, myCloseButtonEnabled, myFadeoutTime, myHideOnFrameResize, myHideOnLinkClick, myClickHandler, myCloseOnClick, myAnimationCycle, myCalloutShift, myPositionChangeXShift, myPositionChangeYShift, myDialogMode, myTitle, myContentInsets, myShadow, mySmallVariant, myBlockClicks, myLayer); if (myStorage != null && myAnchor != null) { List<Balloon> balloons = myStorage.get(myAnchor); if (balloons == null) { myStorage.put(myAnchor, balloons = new ArrayList<Balloon>()); Disposer.register(myAnchor, new Disposable() { @Override public void dispose() { List<Balloon> toDispose = myStorage.remove(myAnchor); if (toDispose != null) { for (Balloon balloon : toDispose) { if (!balloon.isDisposed()) { Disposer.dispose(balloon); } } } } }); } balloons.add(result); result.addListener(new JBPopupAdapter() { @Override public void onClosed(LightweightWindowEvent event) { if (!result.isDisposed()) { Disposer.dispose(result); } } }); } return result; }