no dnd when there's no selected live template at the mouse position (IDEA-74040)

This commit is contained in:
peter
2011-09-08 14:29:00 +02:00
parent c6e8a21af8
commit e575d74ae1
2 changed files with 7 additions and 3 deletions
@@ -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);