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();
}
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];
}
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;
}
}
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");
}
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);
}
Aggregations