Search in sources :

Example 16 with GutterMark

use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.

the class EditorGutterComponentImpl method installDnD.

@SuppressWarnings("ConstantConditions")
private void installDnD() {
    DnDSupport.createBuilder(this).setBeanProvider(info -> {
        final GutterMark renderer = getGutterRenderer(info.getPoint());
        if (renderer instanceof GutterIconRenderer && ((GutterIconRenderer) renderer).getDraggableObject() != null && (info.isCopy() || info.isMove())) {
            myDnDInProgress = true;
            return new DnDDragStartBean(renderer);
        }
        return null;
    }).setDropHandler(e -> {
        final Object attachedObject = e.getAttachedObject();
        if (attachedObject instanceof GutterIconRenderer && checkDumbAware(attachedObject)) {
            final GutterDraggableObject draggableObject = ((GutterIconRenderer) attachedObject).getDraggableObject();
            if (draggableObject != null) {
                final int line = convertPointToLineNumber(e.getPoint());
                if (line != -1) {
                    draggableObject.copy(line, myEditor.getVirtualFile());
                }
            }
        } else if (attachedObject instanceof DnDNativeTarget.EventInfo && myEditor.getSettings().isDndEnabled()) {
            Transferable transferable = ((DnDNativeTarget.EventInfo) attachedObject).getTransferable();
            if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                EditorImpl.handleDrop(myEditor, transferable, e.getAction().getActionId());
            }
        }
        myDnDInProgress = false;
    }).setTargetChecker(e -> {
        final Object attachedObject = e.getAttachedObject();
        if (attachedObject instanceof GutterIconRenderer && checkDumbAware(attachedObject)) {
            final GutterDraggableObject draggableObject = ((GutterIconRenderer) attachedObject).getDraggableObject();
            if (draggableObject != null) {
                final int line = convertPointToLineNumber(e.getPoint());
                if (line != -1) {
                    e.setDropPossible(true);
                    e.setCursor(draggableObject.getCursor(line));
                }
            }
        } else if (attachedObject instanceof DnDNativeTarget.EventInfo && myEditor.getSettings().isDndEnabled()) {
            Transferable transferable = ((DnDNativeTarget.EventInfo) attachedObject).getTransferable();
            if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                final int line = convertPointToLineNumber(e.getPoint());
                if (line != -1) {
                    e.setDropPossible(true);
                    myEditor.getCaretModel().moveToOffset(myEditor.getDocument().getLineStartOffset(line));
                }
            }
        }
        return true;
    }).setImageProvider((NullableFunction<DnDActionInfo, DnDImage>) info -> {
        boolean inUserScale = SystemInfo.isWindows ? !UIUtil.isJreHiDPI(myEditor.getComponent()) : true;
        Image image = ImageUtil.toBufferedImage(getDragImage(getGutterRenderer(info.getPoint())), inUserScale);
        return new DnDImage(image, new Point(image.getWidth(null) / 2, image.getHeight(null) / 2));
    }).enableAsNativeTarget().install();
}
Also used : ScalableIcon(com.intellij.openapi.util.ScalableIcon) TIntFunction(gnu.trove.TIntFunction) HashMap(com.intellij.util.containers.HashMap) EditorUtil(com.intellij.openapi.editor.ex.util.EditorUtil) EditorFontType(com.intellij.openapi.editor.colors.EditorFontType) Balloon(com.intellij.openapi.ui.popup.Balloon) EditorMouseEventArea(com.intellij.openapi.editor.event.EditorMouseEventArea) ColorKey(com.intellij.openapi.editor.colors.ColorKey) TIntObjectHashMap(gnu.trove.TIntObjectHashMap) Logger(com.intellij.openapi.diagnostic.Logger) IterationState(com.intellij.openapi.editor.impl.view.IterationState) TIntArrayList(gnu.trove.TIntArrayList) DumbService(com.intellij.openapi.project.DumbService) ComponentUI(javax.swing.plaf.ComponentUI) com.intellij.openapi.editor.markup(com.intellij.openapi.editor.markup) AffineTransform(java.awt.geom.AffineTransform) TooltipController(com.intellij.codeInsight.hint.TooltipController) TIntObjectProcedure(gnu.trove.TIntObjectProcedure) IdeGlassPaneImpl(com.intellij.openapi.wm.impl.IdeGlassPaneImpl) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) com.intellij.util.ui(com.intellij.util.ui) java.awt.event(java.awt.event) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Registry(com.intellij.openapi.util.registry.Registry) NonHideableIconGutterMark(com.intellij.codeInsight.daemon.NonHideableIconGutterMark) com.intellij.util(com.intellij.util) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) RelativePoint(com.intellij.ui.awt.RelativePoint) JBColor(com.intellij.ui.JBColor) java.util(java.util) GutterMark(com.intellij.codeInsight.daemon.GutterMark) DataFlavor(java.awt.datatransfer.DataFlavor) ActionUtil(com.intellij.openapi.actionSystem.ex.ActionUtil) com.intellij.openapi.editor(com.intellij.openapi.editor) Transferable(java.awt.datatransfer.Transferable) NonNls(org.jetbrains.annotations.NonNls) ContainerUtil(com.intellij.util.containers.ContainerUtil) IdeEventQueue(com.intellij.ide.IdeEventQueue) Comparing(com.intellij.openapi.util.Comparing) HintHint(com.intellij.ui.HintHint) Project(com.intellij.openapi.project.Project) com.intellij.openapi.editor.ex(com.intellij.openapi.editor.ex) com.intellij.ide.dnd(com.intellij.ide.dnd) StringUtil(com.intellij.openapi.util.text.StringUtil) JBUIScaleTrackable(com.intellij.util.ui.JBUI.JBUIScaleTrackable) SystemInfo(com.intellij.openapi.util.SystemInfo) TooltipGroup(com.intellij.codeInsight.hint.TooltipGroup) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) EditorUIUtil(com.intellij.openapi.editor.ex.util.EditorUIUtil) VisualLinesIterator(com.intellij.openapi.editor.impl.view.VisualLinesIterator) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) EditorColors(com.intellij.openapi.editor.colors.EditorColors) CustomActionsSchema(com.intellij.ide.ui.customization.CustomActionsSchema) javax.swing(javax.swing) Transferable(java.awt.datatransfer.Transferable) RelativePoint(com.intellij.ui.awt.RelativePoint) NonHideableIconGutterMark(com.intellij.codeInsight.daemon.NonHideableIconGutterMark) GutterMark(com.intellij.codeInsight.daemon.GutterMark) RelativePoint(com.intellij.ui.awt.RelativePoint) HintHint(com.intellij.ui.HintHint)

