Java Code Examples for com.intellij.openapi.editor.event.EditorMouseEvent#getArea()

The following examples show how to use com.intellij.openapi.editor.event.EditorMouseEvent#getArea() . 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: PreviewEditorMouseListener.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private int getEditorCharOffsetAndRemoveTokenHighlighters(EditorMouseEvent e) {
		if ( e.getArea()!=EditorMouseEventArea.EDITING_AREA ) {
			return -1;
		}

		MouseEvent mouseEvent=e.getMouseEvent();
		Editor editor=e.getEditor();
		int offset = MyActionUtils.getMouseOffset(mouseEvent, editor);
//		System.out.println("offset="+offset);

		if ( offset >= editor.getDocument().getTextLength() ) {
			return -1;
		}

		// Mouse has moved so make sure we don't show any token information tooltips
		InputPanel.clearTokenInfoHighlighters(e.getEditor());
		return offset;
	}
 
Example 2
Source File: FoldingPopupManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void mouseMoved(@Nonnull EditorMouseEvent e) {
  myAlarm.cancelAllRequests();
  Editor editor = e.getEditor();
  if (editor.getUserData(DISABLED) != null) return;
  if (e.getArea() == EditorMouseEventArea.EDITING_AREA) {
    MouseEvent mouseEvent = e.getMouseEvent();
    Point point = mouseEvent.getPoint();
    FoldRegion fold = ((EditorEx)editor).getFoldingModel().getFoldingPlaceholderAt(point);
    TooltipController controller = TooltipController.getInstance();
    if (fold != null && !fold.shouldNeverExpand()) {
      myAlarm.addRequest(() -> {
        if (editor.getUserData(DISABLED) != null || !editor.getComponent().isShowing() || !fold.isValid() || fold.isExpanded()) return;
        DocumentFragment range = createDocumentFragment(fold);
        Point p = SwingUtilities.convertPoint((Component)mouseEvent.getSource(), point, editor.getComponent().getRootPane().getLayeredPane());
        controller.showTooltip(editor, p, new DocumentFragmentTooltipRenderer(range), false, FOLDING_TOOLTIP_GROUP);
      }, TOOLTIP_DELAY_MS);
    }
    else {
      controller.cancelTooltip(FOLDING_TOOLTIP_GROUP, mouseEvent, true);
    }
  }
}
 
Example 3
Source File: EditorPerfDecorations.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void mouseEntered(EditorMouseEvent e) {
  final EditorMouseEventArea area = e.getArea();
  if (!hoveredOverLineMarkerArea &&
      area == EditorMouseEventArea.LINE_MARKERS_AREA ||
      area == EditorMouseEventArea.FOLDING_OUTLINE_AREA ||
      area == EditorMouseEventArea.LINE_NUMBERS_AREA) {
    // Hover is over the gutter area.
    setHoverState(true);
  }
}
 
Example 4
Source File: EditorPerfDecorations.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void mouseExited(EditorMouseEvent e) {
  final EditorMouseEventArea area = e.getArea();
  setHoverState(false);
  // TODO(jacobr): hovers over a tooltip triggered by a gutter icon should
  // be considered a hover of the gutter but this logic does not handle that
  // case correctly.
}
 
Example 5
Source File: EditorPerfDecorations.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void mouseEntered(EditorMouseEvent e) {
  final EditorMouseEventArea area = e.getArea();
  if (!hoveredOverLineMarkerArea &&
      area == EditorMouseEventArea.LINE_MARKERS_AREA ||
      area == EditorMouseEventArea.FOLDING_OUTLINE_AREA ||
      area == EditorMouseEventArea.LINE_NUMBERS_AREA) {
    // Hover is over the gutter area.
    setHoverState(true);
  }
}
 
Example 6
Source File: EditorPerfDecorations.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void mouseExited(EditorMouseEvent e) {
  final EditorMouseEventArea area = e.getArea();
  setHoverState(false);
  // TODO(jacobr): hovers over a tooltip triggered by a gutter icon should
  // be considered a hover of the gutter but this logic does not handle that
  // case correctly.
}
 
Example 7
Source File: EditorActionUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void showEditorPopup(final EditorMouseEvent event, @Nonnull final ActionGroup group) {
  if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) {
    ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.EDITOR_POPUP, group);
    MouseEvent e = event.getMouseEvent();
    final Component c = e.getComponent();
    if (c != null && c.isShowing()) {
      popupMenu.getComponent().show(c, e.getX(), e.getY());
    }
    e.consume();
  }
}
 
Example 8
Source File: ValueLookupManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void mouseMoved(EditorMouseEvent e) {
  if (e.isConsumed()) {
    return;
  }

  Editor editor = e.getEditor();
  if (editor.getProject() != null && editor.getProject() != myProject) {
    return;
  }

  ValueHintType type = AbstractValueHint.getHintType(e);
  if (e.getArea() != EditorMouseEventArea.EDITING_AREA ||
      DISABLE_VALUE_LOOKUP.get(editor) == Boolean.TRUE ||
      type == null) {
    myAlarm.cancelAllRequests();
    return;
  }

  Point point = e.getMouseEvent().getPoint();
  if (myRequest != null && !myRequest.isKeepHint(editor, point)) {
    hideHint();
  }

  for (DebuggerSupport support : mySupports) {
    QuickEvaluateHandler handler = support.getQuickEvaluateHandler();
    if (handler.isEnabled(myProject)) {
      requestHint(handler, editor, point, type);
      break;
    }
  }
}
 
Example 9
Source File: DiffSideView.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean isInMyArea(EditorMouseEvent e) {
  return e.getArea() == EditorMouseEventArea.LINE_NUMBERS_AREA;
}
 
Example 10
Source File: EditorPopupHandler.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void handle(EditorMouseEvent e) {
  if (e.getMouseEvent().isPopupTrigger() && e.getArea() == EditorMouseEventArea.EDITING_AREA) {
    invokePopup(e);
    e.consume();
  }
}