void () { DnDSupport.createBuilder(this) .setBeanProvider(info -> { final GutterIconRenderer renderer = getGutterRenderer(info.getPoint()); if (renderer != null && renderer.getDraggableObject() != null && (info.isCopy() || info.isMove())) { myDnDInProgress = true; return new DnDDragStartBean(renderer); } return null; }) .setDropHandlerWithResult(e -> { boolean success = true; 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(), e.getAction().getActionId()); } } } else if (attachedObject instanceof DnDNativeTarget.EventInfo && myEditor.getSettings().isDndEnabled()) { Transferable transferable = ((DnDNativeTarget.EventInfo)attachedObject).getTransferable(); if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { success = EditorImpl.handleDrop(myEditor, transferable, e.getAction().getActionId()); } } myDnDInProgress = false; return success; }) .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, myEditor.getVirtualFile(), e.getAction().getActionId())); } } } 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(info -> { // [tav] temp workaround for JRE-224 boolean inUserScale = !SystemInfo.isWindows || !StartupUiUtil.isJreHiDPI(myEditor.getComponent()); Image image = ImageUtil.toBufferedImage(getDragImage(getGutterRenderer(info.getPoint())), inUserScale); return new DnDImage(image, new Point(image.getWidth(null) / 2, image.getHeight(null) / 2)); }) .enableAsNativeTarget() // required to accept dragging from editor (as editor component doesn't use DnDSupport to implement drag-n-drop) .install(); }