StatusBarManager.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:CSS-Editor-FX 作者:
private void showLineJumpDialog() {
  TextInputDialog dialog = new TextInputDialog();
  dialog.setTitle("Goto Line");
  dialog.getDialogPane().setContentText("Input Line Number: ");
  dialog.initOwner(area.getValue().getScene().getWindow());
  TextField tf = dialog.getEditor();

  int lines = StringUtil.countLine(area.getValue().getText());
  ValidationSupport vs = new ValidationSupport();
  vs.registerValidator(tf, Validator.<String> createPredicateValidator(
      s -> TaskUtil.uncatch(() -> MathUtil.inRange(Integer.valueOf(s), 1, lines)) == Boolean.TRUE,
      String.format("Line number must be in [%d,%d]", 1, lines)));

  dialog.showAndWait().ifPresent(s -> {
    if (vs.isInvalid() == false) {
      area.getValue().moveTo(Integer.valueOf(s) - 1, 0);
    }
  });
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号