Java 类com.intellij.ui.HintHint 实例源码

项目:intellij-ce-playground    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor,
                        @NotNull Point p,
                        @NotNull TooltipRenderer tooltipRenderer,
                        boolean alignToRight,
                        @NotNull TooltipGroup group,
                        @NotNull HintHint hintInfo) {
  if (myCurrentTooltip == null || !myCurrentTooltip.isVisible()) {
    myCurrentTooltipObject = null;
  }

  if (Comparing.equal(tooltipRenderer, myCurrentTooltipObject)) {
    IdeTooltipManager.getInstance().cancelAutoHide();
    return;
  }
  if (myCurrentTooltipGroup != null && group.compareTo(myCurrentTooltipGroup) < 0) return;

  p = new Point(p);
  hideCurrentTooltip();

  LightweightHint hint = tooltipRenderer.show(editor, p, alignToRight, group, hintInfo);

  myCurrentTooltipGroup = group;
  myCurrentTooltip = hint;
  myCurrentTooltipObject = tooltipRenderer;
}
项目:intellij-ce-playground    文件:UIUtil.java   
static void showTooltip(@NotNull Editor editor, final int start, int end, @NotNull String text) {
  final Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
  final Point left = editor.logicalPositionToXY(editor.offsetToLogicalPosition(start));
  final int documentLength = editor.getDocument().getTextLength();
  if (end >= documentLength) end = documentLength;
  final Point right = editor.logicalPositionToXY(editor.offsetToLogicalPosition(end));

  final Point bestPoint = new Point(left.x + (right.x - left.x) / 2, right.y + editor.getLineHeight() / 2);

  if (visibleArea.x > bestPoint.x) {
    bestPoint.x = visibleArea.x;
  }
  else if (visibleArea.x + visibleArea.width < bestPoint.x) {
    bestPoint.x = visibleArea.x + visibleArea.width - 5;
  }

  final Point p = SwingUtilities.convertPoint(editor.getContentComponent(), bestPoint,
                                              editor.getComponent().getRootPane().getLayeredPane());
  final HintHint hint = new HintHint(editor, bestPoint).setAwtTooltip(true).setHighlighterType(true).setShowImmediately(true)
    .setCalloutShift(editor.getLineHeight() / 2 - 1);
  TooltipController.getInstance().showTooltip(editor, p, text, visibleArea.width, false, SS_INFO_TOOLTIP_GROUP, hint);
}
项目:intellij-ce-playground    文件:TrafficTooltipRendererImpl.java   
@Override
public LightweightHint show(@NotNull Editor editor, @NotNull Point p, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) {
  myTrafficLightRenderer = (TrafficLightRenderer)((EditorMarkupModelImpl)editor.getMarkupModel()).getErrorStripeRenderer();
  myPanel = new TrafficProgressPanel(myTrafficLightRenderer, editor, hintHint);
  repaintTooltipWindow();
  LineTooltipRenderer.correctLocation(editor, myPanel, p, alignToRight, true, myPanel.getMinWidth());
  LightweightHint hint = new LightweightHint(myPanel);

  HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance();
  hintManager.showEditorHint(hint, editor, p,
                             HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT |
                             HintManager.HIDE_BY_SCROLLING, 0, false, hintHint);
  hint.addHintListener(new HintListener() {
    @Override
    public void hintHidden(EventObject event) {
      if (myPanel == null) return; //double hide?
      myPanel = null;
      onHide.run();
    }
  });
  return hint;
}
项目:intellij-ce-playground    文件:DaemonTooltipUtil.java   
public static void showInfoTooltip(@NotNull final HighlightInfo info, @NotNull Editor editor, final int defaultOffset, final int currentWidth) {
  if (info.getToolTip() == null) return;
  Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();

  Point bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
  bestPoint.y += editor.getLineHeight() / 2;

  if (!visibleArea.contains(bestPoint)) {
    bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
  }

  Point p = SwingUtilities.convertPoint(
    editor.getContentComponent(),
    bestPoint,
    editor.getComponent().getRootPane().getLayeredPane()
  );

  TooltipController.getInstance().showTooltip(editor, p, info.getToolTip(), currentWidth, false, DAEMON_INFO_GROUP, new HintHint(editor, bestPoint).setAwtTooltip(true).setHighlighterType(true).setCalloutShift(
    editor.getLineHeight() / 2 - 1));
}
项目:intellij-ce-playground    文件:IntentionHintComponent.java   
@Override
public void show(@NotNull final JComponent parentComponent,
                 final int x,
                 final int y,
                 final JComponent focusBackComponent,
                 @NotNull HintHint hintHint) {
  myVisible = true;
  if (myShouldDelay) {
    myAlarm.cancelAllRequests();
    myAlarm.addRequest(new Runnable() {
      @Override
      public void run() {
        showImpl(parentComponent, x, y, focusBackComponent);
      }
    }, DELAY);
  }
  else {
    showImpl(parentComponent, x, y, focusBackComponent);
  }
}
项目: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);
}
项目:tools-idea    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor,
                        @NotNull Point p,
                        @NotNull TooltipRenderer tooltipRenderer,
                        boolean alignToRight,
                        @NotNull TooltipGroup group,
                        @NotNull HintHint hintInfo) {
  if (myCurrentTooltip == null || !myCurrentTooltip.isVisible()) {
    myCurrentTooltipObject = null;
  }

  if (Comparing.equal(tooltipRenderer, myCurrentTooltipObject)) {
    IdeTooltipManager.getInstance().cancelAutoHide();
    return;
  }
  if (myCurrentTooltipGroup != null && group.compareTo(myCurrentTooltipGroup) < 0) return;

  p = new Point(p);
  hideCurrentTooltip();

  LightweightHint hint = tooltipRenderer.show(editor, p, alignToRight, group, hintInfo);

  myCurrentTooltipGroup = group;
  myCurrentTooltip = hint;
  myCurrentTooltipObject = tooltipRenderer;
}
项目:tools-idea    文件:TrafficTooltipRendererImpl.java   
@Override
public LightweightHint show(@NotNull Editor editor, @NotNull Point p, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) {
  myTrafficLightRenderer = (TrafficLightRenderer)((EditorMarkupModelImpl)editor.getMarkupModel()).getErrorStripeRenderer();
  myPanel = new TrafficProgressPanel(myTrafficLightRenderer, editor, hintHint);
  LineTooltipRenderer.correctLocation(editor, myPanel, p, alignToRight, false, -1);
  LightweightHint hint = new LightweightHint(myPanel);

  HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance();
  hintManager.showEditorHint(hint, editor, p,
                             HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT |
                             HintManager.HIDE_BY_SCROLLING, 0, false, hintHint);
  hint.addHintListener(new HintListener() {
    @Override
    public void hintHidden(EventObject event) {
      if (myPanel == null) return; //double hide?
      myPanel = null;
      onHide.run();
    }
  });
  repaintTooltipWindow();
  return hint;
}
项目:tools-idea    文件:DaemonTooltipUtil.java   
public static void showInfoTooltip(@NotNull final HighlightInfo info, @NotNull Editor editor, final int defaultOffset, final int currentWidth) {
  if (info.getToolTip() == null) return;
  Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();

  Point bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
  bestPoint.y += editor.getLineHeight() / 2;

  if (!visibleArea.contains(bestPoint)) {
    bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
  }

  Point p = SwingUtilities.convertPoint(
    editor.getContentComponent(),
    bestPoint,
    editor.getComponent().getRootPane().getLayeredPane()
  );

  TooltipController.getInstance().showTooltip(editor, p, info.getToolTip(), currentWidth, false, DAEMON_INFO_GROUP, new HintHint(editor, bestPoint).setAwtTooltip(true).setHighlighterType(true).setCalloutShift(
    editor.getLineHeight() / 2 - 1));
}
项目:tools-idea    文件:IntentionHintComponent.java   
@Override
public void show(@NotNull final JComponent parentComponent,
                 final int x,
                 final int y,
                 final JComponent focusBackComponent,
                 @NotNull HintHint hintHint) {
  myVisible = true;
  if (myShouldDelay) {
    myAlarm.cancelAllRequests();
    myAlarm.addRequest(new Runnable() {
      @Override
      public void run() {
        showImpl(parentComponent, x, y, focusBackComponent);
      }
    }, DELAY);
  }
  else {
    showImpl(parentComponent, x, y, focusBackComponent);
  }
}
项目:consulo    文件:TooltipController.java   
public void showTooltip(@Nonnull Editor editor,
                        @Nonnull Point p,
                        @Nonnull TooltipRenderer tooltipRenderer,
                        boolean alignToRight,
                        @Nonnull TooltipGroup group,
                        @Nonnull HintHint hintInfo) {
  if (myCurrentTooltip == null || !myCurrentTooltip.isVisible()) {
    myCurrentTooltipObject = null;
  }

  if (Comparing.equal(tooltipRenderer, myCurrentTooltipObject)) {
    IdeTooltipManager.getInstance().cancelAutoHide();
    return;
  }
  if (myCurrentTooltipGroup != null && group.compareTo(myCurrentTooltipGroup) < 0) return;

  p = new Point(p);
  hideCurrentTooltip();

  LightweightHint hint = tooltipRenderer.show(editor, p, alignToRight, group, hintInfo);

  myCurrentTooltipGroup = group;
  myCurrentTooltip = hint;
  myCurrentTooltipObject = tooltipRenderer;
}
项目:consulo    文件:TrafficTooltipRendererImpl.java   
@Override
public LightweightHint show(@Nonnull Editor editor, @Nonnull Point p, boolean alignToRight, @Nonnull TooltipGroup group, @Nonnull HintHint hintHint) {
  myTrafficLightRenderer = (TrafficLightRenderer)((EditorMarkupModelImpl)editor.getMarkupModel()).getErrorStripeRenderer();
  myPanel = new TrafficProgressPanel(myTrafficLightRenderer, editor, hintHint);
  repaintTooltipWindow();
  LineTooltipRenderer.correctLocation(editor, myPanel, p, alignToRight, true, myPanel.getMinWidth());
  LightweightHint hint = new LightweightHint(myPanel);

  HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance();
  hintManager.showEditorHint(hint, editor, p,
                             HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT |
                             HintManager.HIDE_BY_SCROLLING, 0, false, hintHint);
  hint.addHintListener(new HintListener() {
    @Override
    public void hintHidden(EventObject event) {
      if (myPanel == null) return; //double hide?
      myPanel = null;
      onHide.run();
    }
  });
  return hint;
}
项目:consulo    文件:DaemonTooltipUtil.java   
public static void showInfoTooltip(@Nonnull final HighlightInfo info, @Nonnull Editor editor, final int defaultOffset, final int currentWidth) {
  if (info.getToolTip() == null) return;
  Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();

  Point bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
  bestPoint.y += editor.getLineHeight() / 2;

  if (!visibleArea.contains(bestPoint)) {
    bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset));
  }

  Point p = SwingUtilities.convertPoint(
    editor.getContentComponent(),
    bestPoint,
    editor.getComponent().getRootPane().getLayeredPane()
  );

  TooltipController.getInstance().showTooltip(editor, p, info.getToolTip(), currentWidth, false, DAEMON_INFO_GROUP, new HintHint(editor, bestPoint).setAwtTooltip(true).setHighlighterType(true).setCalloutShift(
    editor.getLineHeight() / 2 - 1));
}
项目:consulo    文件:IntentionHintComponent.java   
@Override
public void show(@Nonnull final JComponent parentComponent,
                 final int x,
                 final int y,
                 final JComponent focusBackComponent,
                 @Nonnull HintHint hintHint) {
  myVisible = true;
  if (myShouldDelay) {
    myAlarm.cancelAllRequests();
    myAlarm.addRequest(new Runnable() {
      @Override
      public void run() {
        showImpl(parentComponent, x, y, focusBackComponent);
      }
    }, DELAY);
  }
  else {
    showImpl(parentComponent, x, y, focusBackComponent);
  }
}
项目:intellij-ce-playground    文件:TooltipController.java   
public void showTooltipByMouseMove(@NotNull final Editor editor,
                                   @NotNull final RelativePoint point,
                                   final TooltipRenderer tooltipObject,
                                   final boolean alignToRight,
                                   @NotNull final TooltipGroup group,
                                   @NotNull HintHint hintHint) {
  LightweightHint currentTooltip = myCurrentTooltip;
  if (currentTooltip == null || !currentTooltip.isVisible()) {
    if (currentTooltip != null) {
      if (!IdeTooltipManager.getInstance().isQueuedToShow(currentTooltip.getCurrentIdeTooltip())) {
        myCurrentTooltipObject = null;
      }
    }
    else {
      myCurrentTooltipObject = null;
    }
  }

  if (Comparing.equal(tooltipObject, myCurrentTooltipObject)) {
    IdeTooltipManager.getInstance().cancelAutoHide();
    return;
  }
  hideCurrentTooltip();

  if (tooltipObject != null) {
    final Point p = point.getPointOn(editor.getComponent().getRootPane().getLayeredPane()).getPoint();
    if (!hintHint.isAwtTooltip()) {
      p.x += alignToRight ? -10 : 10;
    }

    Project project = editor.getProject();
    if (project != null && !project.isOpen()) return;
    if (editor.getContentComponent().isShowing()) {
      showTooltip(editor, p, tooltipObject, alignToRight, group, hintHint);
    }
  }
}
项目:intellij-ce-playground    文件:LineTooltipRenderer.java   
private void expand(@NotNull LightweightHint hint,
                    @NotNull Editor editor,
                    @NotNull Point p,
                    @NotNull JEditorPane pane,
                    boolean alignToRight,
                    @NotNull TooltipGroup group,
                    @NotNull HintHint hintHint) {
  hint.hide();
  if (myCurrentWidth > 0) {
    stripDescription();
  }
  TooltipController.getInstance().showTooltip(editor, new Point(p.x - 3, p.y - 3),
                                              createRenderer(myText, myCurrentWidth > 0 ? 0 : pane.getWidth()), alignToRight, group,
                                              hintHint);
}
项目:intellij-ce-playground    文件:TrafficProgressPanel.java   
TrafficProgressPanel(@NotNull TrafficLightRenderer trafficLightRenderer, @NotNull Editor editor, @NotNull HintHint hintHint) {
  myHintHint = hintHint;
  myTrafficLightRenderer = trafficLightRenderer;

  setLayout(new BorderLayout());

  VerticalBox center = new VerticalBox();

  add(center, BorderLayout.NORTH);
  center.add(statusLabel);
  center.add(statusExtraLineLabel);
  center.add(new Separator());
  center.add(Box.createVerticalStrut(6));

  TrafficLightRenderer.DaemonCodeAnalyzerStatus fakeStatusLargeEnough = new TrafficLightRenderer.DaemonCodeAnalyzerStatus();
  fakeStatusLargeEnough.errorCount = new int[]{1, 1, 1, 1};
  Project project = trafficLightRenderer.getProject();
  PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
  fakeStatusLargeEnough.passStati = new ArrayList<ProgressableTextEditorHighlightingPass>();
  for (int i = 0; i < 3; i++) {
    fakeStatusLargeEnough.passStati
      .add(new ProgressableTextEditorHighlightingPass(project, null, DaemonBundle.message("pass.wolf"), psiFile, editor, TextRange.EMPTY_RANGE, false,
                                                      HighlightInfoProcessor.getEmpty()) {
        @Override
        protected void collectInformationWithProgress(@NotNull ProgressIndicator progress) {
        }

        @Override
        protected void applyInformationWithProgress() {
        }
      });
  }
  center.add(myPassStatusesContainer);

  add(statistics, BorderLayout.SOUTH);
  updatePanel(fakeStatusLargeEnough, true);

  hintHint.initStyle(this, true);
  statusLabel.setFont(statusLabel.getFont().deriveFont(Font.BOLD));
}
项目:intellij-ce-playground    文件:ConsoleGutterComponent.java   
@Override
public void mouseMoved(MouseEvent e) {
  int line = EditorUtil.yPositionToLogicalLine(editor, e.getPoint());
  if (line == lastGutterToolTipLine) {
    return;
  }

  TooltipController controller = TooltipController.getInstance();
  if (lastGutterToolTipLine != -1) {
    controller.cancelTooltip(TOOLTIP_GROUP, e, true);
  }

  String toolTip = gutterContentProvider.getToolTip(line, editor);
  setCursor(toolTip == null ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  if (toolTip == null) {
    lastGutterToolTipLine = -1;
    controller.cancelTooltip(TOOLTIP_GROUP, e, false);
  }
  else {
    lastGutterToolTipLine = line;
    RelativePoint showPoint = new RelativePoint(this, e.getPoint());
    controller.showTooltipByMouseMove(editor,
                                      showPoint,
                                      ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip),
                                      false,
                                      TOOLTIP_GROUP,
                                      new HintHint(this, e.getPoint()).setAwtTooltip(true));
  }
}
项目:intellij-ce-playground    文件:QuickFixManager.java   
/**
 * Shows intention hint (light bulb) if it's not visible yet.
 */
