Package com.intellij.openapi.editor

Examples of com.intellij.openapi.editor.LogicalPosition


    public void loadFromEditor(@NotNull FileEditorStateLevel level, @NotNull TextEditor textEditor) {
        Editor editor = textEditor.getEditor();
        Project project = editor.getProject();
        SelectionModel selectionModel = editor.getSelectionModel();
        LogicalPosition logicalPosition = editor.getCaretModel().getLogicalPosition();

        line = logicalPosition.line;
        column = logicalPosition.column;

        if(FileEditorStateLevel.FULL == level) {
View Full Code Here


    public void applyToEditor(@NotNull TextEditor textEditor) {
        final Editor editor = textEditor.getEditor();
        final Project project = editor.getProject();
        SelectionModel selectionModel = editor.getSelectionModel();

        LogicalPosition logicalPosition = new LogicalPosition(line, column);
        editor.getCaretModel().moveToLogicalPosition(logicalPosition);
        selectionModel.removeSelection();
        editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
        if (verticalScrollProportion != -1F)
            EditorUtil.setVerticalScrollProportion(editor, verticalScrollProportion);
View Full Code Here


  private static void scrollToPreviewSource(final BugInstanceNode bugInstanceNode, final Editor editor) {
    final int line = bugInstanceNode.getSourceLines()[0] - 1;
    if(line >= 0) {
      final LogicalPosition problemPos = new LogicalPosition(line, 0);
      editor.getCaretModel().moveToLogicalPosition(problemPos);
    } else { // anonymous classes
      final RangeHighlighter rangeHighlighter = editor.getMarkupModel().getAllHighlighters()[0];
      editor.getCaretModel().moveToOffset(rangeHighlighter.getStartOffset());
    }
View Full Code Here

  public static Optional<RangeHighlighter> findRangeHighlighterAtLine(final Editor editor, final Integer line) {
    if (line == null) return Optional.absent();
    final MarkupModel markupModel = editor.getMarkupModel();
    final RangeHighlighter[] highlighters = markupModel.getAllHighlighters();
    for (RangeHighlighter highlighter : highlighters) {
      final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(highlighter.getStartOffset());
      final int lineOfHighlighter = logicalPosition.line;
      if (lineOfHighlighter == line - 1) {
        return Optional.of(highlighter);
      }
    }
View Full Code Here

    }
    return highlighters;
  }

  public static int findLineOfRangeHighlighter(@NotNull RangeHighlighter highlighter, @NotNull Editor editor) {
    final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(highlighter.getStartOffset());
    return logicalPosition.line;
  }
View Full Code Here

      ApplicationManager.getApplication().runReadAction(new Runnable() {
        @Override
        public void run() {
          final RangeHighlighter[] highlighters = markupModel.getAllHighlighters();
          for (RangeHighlighter highlighter : highlighters) {
            final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(highlighter.getStartOffset());
            final int lineOfHighlighter = logicalPosition.line;
            if (lineOfHighlighter == line) {
              foundHighlighter = highlighter;
              break;
            }
View Full Code Here

                for (int i = 0; i < files.length; i++) {
                    VirtualFile file = files[i].getVirtualFile();
                    if (file.getPath().endsWith(_name)) {
                        OpenFileDescriptor desc = new OpenFileDescriptor(_project, file, _line, 0);
                        Editor editor = FileEditorManager.getInstance(_project).openTextEditor(desc, true);
                        LogicalPosition position = new LogicalPosition(_line, 0);
                        editor.getCaretModel().moveToLogicalPosition(position);
                        editor.getScrollingModel().scrollTo(position, ScrollType.CENTER);
                        Window window = WindowManager.getInstance().suggestParentWindow(_project);
                        window.setAlwaysOnTop(true);
                        window.setAlwaysOnTop(false);
View Full Code Here

                    FileEditor fileEditor = EditorUtil.getFileEditor(databaseFile, databaseFile.getMainContentFile());
                    if (fileEditor != null && fileEditor instanceof SourceCodeEditor) {
                        sourceCodeEditor = (SourceCodeEditor) fileEditor;
                    }
                }
                LogicalPosition position = new LogicalPosition(line, 0);
                EditorUtil.selectEditor(databaseFile, sourceCodeEditor);
                if (sourceCodeEditor != null) sourceCodeEditor.getEditor().getScrollingModel().scrollTo(position, ScrollType.CENTER);
            }
        }.start();
    }
View Full Code Here

            caretModel.moveToOffset((int) (offset));
            selectionModel.setSelection((int) (selectionStart -length), (int) (selectionEnd -length));
            editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
          } else {
            selectionModel.removeSelection();
            caretModel.moveToLogicalPosition(new LogicalPosition(line, column));
          }
        }
      }
    });
  }
View Full Code Here

            caretModel.moveToOffset((int) (offset+length));
            selectionModel.setSelection((int) (selectionStart + length), (int) (selectionEnd + length));
            editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
          } else {
            selectionModel.removeSelection();
            caretModel.moveToLogicalPosition(new LogicalPosition(line + 1, column));
          }
                }
            }
        });
    }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.editor.LogicalPosition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.