Java Code Examples for com.intellij.openapi.editor.Editor#addEditorMouseListener()

The following examples show how to use com.intellij.openapi.editor.Editor#addEditorMouseListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommentsDiffTool.java    From review-board-idea-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void show(DiffRequest request) {
    final FrameWrapper frameWrapper = new FrameWrapper(request.getProject(), request.getGroupKey());
    final DiffPanelImpl diffPanel = createDiffPanelImpl(request, frameWrapper.getFrame(), frameWrapper);
    final Editor editor = diffPanel.getEditor2();
    updateHighLights(editor);

    editor.addEditorMouseListener(new EditorMouseAdapter() {
        @Override
        public void mouseClicked(EditorMouseEvent e) {
            if (e.getArea() != null && e.getArea().equals(EditorMouseEventArea.LINE_MARKERS_AREA)) {
                final Point locationOnScreen = e.getMouseEvent().getLocationOnScreen();
                final int lineNumber = EditorUtil.yPositionToLogicalLine(editor, e.getMouseEvent()) + 1;
                showCommentsView(locationOnScreen, lineNumber, editor, e);
            }
        }
    });

    DiffUtil.initDiffFrame(request.getProject(), frameWrapper, diffPanel, diffPanel.getComponent());
    frameWrapper.setTitle(request.getWindowTitle());
    frameWrapper.setPreferredFocusedComponent(diffPanel.getComponent());
    frameWrapper.show();
}
 
Example 2
Source File: DiffSideView.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void install(DiffContent content, EditorSource source, DiffSidesContainer container) {
  final Editor editor = source.getEditor();
  Project project = container.getProject();
  if (project == null || editor == null) {
    return;
  }
  final MouseLineNumberListener listener = new MouseLineNumberListener(content, editor, container, project);
  editor.addEditorMouseListener(listener.myMouseListener);
  editor.addEditorMouseMotionListener(listener.myMouseMotionListener);
  source.addDisposable(new Disposable() {
    public void dispose() {
      editor.removeEditorMouseListener(listener.myMouseListener);
      editor.removeEditorMouseMotionListener(listener.myMouseMotionListener);
    }
  });
}
 
Example 3
Source File: QuickDocOnMouseOverManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void registerListeners(@Nonnull Editor editor) {
  editor.addEditorMouseListener(myMouseListener);
  editor.addEditorMouseMotionListener(myMouseListener);
  editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener);
  editor.getCaretModel().addCaretListener(myCaretListener);

  Document document = editor.getDocument();
  if (myMonitoredDocuments.put(document, Boolean.TRUE) == null) {
    document.addDocumentListener(myDocumentListener);
  }
}