final void showIntentionHint(){
  if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){
    hideIntentionHint();
    return;
  }

  // 1. Hide previous hint (if any)
  hideIntentionHint();

  // 2. Found error (if any)
  final ErrorInfo[] errorInfos = getErrorInfos();
  if(!haveFixes(errorInfos)) {
    hideIntentionHint();
    return;
  }

  // 3. Determine position where this hint should be shown
  final Rectangle bounds = getErrorBounds();
  if(bounds == null){
    return;
  }

  // 4. Show light bulb to fix this error
  final LightBulbComponentImpl lightBulbComponent = new LightBulbComponentImpl(this, AllIcons.Actions.IntentionBulb);
  myHint = new LightweightHint(lightBulbComponent);
  myLastHintBounds = bounds;
  myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation()));
}
项目:intellij-ce-playground    文件:AbstractQuickFixManager.java   
private void showHint() {
  if (!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)) {
    hideHint();
    return;
  }

  // 1. Hide previous hint (if any)
  hideHint();

  // 2. Found error (if any)
  List<ErrorInfo> infos = getErrorInfos();
  if (!ErrorInfo.haveFixes(infos)) {
    hideHint();
    return;
  }

  boolean error = false;
  for (ErrorInfo errorInfo : infos) {
    if (errorInfo.getLevel() == HighlightDisplayLevel.ERROR) {
      error = true;
      break;
    }
  }

  // 3. Determine position where this hint should be shown
  Rectangle bounds = getErrorBounds();
  if (bounds == null) {
    return;
  }

  // 4. Show light bulb to fix this error
  myHint = new LightweightHint(new InspectionHint(error ? AllIcons.Actions.QuickfixBulb : AllIcons.Actions.IntentionBulb));
  myLastHintBounds = bounds;
  myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation()));
}
项目:eddy    文件:EddyHintLabel.java   
private void setText(final String text, final HintHint hintHint) {
  clearText();

  if (text != null) {
    //final Html html = new Html(StringEscapeUtils.escapeHtml(text)).setKeepFont(true);
    myPane = IdeTooltipManager.initPane(StringEscapeUtils.escapeHtml(text), hintHint, null);
    add(myPane, BorderLayout.CENTER);
  }

  setOpaque(true);
  setBackground(hintHint.getTextBackground());

  revalidate();
  repaint();
}
项目:eddy    文件:EddyHintLabel.java   
private static HintHint getHintHint(boolean auto) {
  return new HintHint()
          .setTextBg(auto ? AUTOAPPLY_COLOR : QUESTION_COLOR)
          .setTextFg(JBColor.foreground())
          .setFont(UIUtil.getLabelFont()
          .deriveFont(Font.BOLD))
          .setAwtTooltip(true);
}
项目:tools-idea    文件:TooltipController.java   
public void showTooltipByMouseMove(@NotNull final Editor editor,
                                   @NotNull final RelativePoint point,
                                   final TooltipRenderer tooltipObject,
                                   final boolean alignToRight,
                                   @NotNull final TooltipGroup group,
                                   @NotNull HintHint hintHint) {
  LightweightHint currentTooltip = myCurrentTooltip;
  if (currentTooltip == null || !currentTooltip.isVisible()) {
    if (currentTooltip != null) {
      if (!IdeTooltipManager.getInstance().isQueuedToShow(currentTooltip.getCurrentIdeTooltip())) {
        myCurrentTooltipObject = null;
      }
    }
    else {
      myCurrentTooltipObject = null;
    }
  }

  if (Comparing.equal(tooltipObject, myCurrentTooltipObject)) {
    IdeTooltipManager.getInstance().cancelAutoHide();
    return;
  }
  hideCurrentTooltip();

  if (tooltipObject != null) {
    final Point p = point.getPointOn(editor.getComponent().getRootPane().getLayeredPane()).getPoint();
    if (!hintHint.isAwtTooltip()) {
      p.x += alignToRight ? -10 : 10;
    }

    Project project = editor.getProject();
    if (project != null && !project.isOpen()) return;
    if (editor.getContentComponent().isShowing()) {
      showTooltip(editor, p, tooltipObject, alignToRight, group, hintHint);
    }
  }
}
项目:tools-idea    文件:LineTooltipRenderer.java   
private void expand(@NotNull LightweightHint hint,
                    @NotNull Editor editor,
                    @NotNull Point p,
                    @NotNull JEditorPane pane,
                    boolean alignToRight,
                    @NotNull TooltipGroup group,
                    @NotNull HintHint hintHint) {
  hint.hide();
  if (myCurrentWidth > 0) {
    stripDescription();
  }
  TooltipController.getInstance().showTooltip(editor, new Point(p.x - 3, p.y - 3),
                                              createRenderer(myText, myCurrentWidth > 0 ? 0 : pane.getWidth()), alignToRight, group,
                                              hintHint);
}
项目:tools-idea    文件:EditorMarkupModelImpl.java   
private boolean showToolTipByMouseMove(final MouseEvent e, final double width) {
  MouseEvent me = e;

  Set<RangeHighlighter> highlighters = new THashSet<RangeHighlighter>();

  getNearestHighlighters(this, me, width, highlighters);
  getNearestHighlighters((MarkupModelEx)DocumentMarkupModel.forDocument(myEditor.getDocument(), getEditor().getProject(), true), me,
                         width, highlighters);

  if (highlighters.isEmpty()) return false;

  int minDelta = Integer.MAX_VALUE;
  int y = e.getY();

  for (RangeHighlighter each : highlighters) {
    ProperTextRange range = offsetsToYPositions(each.getStartOffset(), each.getEndOffset());
    int eachStartY = range.getStartOffset();
    int eachEndY = range.getEndOffset();
    int eachY = eachStartY + (eachEndY - eachStartY) / 2;
    if (Math.abs(e.getY() - eachY) < minDelta) {
      y = eachY;
    }
  }

  me = new MouseEvent((Component)e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), e.getX(), y + 1, e.getClickCount(),
                      e.isPopupTrigger());

  TooltipRenderer bigRenderer = myTooltipRendererProvider.calcTooltipRenderer(highlighters);
  if (bigRenderer != null) {
    showTooltip(me, bigRenderer, new HintHint(me).setAwtTooltip(true).setPreferredPosition(Balloon.Position.atLeft));
    return true;
  }
  return false;
}
项目:tools-idea    文件:EditorMarkupModelImpl.java   
private void showTrafficLightTooltip(MouseEvent e) {
  if (myTrafficTooltipRenderer == null) {
    myTrafficTooltipRenderer = myTooltipRendererProvider.createTrafficTooltipRenderer(new Runnable() {
      @Override
      public void run() {
        myTrafficTooltipRenderer = null;
      }
    }, myEditor);
  }
  showTooltip(e, myTrafficTooltipRenderer, new HintHint(e).setAwtTooltip(true).setMayCenterPosition(true).setContentActive(false)
    .setPreferredPosition(Balloon.Position.atLeft));
}
项目:tools-idea    文件:ShowParameterInfoContext.java   
private static void showParameterHint(final PsiElement element, final Editor editor, final Object[] descriptors,
                                      final Project project, final ShowParameterInfoHandler.BestLocationPointProvider provider,
                                      @Nullable PsiElement highlighted,
                                      final int elementStart, final ParameterInfoHandler handler
                                      ) {
  if (ParameterInfoController.isAlreadyShown(editor, elementStart)) return;

  if (editor.isDisposed() || !editor.getComponent().isVisible()) return;
  final ParameterInfoComponent component = new ParameterInfoComponent(descriptors, editor,handler);
  component.setParameterOwner(element);
  if (highlighted != null) {
    component.setHighlightedParameter(highlighted);
  }

  component.update(); // to have correct preferred size

  final LightweightHint hint = new LightweightHint(component);
  hint.setSelectingHint(true);
  final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
  final Pair<Point, Short> pos = provider.getBestPointPosition(hint, element, elementStart, true, HintManager.UNDER);

  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      if (editor.isDisposed()) return;

      final Document document = editor.getDocument();
      if (document.getTextLength() < elementStart) return;

      HintHint hintHint = HintManagerImpl.createHintHint(editor, pos.getFirst(), hint, pos.getSecond());
      hintHint.setExplicitClose(true);

      hintManager.showEditorHint(hint, editor, pos.getFirst(), HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING, 0, false, hintHint);
      new ParameterInfoController(project, editor, elementStart, hint, handler, provider);
    }
  });
}
项目:tools-idea    文件:QuickFixManager.java   
/**
 * Shows intention hint (light bulb) if it's not visible yet.
 */
