Java 类com.intellij.util.ui.PositionTracker 实例源码

项目:intellij-ce-playground    文件:ActionMacroManager.java   
private void showBalloon() {
  if (myBalloon != null) {
    Disposer.dispose(myBalloon);
    return;
  }

  myBalloon = JBPopupFactory.getInstance().createBalloonBuilder(myBalloonComponent)
    .setAnimationCycle(200)
    .setCloseButtonEnabled(true)
    .setHideOnAction(false)
    .setHideOnClickOutside(false)
    .setHideOnFrameResize(false)
    .setHideOnKeyOutside(false)
    .setSmallVariant(true)
    .setShadow(true)
    .createBalloon();

  Disposer.register(myBalloon, new Disposable() {
    @Override
    public void dispose() {
      myBalloon = null;
    }
  });

  myBalloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (myBalloon != null) {
        Disposer.dispose(myBalloon);
      }
    }
  });

  myBalloon.show(new PositionTracker<Balloon>(myIcon) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      return new RelativePoint(myIcon, new Point(myIcon.getSize().width / 2, 4));
    }
  }, Balloon.Position.above);
}
项目:tools-idea    文件:ActionMacroManager.java   
private void showBalloon() {
  if (myBalloon != null) {
    Disposer.dispose(myBalloon);
    return;
  }

  myBalloon = JBPopupFactory.getInstance().createBalloonBuilder(myBalloonComponent)
    .setAnimationCycle(200)
    .setCloseButtonEnabled(true)
    .setHideOnAction(false)
    .setHideOnClickOutside(false)
    .setHideOnFrameResize(false)
    .setHideOnKeyOutside(false)
    .setSmallVariant(true)
    .setShadow(true)
    .createBalloon();

  Disposer.register(myBalloon, new Disposable() {
    @Override
    public void dispose() {
      myBalloon = null;
    }
  });

  myBalloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (myBalloon != null) {
        Disposer.dispose(myBalloon);
      }
    }
  });

  myBalloon.show(new PositionTracker<Balloon>(myIcon) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      return new RelativePoint(myIcon, new Point(myIcon.getSize().width / 2, 4));
    }
  }, Balloon.Position.above);
}
项目:tools-idea    文件:InplaceRefactoring.java   
protected void showBalloon() {
  final JComponent component = getComponent();
  if (component == null) return;
  if (ApplicationManager.getApplication().isHeadlessEnvironment()) return;
  final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(component, null).setSmallVariant(true);
  myBalloon = balloonBuilder.createBalloon();
  Disposer.register(myProject, myBalloon);
  Disposer.register(myBalloon, new Disposable() {
    @Override
    public void dispose() {
      releaseIfNotRestart();
    }
  });
  final Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(myEditor);
  topLevelEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  myBalloon.show(new PositionTracker<Balloon>(topLevelEditor.getContentComponent()) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      if (myTarget != null && !popupFactory.isBestPopupLocationVisible(topLevelEditor)) {
        return myTarget;
      }
      final RelativePoint target = popupFactory.guessBestPopupLocation(topLevelEditor);
      if (target == null) return myTarget;
      final Point screenPoint = target.getScreenPoint();
      int y = screenPoint.y;
      if (target.getPoint().getY() > topLevelEditor.getLineHeight() + myBalloon.getPreferredSize().getHeight()) {
        y -= topLevelEditor.getLineHeight();
      }
      myTarget = new RelativePoint(new Point(screenPoint.x, y));
      return myTarget;
    }
  }, Balloon.Position.above);
}
项目:consulo    文件:ActionMacroManager.java   
private void showBalloon() {
  if (myBalloon != null) {
    Disposer.dispose(myBalloon);
    return;
  }

  myBalloon =
          JBPopupFactory.getInstance().createBalloonBuilder(myBalloonComponent).setAnimationCycle(200).setCloseButtonEnabled(true).setHideOnAction(false)
                  .setHideOnClickOutside(false).setHideOnFrameResize(false).setHideOnKeyOutside(false).setSmallVariant(true).setShadow(true)
                  .createBalloon();

  Disposer.register(myBalloon, new Disposable() {
    @Override
    public void dispose() {
      myBalloon = null;
    }
  });

  myBalloon.addListener(new JBPopupAdapter() {
    @Override
    public void onClosed(LightweightWindowEvent event) {
      if (myBalloon != null) {
        Disposer.dispose(myBalloon);
      }
    }
  });

  myBalloon.show(new PositionTracker<Balloon>(myIcon) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      return new RelativePoint(myIcon, new Point(myIcon.getSize().width / 2, 4));
    }
  }, Balloon.Position.above);
}
项目:consulo    文件:InplaceRefactoring.java   
protected void showBalloon() {
  final JComponent component = getComponent();
  if (component == null) return;
  if (ApplicationManager.getApplication().isHeadlessEnvironment()) return;
  final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(component, null).setSmallVariant(true);
  myBalloon = balloonBuilder.createBalloon();
  final Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(myEditor);
  Disposer.register(myProject, myBalloon);
  Disposer.register(myBalloon, new Disposable() {
    @Override
    public void dispose() {
      releaseIfNotRestart();
      topLevelEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null);
    }
  });
  topLevelEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  myBalloon.show(new PositionTracker<Balloon>(topLevelEditor.getContentComponent()) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      if (myTarget != null && !popupFactory.isBestPopupLocationVisible(topLevelEditor)) {
        return myTarget;
      }
      if (myCaretRangeMarker != null && myCaretRangeMarker.isValid()) {
        topLevelEditor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION,
                                   topLevelEditor.offsetToVisualPosition(myCaretRangeMarker.getStartOffset()));
      }
      final RelativePoint target = popupFactory.guessBestPopupLocation(topLevelEditor);
      final Point screenPoint = target.getScreenPoint();
      int y = screenPoint.y;
      if (target.getPoint().getY() > topLevelEditor.getLineHeight() + myBalloon.getPreferredSize().getHeight()) {
        y -= topLevelEditor.getLineHeight();
      }
      myTarget = new RelativePoint(new Point(screenPoint.x, y));
      return myTarget;
    }
  }, Balloon.Position.above);
}
项目:consulo    文件:InplaceChangeSignature.java   
protected void showBalloon() {
  NonFocusableCheckBox checkBox = new NonFocusableCheckBox(RefactoringBundle.message("delegation.panel.delegate.via.overloading.method"));
  checkBox.addActionListener(e -> {
    myDelegate = checkBox.isSelected();
    updateCurrentInfo();
  });
  JPanel content = new JPanel(new BorderLayout());
  content.add(new JBLabel("Performed signature modifications:"), BorderLayout.NORTH);
  content.add(myPreview.getComponent(), BorderLayout.CENTER);
  updateMethodSignature(myStableChange);
  content.add(checkBox, BorderLayout.SOUTH);
  final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createDialogBalloonBuilder(content, null).setSmallVariant(true);
  myBalloon = balloonBuilder.createBalloon();
  myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
  myBalloon.show(new PositionTracker<Balloon>(myEditor.getContentComponent()) {
    @Override
    public RelativePoint recalculateLocation(Balloon object) {
      int offset = myStableChange.getMethod().getTextOffset();
      VisualPosition visualPosition = myEditor.offsetToVisualPosition(offset);
      Point point = myEditor.visualPositionToXY(new VisualPosition(visualPosition.line, visualPosition.column));
      return new RelativePoint(myEditor.getContentComponent(), point);
    }
  }, Balloon.Position.above);
  Disposer.register(myBalloon, () -> {
    EditorFactory.getInstance().releaseEditor(myPreview);
    myPreview = null;
  });
}
项目:intellij-ce-playground    文件:AbstractInplaceIntroducer.java   
protected void revalidate() {
  myWholePanel.revalidate();
  if (myTarget != null) {
    myBalloon.revalidate(new PositionTracker.Static<Balloon>(myTarget));
  }
}
项目:tools-idea    文件:AbstractInplaceIntroducer.java   
protected void revalidate() {
  myWholePanel.revalidate();
  if (myTarget != null) {
    myBalloon.revalidate(new PositionTracker.Static<Balloon>(myTarget));
  }
}
项目:consulo    文件:AbstractInplaceIntroducer.java   
protected void revalidate() {
  myWholePanel.revalidate();
  if (myTarget != null) {
    myBalloon.revalidate(new PositionTracker.Static<Balloon>(myTarget));
  }
}
项目:intellij-ce-playground    文件:Balloon.java   
void show(PositionTracker<Balloon> tracker, Position preferredPosition);
项目:tools-idea    文件:Balloon.java   
void show(PositionTracker<Balloon> tracker, Position preferredPosition);
项目:consulo    文件:Balloon.java   
void show(PositionTracker<Balloon> tracker, Position preferredPosition);