Example 17 with GutterMark

use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.

the class EditorGutterComponentImpl method getGutterRenderer.

@Nullable
private GutterMark getGutterRenderer(final Point p) {
    int line = convertPointToLineNumber(p);
    if (line == -1)
        return null;
    List<GutterMark> renderers = getGutterRenderers(line);
    if (renderers == null) {
        return null;
    }
    final GutterMark[] result = { null };
    processIconsRow(line, renderers, (x, y, renderer) -> {
        final int ex = convertX((int) p.getX());
        Icon icon = scaleIcon(renderer.getIcon());
        // Do not check y to extend the area where users could click
        if (x <= ex && ex <= x + icon.getIconWidth()) {
            result[0] = renderer;
        }
    });
    return result[0];
}
Also used : ScalableIcon(com.intellij.openapi.util.ScalableIcon) NonHideableIconGutterMark(com.intellij.codeInsight.daemon.NonHideableIconGutterMark) GutterMark(com.intellij.codeInsight.daemon.GutterMark) RelativePoint(com.intellij.ui.awt.RelativePoint) HintHint(com.intellij.ui.HintHint) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with GutterMark

use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.

the class EditorGutterComponentImpl method calcLineMarkerAreaWidth.

private void calcLineMarkerAreaWidth(boolean canShrink) {
    myLeftFreePaintersAreaShown = myForceLeftFreePaintersAreaShown;
    myRightFreePaintersAreaShown = myForceRightFreePaintersAreaShown;
    processRangeHighlighters(0, myEditor.getDocument().getTextLength(), highlighter -> {
        LineMarkerRenderer lineMarkerRenderer = highlighter.getLineMarkerRenderer();
        if (lineMarkerRenderer != null) {
            LineMarkerRendererEx.Position position = getLineMarkerPosition(lineMarkerRenderer);
            if (position == LineMarkerRendererEx.Position.LEFT && isLineMarkerVisible(highlighter))
                myLeftFreePaintersAreaShown = true;
            if (position == LineMarkerRendererEx.Position.RIGHT && isLineMarkerVisible(highlighter))
                myRightFreePaintersAreaShown = true;
        }
    });
    int minWidth = areIconsShown() ? (int) (START_ICON_AREA_WIDTH * myEditor.getScale()) : 0;
    myIconsAreaWidth = canShrink ? minWidth : Math.max(myIconsAreaWidth, minWidth);
    processGutterRenderers((line, renderers) -> {
        int width = 1;
        for (int i = 0; i < renderers.size(); i++) {
            GutterMark renderer = renderers.get(i);
            if (!checkDumbAware(renderer))
                continue;
            width += scaleIcon(renderer.getIcon()).getIconWidth();
            if (i > 0)
                width += GAP_BETWEEN_ICONS;
        }
        if (myIconsAreaWidth < width) {
            myIconsAreaWidth = width + 1;
        }
        return true;
    });
    if (isDumbMode()) {
        myIconsAreaWidth = Math.max(myIconsAreaWidth, myLastNonDumbModeIconAreaWidth);
    } else {
        myLastNonDumbModeIconAreaWidth = myIconsAreaWidth;
    }
}
Also used : NonHideableIconGutterMark(com.intellij.codeInsight.daemon.NonHideableIconGutterMark) GutterMark(com.intellij.codeInsight.daemon.GutterMark) RelativePoint(com.intellij.ui.awt.RelativePoint) HintHint(com.intellij.ui.HintHint)

