@Override public void mouseClicked(EditorMouseEvent e) { final Editor editor = e.getEditor(); final Point point = e.getMouseEvent().getPoint(); final LogicalPosition pos = editor.xyToLogicalPosition(point); final AnswerPlaceholder answerPlaceholder = myTaskFile.getAnswerPlaceholder(editor.getDocument(), pos); if (answerPlaceholder != null) { if (myAnswerPlaceholderWithSelection != null && myAnswerPlaceholderWithSelection == answerPlaceholder) { editor.getSelectionModel().removeSelection(); myAnswerPlaceholderWithSelection = null; } else { int startOffset = answerPlaceholder.getRealStartOffset(editor.getDocument()); editor.getSelectionModel().setSelection(startOffset, startOffset + answerPlaceholder.getLength()); myAnswerPlaceholderWithSelection = answerPlaceholder; } } }
@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(); }
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(); } } }; }
private Editor createLogEditor() { Project project = myProjectModel.getProject(); final Editor editor = ConsoleViewUtil.setupConsoleEditor(project, false, false); Disposer.register(myProjectModel, new Disposable() { @Override public void dispose() { EditorFactory.getInstance().releaseEditor(editor); } }); ((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true); final ClearLog clearLog = new ClearLog(); clearLog.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.CONSOLE_CLEAR_ALL).getShortcutSet(), editor.getContentComponent()); editor.addEditorMouseListener(new EditorPopupHandler() { public void invokePopup(final EditorMouseEvent event) { final ActionManager actionManager = ActionManager.getInstance(); final ActionPopupMenu menu = actionManager.createActionPopupMenu(ActionPlaces.EDITOR_POPUP, createPopupActions(actionManager, clearLog)); final MouseEvent mouseEvent = event.getMouseEvent(); menu.getComponent().show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); } }); return editor; }
public void mouseMoved(EditorMouseEvent e) { if (e.isConsumed()) return; Editor editor = e.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject) 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, AbstractValueHint.getType(e)); break; } } }
@Override public void mouseMoved(@NotNull EditorMouseEvent event) { Editor editor = event.getEditor(); if (editor.isOneLineMode()) { return; } alarm.cancelAllRequests(); Point point = event.getMouseEvent().getPoint(); if (elementRef == null && event.getMouseEvent().isShiftDown()) { alarm.addRequest(new PreviewRequest(point, editor, false), 100); } else if (elementRef != null && elementRef.get() != getPsiElementAt(point, editor)) { PsiElement element = elementRef.get(); elementRef = null; for (ElementPreviewProvider provider : Extensions.getExtensions(ElementPreviewProvider.EP_NAME)) { try { provider.hide(element, editor); } catch (Exception e) { LOG.error(e); } } } }
@Override public void mouseMoved(EditorMouseEvent e){ int offset = getEditorCharOffsetAndRemoveTokenHighlighters(e); if ( offset<0 ) return; Editor editor=e.getEditor(); if ( inputPanel.previewState==null ) { return; } MouseEvent mouseEvent=e.getMouseEvent(); InputPanel.clearTokenInfoHighlighters(e.getEditor()); if ( mouseEvent.isControlDown() && inputPanel.previewState.parsingResult!=null ) { inputPanel.showTokenInfoUponCtrlKey(editor, inputPanel.previewState, offset); } else if ( mouseEvent.isAltDown() && inputPanel.previewState.parsingResult!=null ) { inputPanel.showParseRegion(e, editor, inputPanel.previewState, offset); } else { // just moving around, show any errors or hints InputPanel.showTooltips(e, editor, inputPanel.previewState, offset); } }
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; }
private static void addConfigureNotificationAction(@Nonnull EditorEx editor, @Nonnull EditorMouseEvent event, @Nonnull final DefaultActionGroup actions) { LogicalPosition position = editor.xyToLogicalPosition(event.getMouseEvent().getPoint()); if (EditorUtil.inVirtualSpace(editor, position)) { return; } int offset = editor.logicalPositionToOffset(position); editor.getMarkupModel().processRangeHighlightersOverlappingWith(offset, offset, new Processor<RangeHighlighterEx>() { @Override public boolean process(RangeHighlighterEx rangeHighlighter) { String groupId = GROUP_ID.get(rangeHighlighter); if (groupId != null) { addConfigureNotificationAction(actions, groupId); return false; } return true; } }); }
@Override public void mouseClicked(EditorMouseEvent e) { final Editor editor = e.getEditor(); final Point point = e.getMouseEvent().getPoint(); final LogicalPosition pos = editor.xyToLogicalPosition(point); final AnswerPlaceholder answerPlaceholder = myTaskFile.getAnswerPlaceholder(editor.logicalPositionToOffset(pos)); if (answerPlaceholder == null || answerPlaceholder.getSelected()) { return; } final Pair<Integer, Integer> offsets = StudyUtils.getPlaceholderOffsets(answerPlaceholder, editor.getDocument()); editor.getSelectionModel().setSelection(offsets.getFirst(), offsets.getSecond()); answerPlaceholder.setSelected(true); }
@Override public void mousePressed(EditorMouseEvent editorMouseEvent) { final FileDocumentManager instance = FileDocumentManager.getInstance(); final VirtualFile file = instance.getFile(editorMouseEvent.getEditor().getDocument()); if (file != null) { GTMRecord.record(file.getPath(), editorMouseEvent.getEditor().getProject()); } }
@Override public void invokePopup(final EditorMouseEvent event) { if (myEditorPopupActions.isEmpty()) return; ActionGroup group = new DefaultActionGroup(myEditorPopupActions); EditorPopupHandler handler = EditorActionUtil.createEditorPopupHandler(group); handler.invokePopup(event); }
public void mouseReleased(EditorMouseEvent e) { if (!isEventHandled(e.getMouseEvent()) || !isInMyArea(e)) { return; } OpenFileDescriptor descriptor = getOpenFileDescriptor(e); if (descriptor == null) { return; } myContainer.showSource(descriptor); }
public void mouseMoved(EditorMouseEvent e) { Editor editor = e.getEditor(); if (editor.getProject() != null && editor.getProject() != myProject && myProject != null/*???*/) return; if (!isInMyArea(e)) return; Cursor cursor = getOpenFileDescriptor(e) != null ? HAND__CURSOR : Cursor.getDefaultCursor(); e.getMouseEvent().getComponent().setCursor(cursor); myEditor.getContentComponent().setCursor(cursor); }
public static Change findChangeAt(EditorMouseEvent e, MergePanel2 mergePanel, int index) { if (mergePanel.getMergeList() == null) return null; Editor editor = e.getEditor(); LOG.assertTrue(editor == mergePanel.getEditor(index)); LogicalPosition logicalPosition = editor.xyToLogicalPosition(e.getMouseEvent().getPoint()); int offset = editor.logicalPositionToOffset(logicalPosition); return forMergeList(mergePanel.getMergeList(), index).findChangeAt(offset); }
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); } } }; }
public static EditorPopupHandler createEditorPopupHandler(@NotNull final ActionGroup group) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { 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; } } }
@Nullable public static ValueHintType getHintType(final EditorMouseEvent e) { int modifiers = e.getMouseEvent().getModifiers(); if (modifiers == 0) { return ValueHintType.MOUSE_OVER_HINT; } else if (isAltMask(modifiers)) { return ValueHintType.MOUSE_ALT_OVER_HINT; } return null; }
@Override public void mouseMoved(@NotNull EditorMouseEvent event) { Editor editor = event.getEditor(); if (editor.isOneLineMode()) { return; } alarm.cancelAllRequests(); Point point = event.getMouseEvent().getPoint(); if (myElements == null && event.getMouseEvent().isShiftDown()) { alarm.addRequest(new PreviewRequest(point, editor, false), 100); } else { Collection<PsiElement> elements = myElements; if (!getPsiElementsAt(point, editor).equals(elements)) { myElements = null; for (ElementPreviewProvider provider : Extensions.getExtensions(ElementPreviewProvider.EP_NAME)) { try { if (elements != null) { for (PsiElement element : elements) { provider.hide(element, editor); } } else { provider.hide(null, editor); } } catch (Exception e) { LOG.error(e); } } } } }
@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(); } }
@Override public void mousePressed(EditorMouseEvent editorMouseEvent) { FileDocumentManager instance = FileDocumentManager.getInstance(); VirtualFile file = instance.getFile(editorMouseEvent.getEditor().getDocument()); Project project = editorMouseEvent.getEditor().getProject(); WakaTime.appendHeartbeat(file, project, false); }
@Override public void mouseClicked(EditorMouseEvent e) { final int offset = getEditorCharOffsetAndRemoveTokenHighlighters(e); if ( offset<0 ) return; final Editor editor=e.getEditor(); if ( inputPanel.previewState==null ) { return; } if ( e.getMouseEvent().getButton()==MouseEvent.BUTTON3 ) { // right click rightClick(e, inputPanel.previewState, editor, offset); return; } MouseEvent mouseEvent=e.getMouseEvent(); if ( mouseEvent.isControlDown() ) { inputPanel.setCursorToGrammarElement(e.getEditor().getProject(), inputPanel.previewState, offset); inputPanel.setCursorToHierarchyViewElement(offset); } else if ( mouseEvent.isAltDown() ) { inputPanel.setCursorToGrammarRule(e.getEditor().getProject(), inputPanel.previewState, offset); } else { inputPanel.setCursorToHierarchyViewElement(offset); } InputPanel.clearDecisionEventHighlighters(editor); }
public void mouseEnteredGrammarEditorEvent(VirtualFile vfile, EditorMouseEvent e) { if ( previewPanel!=null ) { ProfilerPanel profilerPanel = previewPanel.getProfilerPanel(); if ( profilerPanel!=null ) { profilerPanel.mouseEnteredGrammarEditorEvent(vfile, e); } } }
@Override public void mouseClicked(EditorMouseEvent e) { Document doc = e.getEditor().getDocument(); VirtualFile vfile = FileDocumentManager.getInstance().getFile(doc); if ( vfile!=null && vfile.getName().endsWith(".g4") ) { mouseEnteredGrammarEditorEvent(vfile, e); } }
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); } } }; }
public static EditorPopupHandler createEditorPopupHandler(@Nonnull final ActionGroup group) { return new EditorPopupHandler() { @Override public void invokePopup(final EditorMouseEvent event) { 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(); } }
private static DefaultActionGroup createPopupActions(ActionManager actionManager, ClearLogAction action, EditorEx editor, EditorMouseEvent event) { AnAction[] children = ((ActionGroup)actionManager.getAction(IdeActions.GROUP_CONSOLE_EDITOR_POPUP)).getChildren(null); DefaultActionGroup group = new DefaultActionGroup(); addConfigureNotificationAction(editor, event, group); group.addAll(children); group.addSeparator(); group.add(action); return group; }
@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 mouseMoved(@Nonnull EditorMouseEvent event) { Editor editor = event.getEditor(); if (editor.isOneLineMode()) { return; } alarm.cancelAllRequests(); Point point = event.getMouseEvent().getPoint(); if (myElements == null && event.getMouseEvent().isShiftDown()) { alarm.addRequest(new PreviewRequest(point, editor, false), 100); } else { Collection<PsiElement> elements = myElements; if (!getPsiElementsAt(point, editor).equals(elements)) { myElements = null; for (ElementPreviewProvider provider : Extensions.getExtensions(ElementPreviewProvider.EP_NAME)) { try { if (elements != null) { for (PsiElement element : elements) { provider.hide(element, editor); } } else { provider.hide(null, editor); } } catch (Exception e) { LOG.error(e); } } } } }