com.intellij.openapi.ui.popup.Balloon Java Examples
The following examples show how to use
com.intellij.openapi.ui.popup.Balloon.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExternalSystemUiUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * Asks to show balloon that contains information related to the given component. * * @param component component for which we want to show information * @param messageType balloon message type * @param message message to show */ public static void showBalloon(@Nonnull JComponent component, @Nonnull MessageType messageType, @Nonnull String message) { final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType, null) .setDisposable(ApplicationManager.getApplication()) .setFadeoutTime(BALLOON_FADEOUT_TIME); Balloon balloon = builder.createBalloon(); Dimension size = component.getSize(); Balloon.Position position; int x; int y; if (size == null) { x = y = 0; position = Balloon.Position.above; } else { x = Math.min(10, size.width / 2); y = size.height; position = Balloon.Position.below; } balloon.show(new RelativePoint(component, new Point(x, y)), position); }
Example #2
Source File: CopyToDbUnit.java From dbunit-extractor with MIT License | 6 votes |
private void showPopup(DataContext dataContext, XmlOutput xmlOutput) { MessageType messageType = MessageType.INFO; String htmlMessage = ""; if (xmlOutput != null && xmlOutput.getRowSize() > 0 && xmlOutput.getColumnsSize() > 0) { if (xmlOutput.getTableName() == null || xmlOutput.getTableName().isEmpty()) { messageType = MessageType.WARNING; htmlMessage += "Table name is missing. Please try to synchronize database connection. <br/>"; } htmlMessage += "Copied: " + xmlOutput.getRowSize() + " entries (selected " + xmlOutput.getColumnsSize() + " columns)"; } else { messageType = MessageType.ERROR; if (xmlOutput == null) { htmlMessage = "Failed to copy entries. No grid available."; } else if (xmlOutput.getRowSize() <= 0) { htmlMessage = "No rows selected."; } else if (xmlOutput.getColumnsSize() <= 0) { htmlMessage = "No columns selected."; } } JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(htmlMessage, messageType, null) .setFadeoutTime(7500) .createBalloon().show(JBPopupFactory.getInstance().guessBestPopupLocation(dataContext), Balloon.Position.atRight); }
Example #3
Source File: UiUtils.java From Crucible4IDEA with MIT License | 6 votes |
public static void showBalloon(@NotNull final Project project, @NotNull final String message, @NotNull final MessageType messageType) { final JFrame frame = WindowManager.getInstance().getFrame(project.isDefault() ? null : project); if (frame == null) return; final JComponent component = frame.getRootPane(); if (component == null) return; final Rectangle rect = component.getVisibleRect(); final Point p = new Point(rect.x + rect.width - 10, rect.y + 10); final RelativePoint point = new RelativePoint(component, p); final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance(). createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(), messageType.getPopupBackground(), null); balloonBuilder.setShowCallout(false).setCloseButtonEnabled(true) .createBalloon().show(point, Balloon.Position.atLeft); }
Example #4
Source File: LivePreview.java From consulo with Apache License 2.0 | 6 votes |
private void showBalloon(Editor editor, String replacementPreviewText) { if (ApplicationManager.getApplication().isUnitTestMode()) { myReplacementPreviewText = replacementPreviewText; return; } ReplacementView replacementView = new ReplacementView(replacementPreviewText); BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(replacementView); balloonBuilder.setFadeoutTime(0); balloonBuilder.setFillColor(IdeTooltipManager.GRAPHITE_COLOR); balloonBuilder.setAnimationCycle(0); balloonBuilder.setHideOnClickOutside(false); balloonBuilder.setHideOnKeyOutside(false); balloonBuilder.setHideOnAction(false); balloonBuilder.setCloseButtonEnabled(true); myReplacementBalloon = balloonBuilder.createBalloon(); EditorUtil.disposeWithEditor(editor, myReplacementBalloon); myReplacementBalloon.show(new ReplacementBalloonPositionTracker(editor), Balloon.Position.below); }
Example #5
Source File: DesktopBalloonLayoutImpl.java From consulo with Apache License 2.0 | 6 votes |
private void relayout() { final Dimension size = myLayeredPane.getSize(); JBInsets.removeFrom(size, myInsets); final Rectangle layoutRec = new Rectangle(new Point(myInsets.left, myInsets.top), size); List<ArrayList<Balloon>> columns = createColumns(layoutRec); while (columns.size() > 1) { remove(myBalloons.get(0), true); columns = createColumns(layoutRec); } ToolWindowPanelImplEx pane = AWTComponentProviderUtil.findChild(myParent, ToolWindowPanelImplEx.class); JComponent layeredPane = pane != null ? pane.getMyLayeredPane() : null; int eachColumnX = (layeredPane == null ? myLayeredPane.getWidth() : layeredPane.getX() + layeredPane.getWidth()) - 4; doLayout(columns.get(0), eachColumnX + 4, (int)myLayeredPane.getBounds().getMaxY()); }
Example #6
Source File: ColorField.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
void showColorFieldPopup() { disposeColorPicker(); assert (colorPicker == null); colorPicker = ColorPickerProvider.EP_NAME.getExtensionList().get(0); if (colorPicker != null) { colorAtPopupLaunch = currentColor; final Insets insets = this.getInsets(); final Point bottomColorIconOffset = new Point(insets.left + setColorExtension.getIconGap(), this.getHeight() / 2); colorPicker .show(currentColor, this, bottomColorIconOffset, Balloon.Position.atLeft, this::colorListener, this::cancelPopup, this::applyColor); expressionAtPopupLaunch = getText(); } }
Example #7
Source File: QueryPanel.java From nosql4idea with Apache License 2.0 | 6 votes |
void notifyOnErrorForOperator(JComponent component, Exception ex) { String message; if (ex instanceof JSONParseException) { message = StringUtils.removeStart(ex.getMessage(), "\n"); } else { message = String.format("%s: %s", ex.getClass().getSimpleName(), ex.getMessage()); } NonOpaquePanel nonOpaquePanel = new NonOpaquePanel(); JTextPane textPane = Messages.configureMessagePaneUi(new JTextPane(), message); textPane.setFont(COURIER_FONT); textPane.setBackground(MessageType.ERROR.getPopupBackground()); nonOpaquePanel.add(textPane, BorderLayout.CENTER); nonOpaquePanel.add(new JLabel(MessageType.ERROR.getDefaultIcon()), BorderLayout.WEST); JBPopupFactory.getInstance().createBalloonBuilder(nonOpaquePanel) .setFillColor(MessageType.ERROR.getPopupBackground()) .createBalloon() .show(new RelativePoint(component, new Point(0, 0)), Balloon.Position.above); }
Example #8
Source File: LightweightHint.java From consulo with Apache License 2.0 | 6 votes |
private void fixActualPoint(Point actualPoint) { if (!isAwtTooltip()) return; if (!myIsRealPopup) return; Dimension size = myComponent.getPreferredSize(); Balloon.Position position = myHintHint.getPreferredPosition(); int shift = BalloonImpl.getPointerLength(position, false); switch (position) { case below: actualPoint.y += shift; break; case above: actualPoint.y -= (shift + size.height); break; case atLeft: actualPoint.x -= (shift + size.width); break; case atRight: actualPoint.y += shift; break; } }
Example #9
Source File: DesktopBalloonLayoutImpl.java From consulo with Apache License 2.0 | 6 votes |
private List<ArrayList<Balloon>> createColumns(Rectangle layoutRec) { List<ArrayList<Balloon>> columns = new ArrayList<>(); ArrayList<Balloon> eachColumn = new ArrayList<>(); columns.add(eachColumn); int eachColumnHeight = 0; for (Balloon each : myBalloons) { final Dimension eachSize = getSize(each); if (eachColumnHeight + eachSize.height > layoutRec.getHeight()) { eachColumn = new ArrayList<>(); columns.add(eachColumn); eachColumnHeight = 0; } eachColumn.add(each); eachColumnHeight += eachSize.height; } return columns; }
Example #10
Source File: SlideComponent.java From consulo with Apache License 2.0 | 6 votes |
private void updateBalloonText() { final Point point = myVertical ? new Point(0, myPointerValue) : new Point(myPointerValue, 0); myLabel.setText(myTitle + ": " + Unit.formatValue(myValue, myUnit)); if (myTooltipHint == null) { myTooltipHint = new LightweightHint(myLabel); myTooltipHint.setCancelOnClickOutside(false); myTooltipHint.setCancelOnOtherWindowOpen(false); final HintHint hint = new HintHint(this, point) .setPreferredPosition(myVertical ? Balloon.Position.atLeft : Balloon.Position.above) .setBorderColor(Color.BLACK) .setAwtTooltip(true) .setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD)) .setTextBg(HintUtil.INFORMATION_COLOR) .setShowImmediately(true); final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); myTooltipHint.show(this, point.x, point.y, owner instanceof JComponent ? (JComponent)owner : null, hint); } else { myTooltipHint.setLocation(new RelativePoint(this, point)); } }
Example #11
Source File: DesktopBalloonLayoutImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private Balloon merge(@Nullable Object data) { String mergeId = null; if (data instanceof String) { mergeId = (String)data; } else if (data instanceof BalloonLayoutData) { mergeId = ((BalloonLayoutData)data).groupId; } if (mergeId != null) { for (Map.Entry<Balloon, BalloonLayoutData> e : myLayoutData.entrySet()) { if (mergeId.equals(e.getValue().groupId)) { return e.getKey(); } } } return null; }
Example #12
Source File: DesktopBalloonLayoutImpl.java From consulo with Apache License 2.0 | 6 votes |
public void dispose() { myLayeredPane.removeComponentListener(myResizeListener); if (myLafListener != null) { LafManager.getInstance().removeLafManagerListener(myLafListener); myLafListener = null; } for (Balloon balloon : new ArrayList<>(myBalloons)) { Disposer.dispose(balloon); } myRelayoutAlarm.cancelAllRequests(); myBalloons.clear(); myLayoutData.clear(); myListeners.clear(); myLayeredPane = null; myParent = null; }
Example #13
Source File: IdeTooltip.java From consulo with Apache License 2.0 | 5 votes |
public IdeTooltip(Component component, Point point, JComponent tipComponent, Object... identity) { super(identity); myComponent = component; myPoint = point; myTipComponent = tipComponent; setPreferredPosition(Balloon.Position.above); }
Example #14
Source File: GraphTableController.java From consulo with Apache License 2.0 | 5 votes |
private boolean showTooltip(int row, int column, @Nonnull Point point, boolean now) { JComponent tipComponent = myCommitRenderer.getTooltip(myTable.getValueAt(row, column), calcPoint4Graph(point), row); if (tipComponent != null) { myTable.getExpandableItemsHandler().setEnabled(false); IdeTooltip tooltip = new IdeTooltip(myTable, point, new Wrapper(tipComponent)).setPreferredPosition(Balloon.Position.below); IdeTooltipManager.getInstance().show(tooltip, now); return true; } return false; }
Example #15
Source File: ToolSelectDialog.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void doOKAction() { try { myToolsPanel.apply(); } catch (IOException e) { String message = ToolsBundle.message("tools.failed.to.save.changes.0", StringUtil.decapitalize(e.getMessage())); final JLayeredPane pane = myToolsPanel.getRootPane().getLayeredPane(); JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, MessageType.ERROR, null) .setShowCallout(false).setFadeoutTime(3000).setHideOnAction(true).setHideOnClickOutside(true).setHideOnKeyOutside(true). createBalloon().show(new RelativePoint(pane, new Point(pane.getWidth(), 0)), Balloon.Position.above); return; } super.doOKAction(); }
Example #16
Source File: NavigationGutterIconRenderer.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess public void navigate(@Nullable final MouseEvent event, @Nullable final PsiElement elt) { final List<PsiElement> list = getTargetElements(); if (list.isEmpty()) { if (myEmptyText != null) { if (event != null) { final JComponent label = HintUtil.createErrorLabel(myEmptyText); label.setBorder(IdeBorderFactory.createEmptyBorder(2, 7, 2, 7)); JBPopupFactory.getInstance().createBalloonBuilder(label) .setFadeoutTime(3000) .setFillColor(HintUtil.ERROR_COLOR) .createBalloon() .show(new RelativePoint(event), Balloon.Position.above); } } return; } if (list.size() == 1) { PsiNavigateUtil.navigate(list.iterator().next()); } else { if (event != null) { final JBPopup popup = NavigationUtil.getPsiElementPopup(PsiUtilCore.toPsiElementArray(list), myCellRenderer.compute(), myPopupTitle); popup.show(new RelativePoint(event)); } } }
Example #17
Source File: RunPhpMetricsAction.java From PhpMetrics-jetbrains with MIT License | 5 votes |
private void inform(AnActionEvent e, String text, MessageType messageType) { StatusBar statusBar = WindowManager.getInstance() .getStatusBar(PlatformDataKeys.PROJECT.getData(e.getDataContext())); JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(text, messageType, null) .setFadeoutTime(7500) .createBalloon() .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight); }
Example #18
Source File: UsagePreviewPanel.java From consulo with Apache License 2.0 | 5 votes |
private static void showBalloon(Project project, Editor editor, TextRange range, @Nonnull FindModel findModel) { try { String replacementPreviewText = FindManager.getInstance(project).getStringToReplace(editor.getDocument().getText(range), findModel, range.getStartOffset(), editor.getDocument().getText()); if (!Registry.is("ide.find.show.replacement.hint.for.simple.regexp") && (Comparing.equal(replacementPreviewText, findModel.getStringToReplace()))) { return; } ReplacementView replacementView = new ReplacementView(replacementPreviewText); BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(replacementView); balloonBuilder.setFadeoutTime(0); balloonBuilder.setFillColor(IdeTooltipManager.GRAPHITE_COLOR); balloonBuilder.setAnimationCycle(0); balloonBuilder.setHideOnClickOutside(false); balloonBuilder.setHideOnKeyOutside(false); balloonBuilder.setHideOnAction(false); balloonBuilder.setCloseButtonEnabled(true); Balloon balloon = balloonBuilder.createBalloon(); EditorUtil.disposeWithEditor(editor, balloon); balloon.show(new ReplacementBalloonPositionTracker(project, editor, range, findModel), Balloon.Position.below); editor.putUserData(REPLACEMENT_BALLOON_KEY, balloon); } catch (FindManager.MalformedReplacementStringException e) { //Not a problem, just don't show balloon in this case } }
Example #19
Source File: ManageCodeStyleSchemesDialog.java From consulo with Apache License 2.0 | 5 votes |
private static void showStatus(final Component component, final String message, MessageType messageType) { BalloonBuilder balloonBuilder = JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(), messageType.getPopupBackground(), null); balloonBuilder.setFadeoutTime(5000); final Balloon balloon = balloonBuilder.createBalloon(); final Rectangle rect = component.getBounds(); final Point p = new Point(rect.x, rect.y + rect.height); final RelativePoint point = new RelativePoint(component, p); balloon.show(point, Balloon.Position.below); Disposer.register(ProjectManager.getInstance().getDefaultProject(), balloon); }
Example #20
Source File: DesktopBalloonLayoutImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private Dimension getSize(@Nonnull Balloon balloon) { BalloonLayoutData layoutData = myLayoutData.get(balloon); if (layoutData == null) { Dimension size = balloon.getPreferredSize(); return myWidth == null ? size : new Dimension(myWidth.i(), size.height); } return new Dimension(myWidth.i(), layoutData.height); }
Example #21
Source File: WelcomeDesktopBalloonLayoutImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void add(@Nonnull Balloon balloon, @Nullable Object layoutData) { if (layoutData instanceof BalloonLayoutData && ((BalloonLayoutData)layoutData).welcomeScreen) { addToPopup((BalloonImpl)balloon, (BalloonLayoutData)layoutData); } else { super.add(balloon, layoutData); } }
Example #22
Source File: HintManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
private static void doShowInGivenLocation(final LightweightHint hint, final Editor editor, Point p, HintHint hintInfo, boolean updateSize) { if (ApplicationManager.getApplication().isUnitTestMode()) return; JComponent externalComponent = getExternalComponent(editor); Dimension size = updateSize ? hint.getComponent().getPreferredSize() : hint.getComponent().getSize(); if (hint.isRealPopup() || hintInfo.isPopupForced()) { final Point point = new Point(p); SwingUtilities.convertPointToScreen(point, externalComponent); final Rectangle editorScreen = ScreenUtil.getScreenRectangle(point.x, point.y); p = new Point(p); if (hintInfo.getPreferredPosition() == Balloon.Position.atLeft) { p.x -= size.width; } SwingUtilities.convertPointToScreen(p, externalComponent); final Rectangle rectangle = new Rectangle(p, size); ScreenUtil.moveToFit(rectangle, editorScreen, null); p = rectangle.getLocation(); SwingUtilities.convertPointFromScreen(p, externalComponent); if (hintInfo.getPreferredPosition() == Balloon.Position.atLeft) { p.x += size.width; } } else if (externalComponent.getWidth() < p.x + size.width && !hintInfo.isAwtTooltip()) { p.x = Math.max(0, externalComponent.getWidth() - size.width); } if (hint.isVisible()) { if (updateSize) { hint.pack(); } hint.updatePosition(hintInfo.getPreferredPosition()); hint.updateLocation(p.x, p.y); } else { hint.show(externalComponent, p.x, p.y, editor.getContentComponent(), hintInfo); } }
Example #23
Source File: Notification.java From consulo with Apache License 2.0 | 5 votes |
public void setBalloon(@Nonnull final Balloon balloon) { hideBalloon(); myBalloonRef = new WeakReference<>(balloon); balloon.addListener(new JBPopupAdapter() { @Override public void onClosed(LightweightWindowEvent event) { if (SoftReference.dereference(myBalloonRef) == balloon) { myBalloonRef = null; } } }); }
Example #24
Source File: SettingsForm.java From PhpMetrics-jetbrains with MIT License | 5 votes |
private void inform(JComponent target, String text, MessageType messageType) { JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(text, messageType, null) .setFadeoutTime(2000) .createBalloon() .show(RelativePoint.getNorthEastOf(target), Balloon.Position.atRight); }
Example #25
Source File: QueryToXMLConverter.java From dbunit-extractor with MIT License | 5 votes |
private void showPopup(final Editor editor, final MessageType messageType, final String message) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(message, messageType, null) .setFadeoutTime(7500) .createBalloon() .show(JBPopupFactory.getInstance().guessBestPopupLocation(editor), Balloon.Position.atRight); } }); }
Example #26
Source File: LightweightHint.java From consulo with Apache License 2.0 | 5 votes |
public void updatePosition(Balloon.Position position) { if (myHintHint != null) { myHintHint.setPreferredPosition(position); } if (myCurrentIdeTooltip != null) { myCurrentIdeTooltip.setPreferredPosition(position); } }
Example #27
Source File: GLSLDeduceExpressionTypeAction.java From glsl4idea with GNU Lesser General Public License v3.0 | 5 votes |
private void showBalloon(AnActionEvent e, String html) { final Editor editor = e.getData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE); if(editor == null) return; final JBPopupFactory factory = JBPopupFactory.getInstance(); final BalloonBuilder builder = factory.createBalloonBuilder(new JLabel(html)); Balloon balloon = builder.createBalloon(); RelativePoint position = factory.guessBestPopupLocation(editor); balloon.show(position, Balloon.Position.below); }
Example #28
Source File: Toast.java From GsonFormat with Apache License 2.0 | 5 votes |
/** * Display simple notification of given type * * @param project * @param type * @param text */ public static void make(Project project, MessageType type, String text) { StatusBar statusBar = WindowManager.getInstance().getStatusBar(project); JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(text, type, null) .setFadeoutTime(7500) .createBalloon() .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight); }
Example #29
Source File: Toast.java From GsonFormat with Apache License 2.0 | 5 votes |
/** * Display simple notification of given type * * @param project * @param type * @param text */ public static void make(Project project, JComponent jComponent, MessageType type, String text) { StatusBar statusBar = WindowManager.getInstance().getStatusBar(project); JBPopupFactory.getInstance() .createHtmlTextBalloonBuilder(text, type, null) .setFadeoutTime(7500) .createBalloon() .show(RelativePoint.getCenterOf(jComponent), Balloon.Position.above); }
Example #30
Source File: IdeaUtils.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
public static void showPopup(@Nonnull final String text, @Nonnull final MessageType type) { SwingUtils.safeSwing(new Runnable() { @Override 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); } } }); }