Search in sources :

Example 1 with EditorComponentImpl

use of com.intellij.openapi.editor.impl.EditorComponentImpl in project intellij-community by JetBrains.

the class EditorFixture method moveToAndClick.

/**
   * Moves the caret to the given caret offset (0-based).
   *
   * @param offset the character offset.
   */
public EditorFixture moveToAndClick(final int offset, MouseButton button) {
    assertThat(offset).isGreaterThanOrEqualTo(0);
    execute(new GuiTask() {

        @Override
        protected void executeInEDT() throws Throwable {
            FileEditorManager manager = FileEditorManager.getInstance(myFrame.getProject());
            Editor editor = manager.getSelectedTextEditor();
            assert editor != null;
            VisualPosition visualPosition = editor.offsetToVisualPosition(offset);
            Point point = editor.visualPositionToXY(visualPosition);
            Component editorComponent = robot.finder().find(editor.getComponent(), component -> component instanceof EditorComponentImpl);
            robot.click(editorComponent, point, button, 1);
        }
    });
    return this;
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) Condition(org.fest.swing.timing.Condition) GuiQuery(org.fest.swing.edt.GuiQuery) KeymapManager(com.intellij.openapi.keymap.KeymapManager) ComponentDriver(org.fest.swing.driver.ComponentDriver) HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) VirtualFile(com.intellij.openapi.vfs.VirtualFile) HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) com.intellij.openapi.editor(com.intellij.openapi.editor) GenericTypeMatcher(org.fest.swing.core.GenericTypeMatcher) MouseButton(org.fest.swing.core.MouseButton) GuiActionRunner.execute(org.fest.swing.edt.GuiActionRunner.execute) Strings.quote(org.fest.util.Strings.quote) Keymap(com.intellij.openapi.keymap.Keymap) ArrayList(java.util.ArrayList) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) Reflection.method(org.fest.reflect.core.Reflection.method) Assertions.assertThat(org.fest.assertions.Assertions.assertThat) Project(com.intellij.openapi.project.Project) TextHitInfo(java.awt.font.TextHitInfo) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) JBList(com.intellij.ui.components.JBList) FocusManager(javax.swing.FocusManager) GuiTestUtil(com.intellij.testGuiFramework.framework.GuiTestUtil) TextRange(com.intellij.openapi.util.TextRange) AttributedString(java.text.AttributedString) KeyEvent(java.awt.event.KeyEvent) FileEditor(com.intellij.openapi.fileEditor.FileEditor) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) DialogFixture(org.fest.swing.fixture.DialogFixture) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) InputMethodEvent(java.awt.event.InputMethodEvent) AttributedCharacterIterator(java.text.AttributedCharacterIterator) GuiTask(org.fest.swing.edt.GuiTask) Pause.pause(org.fest.swing.timing.Pause.pause) EditorComponentImpl(com.intellij.openapi.editor.impl.EditorComponentImpl) Robot(org.fest.swing.core.Robot) NotNull(org.jetbrains.annotations.NotNull) Assert(org.junit.Assert) Ref(com.intellij.openapi.util.Ref) javax.swing(javax.swing) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) EditorComponentImpl(com.intellij.openapi.editor.impl.EditorComponentImpl) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 2 with EditorComponentImpl

use of com.intellij.openapi.editor.impl.EditorComponentImpl in project intellij-community by JetBrains.

the class AbstractValueHint method showHint.

protected boolean showHint(final JComponent component) {
    myInsideShow = true;
    if (myCurrentHint != null) {
        myCurrentHint.hide();
    }
    myCurrentHint = new LightweightHint(component) {

        @Override
        protected boolean canAutoHideOn(TooltipEvent event) {
            InputEvent inputEvent = event.getInputEvent();
            if (inputEvent instanceof MouseEvent) {
                Component comp = inputEvent.getComponent();
                if (comp instanceof EditorComponentImpl) {
                    EditorImpl editor = ((EditorComponentImpl) comp).getEditor();
                    return !isInsideCurrentRange(editor, ((MouseEvent) inputEvent).getPoint());
                }
            }
            return true;
        }
    };
    myCurrentHint.addHintListener(new HintListener() {

        @Override
        public void hintHidden(EventObject event) {
            if (myHideRunnable != null && !myInsideShow) {
                myHideRunnable.run();
            }
            onHintHidden();
        }
    });
    // editor may be disposed before later invokator process this action
    if (myEditor.isDisposed() || myEditor.getComponent().getRootPane() == null) {
        return false;
    }
    Point p = HintManagerImpl.getHintPosition(myCurrentHint, myEditor, myEditor.xyToLogicalPosition(myPoint), HintManager.UNDER);
    HintHint hint = HintManagerImpl.createHintHint(myEditor, p, myCurrentHint, HintManager.UNDER, true);
    hint.setShowImmediately(true);
    HintManagerImpl.getInstanceImpl().showEditorHint(myCurrentHint, myEditor, p, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false, hint);
    myInsideShow = false;
    return true;
}
Also used : EditorMouseEvent(com.intellij.openapi.editor.event.EditorMouseEvent) TooltipEvent(com.intellij.ide.TooltipEvent) EditorComponentImpl(com.intellij.openapi.editor.impl.EditorComponentImpl) EditorImpl(com.intellij.openapi.editor.impl.EditorImpl) RelativePoint(com.intellij.ui.awt.RelativePoint) EventObject(java.util.EventObject)

Aggregations

EditorComponentImpl (com.intellij.openapi.editor.impl.EditorComponentImpl)2 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)1 TooltipEvent (com.intellij.ide.TooltipEvent)1 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 com.intellij.openapi.editor (com.intellij.openapi.editor)1 EditorMouseEvent (com.intellij.openapi.editor.event.EditorMouseEvent)1 EditorImpl (com.intellij.openapi.editor.impl.EditorImpl)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Keymap (com.intellij.openapi.keymap.Keymap)1 KeymapManager (com.intellij.openapi.keymap.KeymapManager)1 Project (com.intellij.openapi.project.Project)1 Ref (com.intellij.openapi.util.Ref)1 TextRange (com.intellij.openapi.util.TextRange)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 GuiTestUtil (com.intellij.testGuiFramework.framework.GuiTestUtil)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 JBList (com.intellij.ui.components.JBList)1