Java Code Examples for com.intellij.openapi.editor.event.EditorMouseEventArea#EDITING_AREA

The following examples show how to use com.intellij.openapi.editor.event.EditorMouseEventArea#EDITING_AREA . 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: PasteFromX11Action.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  Editor editor = e.getData(CommonDataKeys.EDITOR);
  if (editor == null || !SystemInfo.isXWindow) {
    presentation.setEnabled(false);
  }
  else {
    boolean rightPlace = true;
    final InputEvent inputEvent = e.getInputEvent();
    if (inputEvent instanceof MouseEvent) {
      rightPlace = false;
      final MouseEvent me = (MouseEvent)inputEvent;
      if (editor.getMouseEventArea(me) == EditorMouseEventArea.EDITING_AREA) {
        final Component component = SwingUtilities.getDeepestComponentAt(me.getComponent(), me.getX(), me.getY());
        rightPlace = !(component instanceof JScrollBar);
      }
    }
    presentation.setEnabled(rightPlace);
  }
}
 
Example 3
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 4
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 5
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 6
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();
  }
}