Java Code Examples for com.intellij.openapi.ui.popup.Balloon#getPreferredSize()

The following examples show how to use com.intellij.openapi.ui.popup.Balloon#getPreferredSize() . 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: DesktopBalloonLayoutImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 2
Source File: DesktopBalloonLayoutImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: AnnotateDiffViewerAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void showNotification(@Nonnull DiffViewerBase viewer, @Nonnull Notification notification) {
  JComponent component = viewer.getComponent();

  Window awtWindow = UIUtil.getWindow(component);

  if (awtWindow != null) {
    consulo.ui.Window uiWindow = TargetAWT.from(awtWindow);

    IdeFrame ideFrame = uiWindow.getUserData(IdeFrame.KEY);

    if (ideFrame != null && NotificationsManagerImpl.findWindowForBalloon(viewer.getProject()) == awtWindow) {
      notification.notify(viewer.getProject());
      return;
    }
  }

  Balloon balloon = NotificationsManagerImpl.createBalloon(component, notification, false, true, null, viewer);

  Dimension componentSize = component.getSize();
  Dimension balloonSize = balloon.getPreferredSize();

  int width = Math.min(balloonSize.width, componentSize.width);
  int height = Math.min(balloonSize.height, componentSize.height);

  // top-right corner, 20px to the edges
  RelativePoint point = new RelativePoint(component, new Point(componentSize.width - 20 - width / 2, 20 + height / 2));
  balloon.show(point, Balloon.Position.above);
}