@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); DataContext dataContext = e.getDataContext(); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); 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); } }
@Nullable public EditorMouseEventArea getEditorMouseAreaByOffset(int offset) { if (offset < getAnnotationsAreaOffset()) { return EditorMouseEventArea.LINE_NUMBERS_AREA; } if (offset < getAnnotationsAreaOffset() + getAnnotationsAreaWidth()) { return EditorMouseEventArea.ANNOTATIONS_AREA; } if (offset < getFoldingAreaOffset()) { return EditorMouseEventArea.LINE_MARKERS_AREA; } if (offset < getFoldingAreaOffset() + getFoldingAreaWidth()) { return EditorMouseEventArea.FOLDING_OUTLINE_AREA; } return null; }
private void fireEventToTextAnnotationListeners(final MouseEvent e) { if (myEditor.getMouseEventArea(e) == EditorMouseEventArea.ANNOTATIONS_AREA) { final Point clickPoint = e.getPoint(); final TextAnnotationGutterProvider provider = getProviderAtPoint(clickPoint); if (provider == null) { return; } if (myProviderToListener.containsKey(provider)) { int line = getLineNumAtPoint(clickPoint); if (line >= 0 && line < myEditor.getDocument().getLineCount() && UIUtil.isActionClick(e, MouseEvent.MOUSE_RELEASED)) { myProviderToListener.get(provider).doAction(line); } } } }
@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); } } }); DiffUtil.initDiffFrame(request.getProject(), frameWrapper, diffPanel, diffPanel.getComponent()); frameWrapper.setTitle(request.getWindowTitle()); frameWrapper.show(); }
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); DataContext dataContext = e.getDataContext(); Editor editor = PlatformDataKeys.EDITOR.getData(dataContext); 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); } }
public static EditorPopupHandler createEditorPopupHandler(final String groupId) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { ActionGroup group = (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(groupId); 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(); } } }; }
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) { if (!myHandler.isEnabled(project)) return false; Editor editor = event.getData(PlatformDataKeys.EDITOR); if (editor == null) return false; InputEvent inputEvent = event.getInputEvent(); if (inputEvent instanceof MouseEvent && inputEvent.isAltDown()) { MouseEvent mouseEvent = (MouseEvent)inputEvent; Component component = SwingUtilities.getDeepestComponentAt(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); if (SwingUtilities.isDescendingFrom(component, editor.getComponent())) { MouseEvent convertedEvent = SwingUtilities.convertMouseEvent(mouseEvent.getComponent(), mouseEvent, component); EditorMouseEventArea area = editor.getMouseEventArea(convertedEvent); if (area != EditorMouseEventArea.EDITING_AREA) { return false; } } } return true; }
public 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; }
@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); } }
private void processClose(final MouseEvent e) { final IdeEventQueue queue = IdeEventQueue.getInstance(); // See IDEA-59553 for rationale on why this feature is disabled //if (isLineNumbersShown()) { // if (e.getX() >= getLineNumberAreaOffset() && getLineNumberAreaOffset() + getLineNumberAreaWidth() >= e.getX()) { // queue.blockNextEvents(e); // myEditor.getSettings().setLineNumbersShown(false); // e.consume(); // return; // } //} if (getGutterRenderer(e) != null) return; if (myEditor.getMouseEventArea(e) == EditorMouseEventArea.ANNOTATIONS_AREA) { queue.blockNextEvents(e); closeAllAnnotations(); e.consume(); } }
@Nullable EditorMouseEventArea getEditorMouseAreaByOffset(int offset) { if (isLineNumbersShown() && offset < getLineNumberAreaOffset() + getLineNumberAreaWidth()) { return EditorMouseEventArea.LINE_NUMBERS_AREA; } if (isAnnotationsShown() && offset < getAnnotationsAreaOffset() + getAnnotationsAreaWidth()) { return EditorMouseEventArea.ANNOTATIONS_AREA; } if (isLineMarkersShown() && offset < getFoldingAreaOffset()) { return EditorMouseEventArea.LINE_MARKERS_AREA; } if (isFoldingOutlineShown() && offset < getFoldingAreaOffset() + getFoldingAreaWidth()) { return EditorMouseEventArea.FOLDING_OUTLINE_AREA; } return null; }
public static EditorPopupHandler createEditorPopupHandler(@NotNull final String groupId) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { ActionGroup group = (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(groupId); showEditorPopup(event, group); } } }; }
private static void showEditorPopup(final EditorMouseEvent event, @NotNull 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(); } }
@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; } } }
@Override public void invokePopup(final EditorMouseEvent event) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { ActionGroup group = (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_EDITOR_POPUP); 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(); } }
public static EditorPopupHandler createEditorPopupHandler(@Nonnull final String groupId) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { if (!event.isConsumed() && event.getArea() == EditorMouseEventArea.EDITING_AREA) { ActionGroup group = (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(groupId); showEditorPopup(event, group); } } }; }
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(); } }
@RequiredDispatchThread @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; } } }
@Override public void update(@NotNull AnActionEvent e) { InputEvent inputEvent = e.getInputEvent(); if (!(inputEvent instanceof MouseEvent)) { e.getPresentation().setEnabledAndVisible(false); return; } if (e.getProject() == null) { e.getPresentation().setEnabledAndVisible(false); return; } if (e.getData(OpenInEditorAction.KEY) == null) { e.getPresentation().setEnabledAndVisible(false); return; } Component component = inputEvent.getComponent(); if (component == null) { e.getPresentation().setEnabledAndVisible(false); return; } Point point = ((MouseEvent)inputEvent).getPoint(); Component componentAt = SwingUtilities.getDeepestComponentAt(component, point.x, point.y); if (!(componentAt instanceof EditorGutterComponentEx)) { e.getPresentation().setEnabledAndVisible(false); return; } Editor editor = getEditor(componentAt); if (editor == null) { e.getPresentation().setEnabledAndVisible(false); return; } MouseEvent convertedEvent = SwingUtilities.convertMouseEvent(inputEvent.getComponent(), (MouseEvent)inputEvent, componentAt); EditorMouseEventArea area = editor.getMouseEventArea(convertedEvent); if (area != EditorMouseEventArea.LINE_NUMBERS_AREA) { e.getPresentation().setEnabledAndVisible(false); return; } e.getPresentation().setEnabledAndVisible(true); }
private static boolean isInMyArea(EditorMouseEvent e) { return e.getArea() == EditorMouseEventArea.LINE_NUMBERS_AREA; }
@Override @Nullable public EditorMouseEventArea getMouseEventArea(@NotNull final MouseEvent e) { throw new UnsupportedOperationException("Not implemented"); }
private void handle(EditorMouseEvent e) { if (e.getMouseEvent().isPopupTrigger() && e.getArea() == EditorMouseEventArea.EDITING_AREA) { invokePopup(e); e.consume(); } }
@Override @Nullable public EditorMouseEventArea getMouseEventArea(@NotNull final MouseEvent e) { return getEditor().getMouseEventArea(e); }
@Override public EditorMouseEventArea getMouseEventArea(@NotNull final MouseEvent e) { return myDelegate.getMouseEventArea(e); }
@Override public void update(@Nonnull AnActionEvent e) { InputEvent inputEvent = e.getInputEvent(); if (!(inputEvent instanceof MouseEvent)) { e.getPresentation().setEnabledAndVisible(false); return; } if (e.getProject() == null) { e.getPresentation().setEnabledAndVisible(false); return; } if (e.getData(OpenInEditorAction.KEY) == null) { e.getPresentation().setEnabledAndVisible(false); return; } Component component = inputEvent.getComponent(); if (component == null) { e.getPresentation().setEnabledAndVisible(false); return; } Point point = ((MouseEvent)inputEvent).getPoint(); Component componentAt = SwingUtilities.getDeepestComponentAt(component, point.x, point.y); if (!(componentAt instanceof EditorGutterComponentEx)) { e.getPresentation().setEnabledAndVisible(false); return; } Editor editor = getEditor(componentAt); if (editor == null) { e.getPresentation().setEnabledAndVisible(false); return; } MouseEvent convertedEvent = SwingUtilities.convertMouseEvent(inputEvent.getComponent(), (MouseEvent)inputEvent, componentAt); EditorMouseEventArea area = editor.getMouseEventArea(convertedEvent); if (area != EditorMouseEventArea.LINE_NUMBERS_AREA) { e.getPresentation().setEnabledAndVisible(false); return; } e.getPresentation().setEnabledAndVisible(true); }
@Override @Nullable public EditorMouseEventArea getMouseEventArea(@Nonnull final MouseEvent e) { throw new UnsupportedOperationException("Not implemented"); }
@Override @Nullable public EditorMouseEventArea getMouseEventArea(@Nonnull final MouseEvent e) { return getEditor().getMouseEventArea(e); }
@Override public EditorMouseEventArea getMouseEventArea(@Nonnull final MouseEvent e) { return myDelegate.getMouseEventArea(e); }
/** * Returns the editor area (text, gutter, folding outline and so on) in which the specified * mouse event occurred. * * @param e the mouse event for which the area is requested. * @return the editor area, or null if the event occurred over an unknown area. */ @Nullable EditorMouseEventArea getMouseEventArea(@NotNull MouseEvent e);
/** * Returns the editor area (text, gutter, folding outline and so on) in which the specified * mouse event occurred. * * @param e the mouse event for which the area is requested. * @return the editor area, or null if the event occurred over an unknown area. */ @Nullable EditorMouseEventArea getMouseEventArea(@Nonnull MouseEvent e);