mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
no dnd when there's no selected live template at the mouse position (IDEA-74040)
This commit is contained in:
+6
-2
@@ -614,6 +614,9 @@ public class TemplateListPanel extends JPanel implements Disposable {
|
||||
.setBeanProvider(new NullableFunction<DnDActionInfo, DnDDragStartBean>() {
|
||||
@Override
|
||||
public DnDDragStartBean fun(DnDActionInfo dnDActionInfo) {
|
||||
Point point = dnDActionInfo.getPoint();
|
||||
if (myTree.getPathForLocation(point.x, point.y) == null) return null;
|
||||
|
||||
int selectedIndex = getSelectedIndex();
|
||||
TemplateImpl template = getTemplate(selectedIndex);
|
||||
return template != null ? new DnDDragStartBean(Pair.create(template, getNode(selectedIndex))) : null;
|
||||
@@ -640,11 +643,12 @@ public class TemplateListPanel extends JPanel implements Disposable {
|
||||
moveTemplate(pair.first, ObjectUtils.assertNotNull(getDropGroup(event)).getName(), pair.second);
|
||||
}
|
||||
})
|
||||
.setImageProvider(new Function<DnDActionInfo, DnDImage>() {
|
||||
.setImageProvider(new NullableFunction<DnDActionInfo, DnDImage>() {
|
||||
@Override
|
||||
public DnDImage fun(DnDActionInfo dnDActionInfo) {
|
||||
Point point = dnDActionInfo.getPoint();
|
||||
return new DnDImage(DnDAwareTree.getDragImage(myTree, myTree.getPathForLocation(point.x, point.y), point).first);
|
||||
TreePath path = myTree.getPathForLocation(point.x, point.y);
|
||||
return path == null ? null : new DnDImage(DnDAwareTree.getDragImage(myTree, path, point).first);
|
||||
}
|
||||
})
|
||||
.install();
|
||||
|
||||
@@ -66,7 +66,7 @@ public class DnDAwareTree extends Tree implements DnDAware {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Pair<Image, Point> getDragImage(Tree dndAwareTree, TreePath path, Point dragOrigin) {
|
||||
public static Pair<Image, Point> getDragImage(Tree dndAwareTree, @NotNull TreePath path, Point dragOrigin) {
|
||||
int row = dndAwareTree.getRowForPath(path);
|
||||
Component comp = dndAwareTree.getCellRenderer().getTreeCellRendererComponent(dndAwareTree, path.getLastPathComponent(), false, true, true, row, false);
|
||||
return createDragImage(dndAwareTree, comp, dragOrigin, true);
|
||||
|
||||
Reference in New Issue
Block a user