Example 19 with GutterMark

use of com.intellij.codeInsight.daemon.GutterMark in project intellij-community by JetBrains.

the class DescriptionTypeRelatedItemLineMarkerProviderTest method testInspectionDescriptionFromFieldReference.

public void testInspectionDescriptionFromFieldReference() {
    myFixture.copyDirectoryToProject("inspectionDescriptions", "inspectionDescriptions");
    final GutterMark gutter = myFixture.findGutter("MyWithDescriptionFromFieldReferenceInspection.java");
    DevKitGutterTargetsChecker.checkGutterTargets(gutter, "Description", AllIcons.FileTypes.Html, "MyWithDescriptionFromFieldReferenceInspection.html");
}
Also used : GutterMark(com.intellij.codeInsight.daemon.GutterMark)

Example 20 with GutterMark

use of com.intellij.codeInsight.daemon.GutterMark in project intellij-plugins by JetBrains.

the class FlexColorAnnotatorTest method testGutter4.

@JSTestOptions({ JSTestOption.WithFlexFacet, JSTestOption.WithCssSupportLoader })
public void testGutter4() throws Exception {
    GutterMark r = myFixture.findGutter(getTestName(false) + '.' + "css");
    assertNotNull(r);
    assertInstanceOf(r.getIcon(), ColorIconCache.ColorIcon.class);
}
Also used : GutterMark(com.intellij.codeInsight.daemon.GutterMark) ColorIconCache(com.intellij.xml.util.ColorIconCache) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Aggregations

GutterMark (com.intellij.codeInsight.daemon.GutterMark)23 NonHideableIconGutterMark (com.intellij.codeInsight.daemon.NonHideableIconGutterMark)6 HintHint (com.intellij.ui.HintHint)6 RelativePoint (com.intellij.ui.awt.RelativePoint)6 ScalableIcon (com.intellij.openapi.util.ScalableIcon)4 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)3 Ref (com.intellij.openapi.util.Ref)3 TooltipController (com.intellij.codeInsight.hint.TooltipController)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 Document (com.intellij.openapi.editor.Document)2 MarkupModelEx (com.intellij.openapi.editor.ex.MarkupModelEx)2 RangeHighlighterEx (com.intellij.openapi.editor.ex.RangeHighlighterEx)2 com.intellij.openapi.editor.markup (com.intellij.openapi.editor.markup)2 Project (com.intellij.openapi.project.Project)2 Balloon (com.intellij.openapi.ui.popup.Balloon)2 ContainerUtil (com.intellij.util.containers.ContainerUtil)2 ColorIconCache (com.intellij.xml.util.ColorIconCache)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 GutterIconNavigationHandler (com.intellij.codeInsight.daemon.GutterIconNavigationHandler)1