final void showIntentionHint(){
  if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){
    hideIntentionHint();
    return;
  }

  // 1. Hide previous hint (if any)
  hideIntentionHint();

  // 2. Found error (if any)
  final ErrorInfo[] errorInfos = getErrorInfos();
  if(!haveFixes(errorInfos)) {
    hideIntentionHint();
    return;
  }

  // 3. Determine position where this hint should be shown
  final Rectangle bounds = getErrorBounds();
  if(bounds == null){
    return;
  }

  // 4. Show light bulb to fix this error
  final LightBulbComponentImpl lightBulbComponent = new LightBulbComponentImpl(this, AllIcons.Actions.IntentionBulb);
  myHint = new LightweightHint(lightBulbComponent);
  myLastHintBounds = bounds;
  myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation()));
}
项目:tools-idea    文件:AbstractQuickFixManager.java   
private void showHint() {
  if (!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)) {
    hideHint();
    return;
  }

  // 1. Hide previous hint (if any)
  hideHint();

  // 2. Found error (if any)
  List<ErrorInfo> infos = getErrorInfos();
  if (!ErrorInfo.haveFixes(infos)) {
    hideHint();
    return;
  }

  boolean error = false;
  for (ErrorInfo errorInfo : infos) {
    if (errorInfo.getLevel() == HighlightDisplayLevel.ERROR) {
      error = true;
      break;
    }
  }

  // 3. Determine position where this hint should be shown
  Rectangle bounds = getErrorBounds();
  if (bounds == null) {
    return;
  }

  // 4. Show light bulb to fix this error
  myHint = new LightweightHint(new InspectionHint(error ? AllIcons.Actions.QuickfixBulb : AllIcons.Actions.IntentionBulb));
  myLastHintBounds = bounds;
  myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation()));
}
项目:cordovastudio    文件:AbstractQuickFixManager.java   
private void showHint() {
  if (!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)) {
    hideHint();
    return;
  }

  // 1. Hide previous hint (if any)
  hideHint();

  // 2. Found error (if any)
  List<ErrorInfo> infos = getErrorInfos();
  if (!ErrorInfo.haveFixes(infos)) {
    hideHint();
    return;
  }

  boolean error = false;
  for (ErrorInfo errorInfo : infos) {
    if (errorInfo.getLevel() == HighlightDisplayLevel.ERROR) {
      error = true;
      break;
    }
  }

  // 3. Determine position where this hint should be shown
  Rectangle bounds = getErrorBounds();
  if (bounds == null) {
    return;
  }

  // 4. Show light bulb to fix this error
  myHint = new LightweightHint(new InspectionHint(error ? AllIcons.Actions.QuickfixBulb : AllIcons.Actions.IntentionBulb));
  myLastHintBounds = bounds;
  myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation()));
}
项目:consulo-ui-designer    文件:QuickFixManager.java   
/**
 * Shows intention hint (light bulb) if it's not visible yet.
 */
