use of com.intellij.openapi.ui.popup.BalloonBuilder in project intellij-community by JetBrains.
the class GotItMessage method show.
public void show(RelativePoint point, Balloon.Position position) {
if (myDisposable != null && Disposer.isDisposed(myDisposable)) {
return;
}
final GotItPanel panel = new GotItPanel();
panel.myTitle.setText(myTitle);
panel.myMessage.setText(myMessage);
if (myHyperlinkListener != null) {
panel.myMessage.addHyperlinkListener(myHyperlinkListener);
}
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);
}
use of com.intellij.openapi.ui.popup.BalloonBuilder in project intellij-community by JetBrains.
the class IdeTooltipManager method show.
private void show(final IdeTooltip tooltip, @Nullable Runnable beforeShow, boolean animationEnabled) {
boolean toCenterX;
boolean toCenterY;
boolean toCenter = tooltip.isToCenter();
boolean small = false;
if (!toCenter && tooltip.isToCenterIfSmall()) {
Dimension size = tooltip.getComponent().getSize();
toCenterX = size.width < 64;
toCenterY = size.height < 64;
toCenter = toCenterX || toCenterY;
small = true;
} else {
toCenterX = true;
toCenterY = true;
}
Point effectivePoint = tooltip.getPoint();
if (toCenter) {
Rectangle bounds = tooltip.getComponent().getBounds();
effectivePoint.x = toCenterX ? bounds.width / 2 : effectivePoint.x;
effectivePoint.y = toCenterY ? bounds.height / 2 : effectivePoint.y;
}
if (myCurrentComponent == tooltip.getComponent() && myCurrentTipUi != null && !myCurrentTipUi.isDisposed()) {
myCurrentTipUi.show(new RelativePoint(tooltip.getComponent(), effectivePoint), tooltip.getPreferredPosition());
return;
}
if (myCurrentComponent == tooltip.getComponent() && effectivePoint.equals(new Point(myX, myY))) {
return;
}
Color bg = tooltip.getTextBackground() != null ? tooltip.getTextBackground() : getTextBackground(true);
Color fg = tooltip.getTextForeground() != null ? tooltip.getTextForeground() : getTextForeground(true);
Color border = tooltip.getBorderColor() != null ? tooltip.getBorderColor() : getBorderColor(true);
BalloonBuilder builder = myPopupFactory.createBalloonBuilder(tooltip.getTipComponent()).setFillColor(bg).setBorderColor(border).setBorderInsets(tooltip.getBorderInsets()).setAnimationCycle(animationEnabled ? Registry.intValue("ide.tooltip.animationCycle") : 0).setShowCallout(true).setCalloutShift(small && tooltip.getCalloutShift() == 0 ? 2 : tooltip.getCalloutShift()).setPositionChangeXShift(tooltip.getPositionChangeX()).setPositionChangeYShift(tooltip.getPositionChangeY()).setHideOnKeyOutside(!tooltip.isExplicitClose()).setHideOnAction(!tooltip.isExplicitClose()).setRequestFocus(tooltip.isRequestFocus()).setLayer(tooltip.getLayer());
tooltip.getTipComponent().setForeground(fg);
tooltip.getTipComponent().setBorder(JBUI.Borders.empty(1, 3, 2, 3));
tooltip.getTipComponent().setFont(tooltip.getFont() != null ? tooltip.getFont() : getTextFont(true));
if (beforeShow != null) {
beforeShow.run();
}
myCurrentTipUi = (BalloonImpl) builder.createBalloon();
myCurrentTipUi.setAnimationEnabled(animationEnabled);
tooltip.setUi(myCurrentTipUi);
myCurrentComponent = tooltip.getComponent();
myX = effectivePoint.x;
myY = effectivePoint.y;
myCurrentTipIsCentered = toCenter;
myCurrentTooltip = tooltip;
myShowRequest = null;
myQueuedComponent = null;
myQueuedTooltip = null;
myLastDisposable = myCurrentTipUi;
Disposer.register(myLastDisposable, new Disposable() {
@Override
public void dispose() {
myLastDisposable = null;
}
});
myCurrentTipUi.show(new RelativePoint(tooltip.getComponent(), effectivePoint), tooltip.getPreferredPosition());
myAlarm.addRequest(() -> {
if (myCurrentTooltip == tooltip && tooltip.canBeDismissedOnTimeout()) {
hideCurrent(null, null, null);
}
}, tooltip.getDismissDelay());
}
use of com.intellij.openapi.ui.popup.BalloonBuilder in project intellij-community by JetBrains.
the class InplaceRefactoring method showBalloon.
protected void showBalloon() {
final JComponent component = getComponent();
if (component == null)
return;
if (ApplicationManager.getApplication().isHeadlessEnvironment())
return;
final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(component, null).setSmallVariant(true);
myBalloon = balloonBuilder.createBalloon();
Disposer.register(myProject, myBalloon);
Disposer.register(myBalloon, new Disposable() {
@Override
public void dispose() {
releaseIfNotRestart();
myEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);
}
});
EditorUtil.disposeWithEditor(myEditor, myBalloon);
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {
@Override
public RelativePoint recalculateLocation(Balloon object) {
if (myTarget != null && !popupFactory.isBestPopupLocationVisible(myEditor)) {
return myTarget;
}
if (myCaretRangeMarker != null && myCaretRangeMarker.isValid()) {
myEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, myEditor.offsetToVisualPosition(myCaretRangeMarker.getStartOffset()));
}
final RelativePoint target = popupFactory.guessBestPopupLocation(myEditor);
final Point screenPoint = target.getScreenPoint();
int y = screenPoint.y;
if (target.getPoint().getY() > myEditor.getLineHeight() + myBalloon.getPreferredSize().getHeight()) {
y -= myEditor.getLineHeight();
}
myTarget = new RelativePoint(new Point(screenPoint.x, y));
return myTarget;
}
}, Balloon.Position.above);
}
use of com.intellij.openapi.ui.popup.BalloonBuilder in project intellij-community by JetBrains.
the class PyStudyExecutor method showNoSdkNotification.
public void showNoSdkNotification(@NotNull final Project project) {
final String text = "<html>No Python interpreter configured for the project<br><a href=\"\">Configure interpreter</a></html>";
final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(text, null, MessageType.WARNING.getPopupBackground(), event -> {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
ApplicationManager.getApplication().invokeLater(() -> ShowSettingsUtil.getInstance().showSettingsDialog(project, "Project Interpreter"));
}
});
balloonBuilder.setHideOnLinkClick(true);
final Balloon balloon = balloonBuilder.createBalloon();
StudyUtils.showCheckPopUp(project, balloon);
}
Aggregations