diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
index 39b28ab6..cb525390 100644
--- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
+++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java
@@ -1649,7 +1649,7 @@ public class Presenter implements IPlugInPort {
if (selectedComponents.isEmpty()) {
// If there's no selection finalize selectionRect and see which
// components intersect with it.
- if (scaledPoint != null) {
+ if (scaledPoint != null && previousDragPoint != null) {
this.selectionRect = Utils.createRectangle(new Point((int)scaledPoint.getX(), (int)scaledPoint.getY()),
new Point((int)previousDragPoint.getX(), (int)previousDragPoint.getY()));;
}
diff --git a/diylc/diylc-core/src/org/diylc/presenter/update.xml b/diylc/diylc-core/src/org/diylc/presenter/update.xml
index f00c2b42..c7e56dc0 100644
--- a/diylc/diylc-core/src/org/diylc/presenter/update.xml
+++ b/diylc/diylc-core/src/org/diylc/presenter/update.xml
@@ -3325,6 +3325,10 @@
IMPROVEMENT
When rotating Vero and Tri-Pad boards, change the orientation of strips to match the rotation angle
+
+
+ BUG_FIX
+ Dragging components from the component tree to the canvas stops working once the component type is selected in the tree
https://github.com/bancika/diy-layout-creator/releases
diff --git a/diylc/diylc-swing/src/org/diylc/swing/plugins/tree/TreeGestureListener.java b/diylc/diylc-swing/src/org/diylc/swing/plugins/tree/TreeGestureListener.java
index ba9742ac..b21ee6fe 100644
--- a/diylc/diylc-swing/src/org/diylc/swing/plugins/tree/TreeGestureListener.java
+++ b/diylc/diylc-swing/src/org/diylc/swing/plugins/tree/TreeGestureListener.java
@@ -20,9 +20,9 @@ package org.diylc.swing.plugins.tree;
import java.awt.Point;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
+import java.awt.event.MouseListener;
import javax.swing.JTree;
-import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import org.diylc.common.ComponentType;
@@ -46,16 +46,15 @@ class TreeGestureListener implements DragGestureListener {
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
ComponentType type = null;
- TreeNode payload = null;
+ MouseListener clickListener = null;
if (presenter.getNewComponentTypeSlot() == null) {
JTree tree = (JTree) dge.getComponent();
Point p = dge.getDragOrigin();
TreePath path = tree.getClosestPathForLocation(p.x, p.y);
- if (path != null && path.getLastPathComponent() instanceof DefaultMutableTreeNode) {
- DefaultMutableTreeNode leaf = (DefaultMutableTreeNode) path.getLastPathComponent();
- payload = (TreeNode) leaf.getUserObject();
- if (payload != null && (payload.getComponentType() != null || payload.getClickListener() != null))
- type = payload.getComponentType();
+ if (path != null && path.getLastPathComponent() instanceof TreeNode) {
+ TreeNode leaf = (TreeNode) path.getLastPathComponent();
+ clickListener = leaf.getClickListener();
+ type = leaf.getComponentType();
}
} else {
type = presenter.getNewComponentTypeSlot();
@@ -64,8 +63,8 @@ class TreeGestureListener implements DragGestureListener {
boolean start = false;
if (type == null)
{
- if (payload != null && payload.getClickListener() != null) {
- payload.getClickListener().mouseClicked(null);
+ if (clickListener != null) {
+ clickListener.mouseClicked(null);
start = true;
}
}