final void showIntentionHint(){
  if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){
    hideIntentionHint();
    return;
  }

  // 1. Hide previous hint (if any)
  hideIntentionHint();

  // 2. Found error (if any)
  final ErrorInfo[] errorInfos = getErrorInfos();
  if(!haveFixes(errorInfos)) {
    hideIntentionHint();
    return;
  }

  // 3. Determine position where this hint should be shown
  final Rectangle bounds = getErrorBounds();
  if(bounds == null){
    return;
  }

  // 4. Show light bulb to fix this error
  final LightBulbComponentImpl lightBulbComponent = new LightBulbComponentImpl(this, AllIcons.Actions.IntentionBulb);
  myHint = new LightweightHint(lightBulbComponent);
  myLastHintBounds = bounds;
  myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation()));
}
项目:consulo    文件:DiffRequestProcessor.java   
@Nonnull
private static HintHint createNotifyHint(@Nonnull JComponent component, @Nonnull Point point, boolean above) {
  return new HintHint(component, point)
          .setPreferredPosition(above ? Balloon.Position.above : Balloon.Position.below)
          .setAwtTooltip(true)
          .setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD))
          .setTextBg(HintUtil.INFORMATION_COLOR)
          .setShowImmediately(true);
}
项目:consulo    文件:CoverageLineMarkerRenderer.java   
private void showHint(final Editor editor, final Point point, final int lineNumber) {
  final JPanel panel = new JPanel(new BorderLayout());
  panel.add(createActionsToolbar(editor, lineNumber), BorderLayout.NORTH);

  final LineData lineData = getLineData(lineNumber);
  final Editor uEditor;
  if (lineData != null && lineData.getStatus() != LineCoverage.NONE && !mySubCoverageActive) {
    final EditorFactory factory = EditorFactory.getInstance();
    final Document doc = factory.createDocument(getReport(editor, lineNumber));
    doc.setReadOnly(true);
    uEditor = factory.createEditor(doc, editor.getProject());
    panel.add(EditorFragmentComponent.createEditorFragmentComponent(uEditor, 0, doc.getLineCount(), false, false), BorderLayout.CENTER);
  } else {
    uEditor = null;
  }


  final LightweightHint hint = new LightweightHint(panel){
    @Override
    public void hide() {
      if (uEditor != null) EditorFactory.getInstance().releaseEditor(uEditor);
      super.hide();

    }
  };
  HintManagerImpl.getInstanceImpl().showEditorHint(hint, editor, point,
                                                   HintManagerImpl.HIDE_BY_ANY_KEY | HintManagerImpl.HIDE_BY_TEXT_CHANGE | HintManagerImpl.HIDE_BY_OTHER_HINT | HintManagerImpl.HIDE_BY_SCROLLING, -1, false, new HintHint(editor, point));
}
项目:consulo    文件:GraphTableController.java   
private void showToolTip(@Nonnull String text, @Nonnull MouseEvent e) {
  // standard tooltip does not allow to customize its location, and locating tooltip above can obscure some important info
  Point point = new Point(e.getX() + 5, e.getY());

  JEditorPane tipComponent = IdeTooltipManager.initPane(text, new HintHint(myTable, point).setAwtTooltip(true), null);
  IdeTooltip tooltip = new IdeTooltip(myTable, point, new Wrapper(tipComponent)).setPreferredPosition(Balloon.Position.atRight);
  IdeTooltipManager.getInstance().show(tooltip, false);
}
项目:consulo    文件:TooltipController.java   
public void showTooltipByMouseMove(@Nonnull final Editor editor,
                                   @Nonnull final RelativePoint point,
                                   final TooltipRenderer tooltipObject,
                                   final boolean alignToRight,
                                   @Nonnull final TooltipGroup group,
                                   @Nonnull HintHint hintHint) {
  LightweightHint currentTooltip = myCurrentTooltip;
  if (currentTooltip == null || !currentTooltip.isVisible()) {
    if (currentTooltip != null) {
      if (!IdeTooltipManager.getInstance().isQueuedToShow(currentTooltip.getCurrentIdeTooltip())) {
        myCurrentTooltipObject = null;
      }
    }
    else {
      myCurrentTooltipObject = null;
    }
  }

  if (Comparing.equal(tooltipObject, myCurrentTooltipObject)) {
    IdeTooltipManager.getInstance().cancelAutoHide();
    return;
  }
  hideCurrentTooltip();

  if (tooltipObject != null) {
    final Point p = point.getPointOn(editor.getComponent().getRootPane().getLayeredPane()).getPoint();
    if (!hintHint.isAwtTooltip()) {
      p.x += alignToRight ? -10 : 10;
    }

    Project project = editor.getProject();
    if (project != null && !project.isOpen()) return;
    if (editor.getContentComponent().isShowing()) {
      showTooltip(editor, p, tooltipObject, alignToRight, group, hintHint);
    }
  }
}
项目:consulo    文件:LineTooltipRenderer.java   
private void expand(@Nonnull LightweightHint hint,
                    @Nonnull Editor editor,
                    @Nonnull Point p,
                    @Nonnull JEditorPane pane,
                    boolean alignToRight,
                    @Nonnull TooltipGroup group,
                    @Nonnull HintHint hintHint) {
  hint.hide();
  if (myCurrentWidth > 0) {
    stripDescription();
  }
  TooltipController.getInstance().showTooltip(editor, new Point(p.x - 3, p.y - 3),
                                              createRenderer(myText, myCurrentWidth > 0 ? 0 : pane.getWidth()), alignToRight, group,
                                              hintHint);
}
项目:consulo    文件:PopupFactoryImpl.java   
@Nonnull
@Override
public BalloonBuilder createHtmlTextBalloonBuilder(@Nonnull final String htmlContent, @Nullable final Icon icon, final Color fillColor,
                                                   @Nullable final HyperlinkListener listener) {
  JEditorPane text = IdeTooltipManager.initPane(htmlContent, new HintHint().setAwtTooltip(true), null);

  if (listener != null) {
    text.addHyperlinkListener(listener);
  }
  text.setEditable(false);
  NonOpaquePanel.setTransparent(text);
  text.setBorder(null);


  JLabel label = new JLabel();
  final JPanel content = new NonOpaquePanel(new BorderLayout((int)(label.getIconTextGap() * 1.5), (int)(label.getIconTextGap() * 1.5)));

  final NonOpaquePanel textWrapper = new NonOpaquePanel(new GridBagLayout());
  JScrollPane scrolledText = ScrollPaneFactory.createScrollPane(text, true);
  scrolledText.setBackground(fillColor);
  scrolledText.getViewport().setBackground(fillColor);
  textWrapper.add(scrolledText);
  content.add(textWrapper, BorderLayout.CENTER);

  final NonOpaquePanel north = new NonOpaquePanel(new BorderLayout());
  north.add(new JLabel(icon), BorderLayout.NORTH);
  content.add(north, BorderLayout.WEST);

  content.setBorder(new EmptyBorder(2, 4, 2, 4));

  final BalloonBuilder builder = createBalloonBuilder(content);

  builder.setFillColor(fillColor);

  return builder;
}
项目:consulo    文件:TrafficProgressPanel.java   
TrafficProgressPanel(@Nonnull TrafficLightRenderer trafficLightRenderer, @Nonnull Editor editor, @Nonnull HintHint hintHint) {
  myHintHint = hintHint;
  myTrafficLightRenderer = trafficLightRenderer;

  setLayout(new BorderLayout());

  VerticalBox center = new VerticalBox();

  add(center, BorderLayout.NORTH);
  center.add(statusLabel);
  center.add(statusExtraLineLabel);
  center.add(new Separator());
  center.add(Box.createVerticalStrut(6));

  TrafficLightRenderer.DaemonCodeAnalyzerStatus fakeStatusLargeEnough = new TrafficLightRenderer.DaemonCodeAnalyzerStatus();
  fakeStatusLargeEnough.errorCount = new int[]{1, 1, 1, 1};
  Project project = trafficLightRenderer.getProject();
  PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
  fakeStatusLargeEnough.passStati = new ArrayList<ProgressableTextEditorHighlightingPass>();
  for (int i = 0; i < 3; i++) {
    fakeStatusLargeEnough.passStati
            .add(new ProgressableTextEditorHighlightingPass(project, null, DaemonBundle.message("pass.wolf"), psiFile, editor, TextRange.EMPTY_RANGE, false,
                                                            HighlightInfoProcessor.getEmpty()) {
              @Override
              protected void collectInformationWithProgress(@Nonnull ProgressIndicator progress) {
              }

              @Override
              protected void applyInformationWithProgress() {
              }
            });
  }
  center.add(myPassStatusesContainer);

  add(statistics, BorderLayout.SOUTH);
  updatePanel(fakeStatusLargeEnough, true);

  hintHint.initStyle(this, true);
  statusLabel.setFont(statusLabel.getFont().deriveFont(Font.BOLD));
}
项目:consulo    文件:ConsoleGutterComponent.java   
@Override
public void mouseMoved(MouseEvent e) {
  int line = EditorUtil.yPositionToLogicalLine(editor, e.getPoint());
  if (line == lastGutterToolTipLine) {
    return;
  }

  TooltipController controller = TooltipController.getInstance();
  if (lastGutterToolTipLine != -1) {
    controller.cancelTooltip(TOOLTIP_GROUP, e, true);
  }

  String toolTip = gutterContentProvider.getToolTip(line, editor);
  setCursor(toolTip == null ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  if (toolTip == null) {
    lastGutterToolTipLine = -1;
    controller.cancelTooltip(TOOLTIP_GROUP, e, false);
  }
  else {
    lastGutterToolTipLine = line;
    RelativePoint showPoint = new RelativePoint(this, e.getPoint());
    controller.showTooltipByMouseMove(editor,
                                      showPoint,
                                      ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(toolTip),
                                      false,
                                      TOOLTIP_GROUP,
                                      new HintHint(this, e.getPoint()).setAwtTooltip(true));
  }
}
项目:intellij-ce-playground    文件:TooltipController.java   
public void showTooltip(@NotNull Editor editor, @NotNull Point p, @NotNull String text, int currentWidth, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) {
  TooltipRenderer tooltipRenderer = ((EditorMarkupModel)editor.getMarkupModel()).getErrorStripTooltipRendererProvider().calcTooltipRenderer(text, currentWidth);
  showTooltip(editor, p, tooltipRenderer, alignToRight, group, hintHint);
}