Java 类com.intellij.openapi.ui.popup.Balloon 实例源码

项目:hybris-integration-intellij-idea-plugin    文件:ExecuteHybrisConsole.java   
private void handleBadRequest(final HybrisHttpResult httpResult, final Project project) {
    if (httpResult.getStatusCode() != SC_OK) {
        final StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

        if (httpResult.getStatusCode() == SC_NOT_FOUND || httpResult.getStatusCode() == SC_MOVED_TEMPORARILY) {
            JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(
                "Hybris Host URL '" + httpResult.getErrorMessage() + "' was incorrect. Please, check your settings.",
                MessageType.ERROR,
                null
            ).setFadeoutTime(FADEOUT_TIME)
                          .createBalloon().show(
                RelativePoint.getCenterOf(statusBar.getComponent()),
                Balloon.Position.atRight
            );
        }
    }
}
项目:educational-plugin    文件:PyStudyShowTutorial.java   
@Override
public void projectOpened() {
  ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> ApplicationManager.getApplication().runWriteAction(
    (DumbAwareRunnable)() -> {
      if (PropertiesComponent.getInstance().getBoolean(ourShowPopup, true)) {
        final String content = "<html>If you'd like to learn more about PyCharm Edu, " +
                               "click <a href=\"https://www.jetbrains.com/pycharm-edu/quickstart/\">here</a> to watch a tutorial</html>";
        final Notification notification = new Notification("Watch Tutorials!", "", content, NotificationType.INFORMATION,
                                                           new NotificationListener.UrlOpeningListener(true));
        StartupManager.getInstance(myProject).registerPostStartupActivity(() -> Notifications.Bus.notify(notification));
        Balloon balloon = notification.getBalloon();
        if (balloon != null) {
          balloon.addListener(new JBPopupAdapter() {
            @Override
            public void onClosed(LightweightWindowEvent event) {
              notification.expire();
            }
          });
        }
        notification.whenExpired(() -> PropertiesComponent.getInstance().setValue(ourShowPopup, false, true));
      }
    }));
}
项目:GravSupport    文件:GravProjectGenerator.java   
@Override
public void generateProject(@NotNull Project project, @NotNull VirtualFile baseDir, @NotNull GravProjectSettings settings, @NotNull Module module) {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
    VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(settings.gravInstallationPath));
    if (vf == null || !GravSdkType.isValidGravSDK(vf)) {
        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder("Project couldn't be created because Grav Installation isn't valid", MessageType.ERROR, null)
                .setFadeoutTime(3500)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);
    } else {
        storage.setDefaultGravDownloadPath(settings.gravInstallationPath);
        PropertiesComponent.getInstance().setValue(LAST_USED_GRAV_HOME, new File(settings.gravInstallationPath).getAbsolutePath());
        GravProjectGeneratorUtil projectGenerator = new GravProjectGeneratorUtil();
        projectGenerator.generateProject(project, baseDir, settings, module);
        try {
            List<String> includePath = new ArrayList<>();
            includePath.add(baseDir.getPath());
            PhpIncludePathManager.getInstance(project).setIncludePath(includePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:GravSupport    文件:GravModuleBuilder.java   
@Override
    public void moduleCreated(@NotNull Module module) {
        StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
        String msg = String.format("Please wait while module for project %s is created", project.getName());
        settings = GravProjectSettings.getInstance(project);

        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder(msg, MessageType.WARNING, null)
                .setFadeoutTime(4000)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);

        VirtualFile[] roots1 = ModuleRootManager.getInstance(module).getContentRoots();
        if (roots1.length != 0) {
            final VirtualFile src = roots1[0];
            settings.withSrcDirectory = withSrcDirectory;
            settings.gravInstallationPath = getGravInstallPath().getPath();
//            settings.withSrcDirectory =
            GravProjectGeneratorUtil generatorUtil = new GravProjectGeneratorUtil();
            generatorUtil.generateProject(project, src, settings, module);
        }
    }
项目:intellij-idea-plugin-connector-for-aws-lambda    文件:MessageHelper.java   
private static void showMessage(final Project project, final MessageType messageType, final String format, final Object[] args) {
    StatusBar statusBar = windowManager.getStatusBar(project);
    if(statusBar == null || statusBar.getComponent() == null){
        return;
    }
    String message = String.format(format, args);
    jbPopupFactory.createHtmlTextBalloonBuilder(message, messageType, null)
                .setFadeoutTime(7500)
                .createBalloon()
                .show(RelativePoint.getNorthEastOf(statusBar.getComponent()), Balloon.Position.atRight);

    if(messageType == MessageType.INFO){
        log.info(message);
    }
    else if(messageType == MessageType.WARNING) {
        log.warn(message);
    }
    else{
        log.debug(message);
    }
}
项目:NetSuite-Tools-For-WebStorm    文件:UploadTask.java   
private void displayUploadResultBalloonMessage(String fileName, Boolean isSuccess) {
    String message = fileName + " Uploaded Successfully";
    MessageType messageType = MessageType.INFO;

    if (!isSuccess) {
        message = fileName + " Failed to Upload";
        messageType = MessageType.ERROR;
    }

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder("<h3>" + message + "</h3>", messageType, null)
            .setFadeoutTime(3000)
            .createBalloon()
            .show(RelativePoint.getNorthEastOf(WindowManager.getInstance().getIdeFrame(project).getComponent()),
                    Balloon.Position.above);
}
项目:gtm-jetbrains-plugin    文件:GTMProject.java   
private void installGtmWidget() {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
    if (statusBar != null) {
        statusBar.addWidget(myStatusWidget, myProject);
        myStatusWidget.installed();
        if (!GTMRecord.initGtmExePath()) {
            JBPopupFactory.getInstance()
                    .createHtmlTextBalloonBuilder(GTMConfig.getInstance().gtmNotFound, ERROR, null)
                    .setFadeoutTime(30000)
                    .createBalloon()
                    .show(RelativePoint.getSouthEastOf(statusBar.getComponent()),
                            Balloon.Position.atRight);
            return;
        }
        if (!GTMRecord.checkVersion()) {
            JBPopupFactory.getInstance()
                    .createHtmlTextBalloonBuilder(GTMConfig.getInstance().gtmVerOutdated, WARNING, null)
                    .setFadeoutTime(30000)
                    .createBalloon()
                    .show(RelativePoint.getSouthEastOf(statusBar.getComponent()),
                            Balloon.Position.atRight);
        }
    }
}
项目:samebug-idea-plugin    文件:IncomingChatInvitationPopupController.java   
public void showIncomingChatInvitation(@NotNull ChatInvitation chatInvitation, @NotNull IncomingChatInvitationNotification notification) {
    IncomingChatInvitationPopup.Model popupModel = IdeaSamebugPlugin.getInstance().conversionService.convertIncomingChatInvitationPopup(chatInvitation);
    IncomingChatInvitationPopup popup = new IncomingChatInvitationPopup(popupModel);
    IncomingChatInvitationPopupListener incomingChatInvitationPopupListener = new IncomingChatInvitationPopupListener(this, chatInvitation);
    ListenerService.putListenerToComponent(popup, IIncomingChatInvitationPopup.Listener.class, incomingChatInvitationPopupListener);

    BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(popup);
    balloonBuilder.setFillColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setContentInsets(new Insets(40, 0, 40, 0));
    balloonBuilder.setBorderInsets(new Insets(0, 0, 0, 0));
    balloonBuilder.setBorderColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setShadow(true);
    IdeFrame window = (IdeFrame) NotificationsManagerImpl.findWindowForBalloon(myProject);
    RelativePoint pointToShowPopup = null;
    if (window != null) pointToShowPopup = RelativePoint.getSouthEastOf(window.getComponent());
    Balloon balloon = balloonBuilder.createBalloon();
    balloon.show(pointToShowPopup, Balloon.Position.atLeft);

    TrackingService.trace(SwingRawEvent.notificationShow(popup));
}
项目:samebug-idea-plugin    文件:IncomingTipPopupController.java   
public void showIncomingChatInvitation(@NotNull IncomingAnswer incomingTip, @NotNull IncomingTipNotification notification) {
    IIncomingTipPopup.Model popupModel = IdeaSamebugPlugin.getInstance().conversionService.convertIncomingTipPopup(incomingTip);
    IncomingTipPopup popup = new IncomingTipPopup(popupModel);
    DataService.putData(popup, TrackingKeys.Location, new Locations.TipAnswerNotification(incomingTip.getSolution().getId()));

    BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(popup);
    balloonBuilder.setFillColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setContentInsets(new Insets(40, 0, 40, 0));
    balloonBuilder.setBorderInsets(new Insets(0, 0, 0, 0));
    balloonBuilder.setBorderColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setShadow(true);
    IdeFrame window = (IdeFrame) NotificationsManagerImpl.findWindowForBalloon(myProject);
    RelativePoint pointToShowPopup = null;
    if (window != null) pointToShowPopup = RelativePoint.getSouthEastOf(window.getComponent());
    Balloon balloon = balloonBuilder.createBalloon();
    data.put(popup, incomingTip);
    notifications.put(popup, notification);
    balloons.put(popup, balloon);
    balloon.show(pointToShowPopup, Balloon.Position.atLeft);

    TrackingService.trace(SwingRawEvent.notificationShow(popup));
}
项目:samebug-idea-plugin    文件:HelpRequestPopupController.java   
public void showIncomingHelpRequest(@NotNull IncomingHelpRequest helpRequest, @NotNull IncomingHelpRequestNotification notification) {
    IHelpRequestPopup.Model popupModel = IdeaSamebugPlugin.getInstance().conversionService.convertHelpRequestPopup(helpRequest);
    HelpRequestPopup popup = new HelpRequestPopup(popupModel);
    DataService.putData(popup, TrackingKeys.Location, new Locations.HelpRequestNotification(helpRequest.getMatch().getHelpRequest().getId()));
    DataService.putData(popup, TrackingKeys.WriteTipTransaction, Funnels.newTransactionId());
    HelpRequestPopupListener helpRequestPopupListener = new HelpRequestPopupListener(this);
    ListenerService.putListenerToComponent(popup, IHelpRequestPopup.Listener.class, helpRequestPopupListener);

    BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(popup);
    balloonBuilder.setFillColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setContentInsets(new Insets(40, 0, 40, 0));
    balloonBuilder.setBorderInsets(new Insets(0, 0, 0, 0));
    balloonBuilder.setBorderColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setShadow(true);
    IdeFrame window = (IdeFrame) NotificationsManagerImpl.findWindowForBalloon(myProject);
    RelativePoint pointToShowPopup = null;
    if (window != null) pointToShowPopup = RelativePoint.getSouthEastOf(window.getComponent());
    Balloon balloon = balloonBuilder.createBalloon();
    data.put(popup, helpRequest);
    notifications.put(popup, notification);
    balloons.put(popup, balloon);
    balloon.show(pointToShowPopup, Balloon.Position.atLeft);

    TrackingService.trace(SwingRawEvent.notificationShow(popup));
}
项目:intellij-ce-playground    文件:ResetConfigurationModuleAdapter.java   
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
  final Module moduleByName = ModuleManager.getInstance(myProject).findModuleByName(e.getDescription());
  if (moduleByName != null) {
    myConfiguration.getConfigurationModule().setModule(moduleByName);
    try {
      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);
    }
  }
}
项目:intellij-ce-playground    文件:DirDiffTableModel.java   
private void reportException(final String htmlContent) {
  Runnable balloonShower = new Runnable() {
    @Override
    public void run() {
      Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(htmlContent, MessageType.WARNING, null).
        setShowCallout(false).setHideOnClickOutside(true).setHideOnAction(true).setHideOnFrameResize(true).setHideOnKeyOutside(true).
        createBalloon();
      final Rectangle rect = myPanel.getPanel().getBounds();
      final Point p = new Point(rect.x + rect.width - 100, rect.y + 50);
      final RelativePoint point = new RelativePoint(myPanel.getPanel(), p);
      balloon.show(point, Balloon.Position.below);
      Disposer.register(myProject != null ? myProject : ApplicationManager.getApplication(), balloon);
    }
  };
  ApplicationManager.getApplication().invokeLater(balloonShower, new Condition() {
    @Override
    public boolean value(Object o) {
      return !(myProject == null || myProject.isDefault()) && ((!myProject.isOpen()) || myProject.isDisposed());
    }
  }
  );
}
项目:intellij-ce-playground    文件:PopupUtil.java   
public static void showBalloonForComponent(@NotNull Component component, @NotNull final String message, final MessageType type,
                                           final boolean atTop, @Nullable final Disposable disposable) {
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  if (popupFactory == null) return;
  BalloonBuilder balloonBuilder = popupFactory.createHtmlTextBalloonBuilder(message, type, null);
  balloonBuilder.setDisposable(disposable == null ? ApplicationManager.getApplication() : disposable);
  Balloon balloon = balloonBuilder.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);
}
项目:intellij-ce-playground    文件:ExternalSystemUiUtil.java   
/**
 * 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(@NotNull JComponent component, @NotNull MessageType messageType, @NotNull 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);
}
项目:intellij-ce-playground    文件:ToolWindowsWidget.java   
@Override
public void addNotify() {
  super.addNotify();
  final String key = "toolwindow.stripes.buttons.info.shown";
  if (UISettings.getInstance().HIDE_TOOL_STRIPES && !PropertiesComponent.getInstance().isTrueValue(key)) {
    PropertiesComponent.getInstance().setValue(key, String.valueOf(true));
    final Alarm alarm = new Alarm();
    alarm.addRequest(new Runnable() {
      @Override
      public void run() {
        GotItMessage.createMessage(UIBundle.message("tool.window.quick.access.title"), UIBundle.message(
          "tool.window.quick.access.message"))
          .setDisposable(ToolWindowsWidget.this)
          .show(new RelativePoint(ToolWindowsWidget.this, new Point(10, 0)), Balloon.Position.above);
        Disposer.dispose(alarm);
      }
    }, 20000);
  }
}
项目:intellij-ce-playground    文件:LightweightHint.java   
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;
  }
}
项目:intellij-ce-playground    文件:LightweightHint.java   
private static boolean fitsLayeredPane(JLayeredPane pane, JComponent component, RelativePoint desiredLocation, HintHint hintHint) {
  if (hintHint.isAwtTooltip()) {
    Dimension size = component.getPreferredSize();
    Dimension paneSize = pane.getSize();

    Point target = desiredLocation.getPointOn(pane).getPoint();
    Balloon.Position pos = hintHint.getPreferredPosition();
    int pointer = BalloonImpl.getPointerLength(pos, false) + BalloonImpl.getNormalInset();
    if (pos == Balloon.Position.above || pos == Balloon.Position.below) {
      boolean heightFit = target.y - size.height - pointer > 0 || target.y + size.height + pointer < paneSize.height;
      return heightFit && size.width + pointer < paneSize.width;
    }
    else {
      boolean widthFit = target.x - size.width - pointer > 0 || target.x + size.width + pointer < paneSize.width;
      return widthFit && size.height + pointer < paneSize.height;
    }
  }
  else {
    final Rectangle lpRect = new Rectangle(pane.getLocationOnScreen().x, pane.getLocationOnScreen().y, pane.getWidth(), pane.getHeight());
    Rectangle componentRect = new Rectangle(desiredLocation.getScreenPoint().x,
                                            desiredLocation.getScreenPoint().y,
                                            component.getPreferredSize().width,
                                            component.getPreferredSize().height);
    return lpRect.contains(componentRect);
  }
}
项目:intellij-ce-playground    文件:SlideComponent.java   
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));
  }
}
项目:intellij-ce-playground    文件:BalloonImpl.java   
@Override
public void show(PositionTracker<Balloon> tracker, Balloon.Position position) {
  AbstractPosition pos = BELOW;
  switch (position) {
    case atLeft:
      pos = AT_LEFT;
      break;
    case atRight:
      pos = AT_RIGHT;
      break;
    case below:
      pos = BELOW;
      break;
    case above:
      pos = ABOVE;
      break;
  }

  show(tracker, pos);
}
项目:intellij-ce-playground    文件:BalloonImpl.java   
private MyComponent(JComponent content, BalloonImpl balloon, EmptyBorder shapeBorder) {
  setOpaque(false);
  setLayout(null);
  myBalloon = balloon;

  setFocusCycleRoot(true);
  putClientProperty(Balloon.KEY, BalloonImpl.this);

  myContent = new JPanel(new BorderLayout(2, 2));
  Wrapper contentWrapper = new Wrapper(content);
  if (myTitle != null) {
    myTitleLabel = new JLabel(myTitle, SwingConstants.CENTER);
    myTitleLabel.setForeground(UIManager.getColor("List.background"));
    myTitleLabel.setBorder(new EmptyBorder(0, 4, 0, 4));
    myContent.add(myTitleLabel, BorderLayout.NORTH);
    contentWrapper.setBorder(new EmptyBorder(1, 1, 1, 1));
  }
  myContent.add(contentWrapper, BorderLayout.CENTER);
  myContent.setBorder(shapeBorder);
  myContent.setOpaque(false);

  add(myContent);


}
项目:intellij-ce-playground    文件:BalloonLayoutImpl.java   
private List<ArrayList<Balloon>> createColumns(Rectangle layoutRec) {
  List<ArrayList<Balloon>> columns = new ArrayList<ArrayList<Balloon>>();

  ArrayList<Balloon> eachColumn = new ArrayList<Balloon>();
  columns.add(eachColumn);

  int eachColumnHeight = 0;
  for (Balloon each : myBalloons) {
    final Dimension eachSize = each.getPreferredSize();
    if (eachColumnHeight + eachSize.height > layoutRec.getHeight()) {
      eachColumn = new ArrayList<Balloon>();
      columns.add(eachColumn);
      eachColumnHeight = 0;
    }
    eachColumn.add(each);
    eachColumnHeight += eachSize.height;
  }
  return columns;
}
项目:intellij-ce-playground    文件:IdeTooltipManager.java   
private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter, int shift, int posChangeX, int posChangeY) {
  String aText = String.valueOf(c.getToolTipText(me));
  final IdeTooltip tooltip = new IdeTooltip(c, me.getPoint(), null, /*new Object()*/c, aText) {
    @Override
    protected boolean beforeShow() {
      myCurrentEvent = me;

      if (!c.isShowing()) return false;

      String text = c.getToolTipText(myCurrentEvent);
      if (text == null || text.trim().isEmpty()) return false;

      JLayeredPane layeredPane = IJSwingUtilities.findParentOfType(c, JLayeredPane.class);

      final JEditorPane pane = initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane);
      final Wrapper wrapper = new Wrapper(pane);
      setTipComponent(wrapper);
      return true;
    }
  }.setToCenter(toCenter).setCalloutShift(shift).setPositionChangeShift(posChangeX, posChangeY).setLayer(Balloon.Layer.top);

  show(tooltip, false);
}
项目:intellij-ce-playground    文件:AnnotateDiffViewerAction.java   
private static void showNotification(@NotNull DiffViewerBase viewer, @NotNull Notification notification) {
  JComponent component = viewer.getComponent();

  Window window = UIUtil.getWindow(component);
  if (window instanceof IdeFrame && NotificationsManagerImpl.findWindowForBalloon(viewer.getProject()) == window) {
    notification.notify(viewer.getProject());
    return;
  }

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

  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);
}
项目:intellij-ce-playground    文件:ProjectStartupConfigurable.java   
private void addConfiguration(RunnerAndConfigurationSettings configuration) {
  if (!ProjectStartupRunner.canBeRun(configuration)) {
    final String message = "Can not add Run Configuration '" + configuration.getName() + "' to Startup Tasks," +
                           " since it can not be started with 'Run' action.";
    final Balloon balloon = JBPopupFactory.getInstance()
      .createHtmlTextBalloonBuilder(message, MessageType.ERROR, null)
      .setHideOnClickOutside(true)
      .setFadeoutTime(3000)
      .setCloseButtonEnabled(true)
      .createBalloon();
    final RelativePoint rp = new RelativePoint(myDecorator.getActionsPanel(), new Point(5, 5));
    balloon.show(rp, Balloon.Position.atLeft);
    return;
  }
  myModel.addConfiguration(configuration);
  refreshDataUpdateSelection(configuration);
}
项目:intellij-ce-playground    文件:LivePreview.java   
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();

  myReplacementBalloon.show(new ReplacementBalloonPositionTracker(editor), Balloon.Position.below);
}
项目:intellij-ce-playground    文件:PyStudyExecutor.java   
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(),
                                 new HyperlinkListener() {
                                   @Override
                                   public void hyperlinkUpdate(HyperlinkEvent event) {
                                     if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                                       ApplicationManager.getApplication()
                                         .invokeLater(new Runnable() {
                                           @Override
                                           public void run() {
                                             ShowSettingsUtil.getInstance().showSettingsDialog(project, "Project Interpreter");
                                           }
                                         });
                                     }
                                   }
                                 });
  balloonBuilder.setHideOnLinkClick(true);
  final Balloon balloon = balloonBuilder.createBalloon();
  StudyUtils.showCheckPopUp(project, balloon);
}
项目:intellij-ce-playground    文件:PyUtil.java   
/**
 * Shows an information balloon in a reasonable place at the top right of the window.
 *
 * @param project     our project
 * @param message     the text, HTML markup allowed
 * @param messageType message type, changes the icon and the background.
 */
