コード例 #1
0
 private boolean navigateInAnyFileEditor(Project project, boolean focusEditor) {
   List<FileEditor> editors = FileEditorManager.getInstance(project).openEditor(this, focusEditor);
   for (FileEditor editor : editors) {
     if (editor instanceof TextEditor) {
       Editor e = ((TextEditor) editor).getEditor();
       unfoldCurrentLine(e);
       if (focusEditor) {
         IdeFocusManager.getInstance(myProject).requestFocus(e.getContentComponent(), true);
       }
     }
   }
   return !editors.isEmpty();
 }
コード例 #2
0
  public void navigateIn(@NotNull Editor e) {
    final int offset = getOffset();
    CaretModel caretModel = e.getCaretModel();
    boolean caretMoved = false;
    if (myLogicalLine >= 0) {
      LogicalPosition pos = new LogicalPosition(myLogicalLine, Math.max(myLogicalColumn, 0));
      if (offset < 0 || offset == e.logicalPositionToOffset(pos)) {
        caretModel.moveToLogicalPosition(pos);
        caretMoved = true;
      }
    }
    if (!caretMoved && offset >= 0) {
      caretModel.moveToOffset(Math.min(offset, e.getDocument().getTextLength()));
      caretMoved = true;
    }

    if (caretMoved) {
      e.getSelectionModel().removeSelection();
      scrollToCaret(e);
      unfoldCurrentLine(e);
    }
  }