public void mouseClicked(final EditorMouseEvent e) { final Editor editor = e.getEditor(); final MouseEvent mouseEvent = e.getMouseEvent(); if (mouseEvent.isPopupTrigger() || mouseEvent.isMetaDown() || mouseEvent.isControlDown() || mouseEvent.getButton() != MouseEvent.BUTTON1 || MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(editor) || e.getArea() != EditorMouseEventArea.LINE_MARKERS_AREA ||!isFromMyProject(editor)) { return; } PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Runnable() { public void run() { final int line = editor.xyToLogicalPosition(mouseEvent.getPoint()).line; final Document document = editor.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (line >= 0 && line < document.getLineCount() && file != null) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (!myProject.isDisposed() && myProject.isInitialized() && file.isValid()) { XDebuggerUtil.getInstance().toggleLineBreakpoint(myProject, file, line, mouseEvent.isAltDown()); } } }); } } }); }
@Override @RequiredDispatchThread protected void createHighlighter(@Nonnull Range range) { myApplication.assertIsDispatchThread(); if (range.getHighlighter() != null) { LOG.error("Multiple highlighters registered for the same Range"); return; } if (myMode == Mode.SILENT) return; int first = range.getLine1() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine1()); int second = range.getLine2() >= getLineCount(myDocument) ? myDocument.getTextLength() : myDocument.getLineStartOffset(range.getLine2()); MarkupModel markupModel = DocumentMarkupModel.forDocument(myDocument, myProject, true); RangeHighlighter highlighter = LineStatusMarkerRenderer.createRangeHighlighter(range, new TextRange(first, second), markupModel); highlighter.setLineMarkerRenderer(LineStatusMarkerRenderer.createRenderer(range, (editor) -> { return new LineStatusTrackerDrawing.MyLineStatusMarkerPopup(this, editor, range); })); highlighter.setEditorFilter(MarkupEditorFilterFactory.createIsNotDiffFilter()); range.setHighlighter(highlighter); }
@Override public void mouseClicked(final EditorMouseEvent e) { final Editor editor = e.getEditor(); final MouseEvent mouseEvent = e.getMouseEvent(); if (mouseEvent.isPopupTrigger() || mouseEvent.isMetaDown() || mouseEvent.isControlDown() || mouseEvent.getButton() != MouseEvent.BUTTON1 || MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(editor) || !isInsideGutter(e, editor) || ConsoleViewUtil.isConsoleViewEditor(editor) || !isFromMyProject(editor) || (editor.getSelectionModel().hasSelection() && myDragDetected) ) { return; } PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(new Runnable() { @Override public void run() { final int line = EditorUtil.yPositionToLogicalLine(editor, mouseEvent); final Document document = editor.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (line >= 0 && line < document.getLineCount() && file != null) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { if (!myProject.isDisposed() && myProject.isInitialized() && file.isValid()) { ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT, e.getMouseEvent()); AsyncResult<XLineBreakpoint> result = XBreakpointUtil.toggleLineBreakpoint( myProject, XSourcePositionImpl.create(file, line), editor, mouseEvent.isAltDown(), false); result.doWhenDone(new Consumer<XLineBreakpoint>() { @Override public void consume(XLineBreakpoint breakpoint) { if (!mouseEvent.isAltDown() && mouseEvent.isShiftDown() && breakpoint != null) { breakpoint.setSuspendPolicy(SuspendPolicy.NONE); String selection = editor.getSelectionModel().getSelectedText(); if (selection != null) { breakpoint.setLogExpression(selection); } else { breakpoint.setLogMessage(true); } // edit breakpoint DebuggerUIUtil.showXBreakpointEditorBalloon(myProject, mouseEvent.getPoint(), ((EditorEx)editor).getGutterComponentEx(), false, breakpoint); } } }); } } }); } } }); }
@Override public void mouseClicked(final EditorMouseEvent e) { final Editor editor = e.getEditor(); final MouseEvent mouseEvent = e.getMouseEvent(); if (mouseEvent.isPopupTrigger() || mouseEvent.isMetaDown() || mouseEvent.isControlDown() || mouseEvent.getButton() != MouseEvent.BUTTON1 || MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(editor) || !isInsideGutter(e, editor) || ConsoleViewUtil.isConsoleViewEditor(editor) || !isFromMyProject(editor) || (editor.getSelectionModel().hasSelection() && myDragDetected)) { return; } PsiDocumentManager.getInstance(myProject).commitAllDocuments(); final int line = EditorUtil.yPositionToLogicalLine(editor, mouseEvent); final Document document = editor.getDocument(); final VirtualFile file = FileDocumentManager.getInstance().getFile(document); if (line >= 0 && line < document.getLineCount() && file != null) { ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT, e.getMouseEvent()); final AsyncResult<XLineBreakpoint> lineBreakpoint = XBreakpointUtil.toggleLineBreakpoint(myProject, XSourcePositionImpl.create(file, line), editor, mouseEvent.isAltDown(), false); lineBreakpoint.doWhenDone(breakpoint -> { if (!mouseEvent.isAltDown() && mouseEvent.isShiftDown() && breakpoint != null) { breakpoint.setSuspendPolicy(SuspendPolicy.NONE); String selection = editor.getSelectionModel().getSelectedText(); if (selection != null) { breakpoint.setLogExpression(selection); } else { breakpoint.setLogMessage(true); } // edit breakpoint DebuggerUIUtil.showXBreakpointEditorBalloon(myProject, mouseEvent.getPoint(), ((EditorEx)editor).getGutterComponentEx(), false, breakpoint); } }); } }