// TODO: move to a better place
public static void showBalloon(Project project, String message, MessageType messageType) {
  // ripped from com.intellij.openapi.vcs.changes.ui.ChangesViewBalloonProblemNotifier
  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);

  JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(), messageType.getPopupBackground(), null)
    .setShowCallout(false).setCloseButtonEnabled(true)
    .createBalloon().show(point, Balloon.Position.atLeft);
}
项目:intellij-ce-playground    文件:EmmetPreviewHint.java   
public void showHint() {
  myParentEditor.putUserData(KEY, this);

  Pair<Point, Short> position = guessPosition();
  JRootPane pane = myParentEditor.getComponent().getRootPane();
  JComponent layeredPane = pane != null ? pane.getLayeredPane() : myParentEditor.getComponent();
  HintHint hintHint = new HintHint(layeredPane, position.first)
    .setAwtTooltip(true)
    .setContentActive(true)
    .setExplicitClose(true)
    .setShowImmediately(true)
    .setPreferredPosition(position.second == HintManager.ABOVE ? Balloon.Position.above : Balloon.Position.below)
    .setTextBg(myParentEditor.getColorsScheme().getDefaultBackground())
    .setBorderInsets(new Insets(1, 1, 1, 1));

  int hintFlags = HintManager.HIDE_BY_OTHER_HINT | HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING;
  HintManagerImpl.getInstanceImpl().showEditorHint(this, myParentEditor, position.first, hintFlags, 0, false, hintHint);
}
项目:intellij-ce-playground    文件:ColorPicker.java   
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));
  }
}
项目:dbunit-extractor    文件:CopyToDbUnit.java   
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);
}
项目:tools-idea    文件:PopupUtil.java   
public static void showBalloonForComponent(@NotNull Component component, @NotNull final String message, final MessageType type,
                                           final boolean atTop, @Nullable final Disposable disposable) {
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  if (popupFactory == null) return;
  BalloonBuilder balloonBuilder = popupFactory.createHtmlTextBalloonBuilder(message, type, null);
  balloonBuilder.setDisposable(disposable == null ? ApplicationManager.getApplication() : disposable);
  Balloon balloon = balloonBuilder.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);
}
项目:tools-idea    文件:ExternalSystemUiUtil.java   
/**
 * 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(@NotNull JComponent component, @NotNull MessageType messageType, @NotNull String message) {
  final BalloonBuilder builder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType, null)
    .setDisposable(ApplicationManager.getApplication())
    .setFadeoutTime(TimeUnit.SECONDS.toMillis(1));
  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);
}
项目:tools-idea    文件:LightweightHint.java   
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;
  }
}
项目:tools-idea    文件:LightweightHint.java   
private static boolean fitsLayeredPane(JLayeredPane pane, JComponent component, RelativePoint desiredLocation, HintHint hintHint) {
  if (hintHint.isAwtTooltip()) {
    Dimension size = component.getPreferredSize();
    Dimension paneSize = pane.getSize();

    Point target = desiredLocation.getPointOn(pane).getPoint();
    Balloon.Position pos = hintHint.getPreferredPosition();
    int pointer = BalloonImpl.getPointerLength(pos, false) + BalloonImpl.getNormalInset();
    if (pos == Balloon.Position.above || pos == Balloon.Position.below) {
      boolean heightFit = target.y - size.height - pointer > 0 || target.y + size.height + pointer < paneSize.height;
      return heightFit && size.width + pointer < paneSize.width;
    }
    else {
      boolean widthFit = target.x - size.width - pointer > 0 || target.x + size.width + pointer < paneSize.width;
      return widthFit && size.height + pointer < paneSize.height;
    }
  }
  else {
    final Rectangle lpRect = new Rectangle(pane.getLocationOnScreen().x, pane.getLocationOnScreen().y, pane.getWidth(), pane.getHeight());
    Rectangle componentRect = new Rectangle(desiredLocation.getScreenPoint().x,
                                            desiredLocation.getScreenPoint().y,
                                            component.getPreferredSize().width,
                                            component.getPreferredSize().height);
    return lpRect.contains(componentRect);
  }
}
项目:tools-idea    文件:SlideComponent.java   
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));
  }
}
项目:tools-idea    文件:BalloonImpl.java   
public void show(PositionTracker<Balloon> tracker, Balloon.Position position) {
  AbstractPosition pos = BELOW;
  switch (position) {
    case atLeft:
      pos = AT_LEFT;
      break;
    case atRight:
      pos = AT_RIGHT;
      break;
    case below:
      pos = BELOW;
      break;
    case above:
      pos = ABOVE;
      break;
  }

  show(tracker, pos);
}
项目:tools-idea    文件:BalloonImpl.java   
private MyComponent(JComponent content, BalloonImpl balloon, EmptyBorder shapeBorder) {
  setOpaque(false);
  setLayout(null);
  myBalloon = balloon;

  setFocusCycleRoot(true);
  putClientProperty(Balloon.KEY, BalloonImpl.this);

  myContent = new JPanel(new BorderLayout(2, 2));
  Wrapper contentWrapper = new Wrapper(content);
  if (myTitle != null) {
    myTitleLabel = new JLabel(myTitle, CENTER);
    myTitleLabel.setForeground(UIManager.getColor("List.background"));
    myTitleLabel.setBorder(new EmptyBorder(0, 4, 0, 4));
    myContent.add(myTitleLabel, BorderLayout.NORTH);
    contentWrapper.setBorder(new EmptyBorder(1, 1, 1, 1));
  }
  myContent.add(contentWrapper, BorderLayout.CENTER);
  myContent.setBorder(shapeBorder);
  myContent.setOpaque(false);

  add(myContent);


}
项目:tools-idea    文件:BalloonLayoutImpl.java   
private List<ArrayList<Balloon>> createColumns(Rectangle layoutRec) {
  List<ArrayList<Balloon>> columns = new ArrayList<ArrayList<Balloon>>();

  ArrayList<Balloon> eachColumn = new ArrayList<Balloon>();
  columns.add(eachColumn);

  int eachColumnHeight = 0;
  for (Balloon each : myBalloons) {
    final Dimension eachSize = each.getPreferredSize();
    if (eachColumnHeight + eachSize.height > layoutRec.getHeight()) {
      eachColumn = new ArrayList<Balloon>();
      columns.add(eachColumn);
      eachColumnHeight = 0;
    }
    eachColumn.add(each);
    eachColumnHeight += eachSize.height;
  }
  return columns;
}
项目:tools-idea    文件:IdeTooltipManager.java   
private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter, int shift, int posChangeX, int posChangeY) {
  final IdeTooltip tooltip = new IdeTooltip(c, me.getPoint(), null, new Object()) {
    @Override
    protected boolean beforeShow() {
      myCurrentEvent = me;

      if (!c.isShowing()) return false;

      String text = c.getToolTipText(myCurrentEvent);
      if (text == null || text.trim().isEmpty()) return false;

      JLayeredPane layeredPane = IJSwingUtilities.findParentOfType(c, JLayeredPane.class);

      final JEditorPane pane = initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane);
      final Wrapper wrapper = new Wrapper(pane);
      setTipComponent(wrapper);
      return true;
    }
  }.setToCenter(toCenter).setCalloutShift(shift).setPositionChangeShift(posChangeX, posChangeY).setLayer(Balloon.Layer.top);

  show(tooltip, false);
}
项目:tools-idea    文件:Highlighters.java   
public void show(JLayeredPane aPane, Rectangle aRectangle, DnDEvent aEvent) {
  if (!Registry.is("ide.dnd.textHints")) return;

  final String result = aEvent.getExpectedDropResult();
  if (result != null && result.length() > 0) {
    RelativePoint point  = null;
    for (DropTargetHighlighter each : ourHightlighters) {
      if (each instanceof AbstractComponentHighlighter) {
        Rectangle rec = ((AbstractComponentHighlighter)each).getBounds();
        point = new RelativePoint(aPane, new Point(rec.x + rec.width, rec.y + rec.height / 2));
        break;
      }
    }

    if (point == null) {
      point = new RelativePoint(aPane, new Point(aRectangle.x + aRectangle.width, aRectangle.y + aRectangle.height / 2));
    }

    myCurrentBalloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(result, myMessageType, null).createBalloon();
    myCurrentBalloon.show(point, Balloon.Position.atRight);
  }
}