diff --git a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java index c6c8ef6e..5ca0ccd4 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/Presenter.java +++ b/diylc/diylc-core/src/org/diylc/presenter/Presenter.java @@ -1156,7 +1156,7 @@ public class Presenter implements IPlugInPort { return true; previousDragPoint.translate(actualD.x, actualD.y); - } else if (selectedComponents.isEmpty() && instantiationManager.getComponentTypeSlot() == null) { + } else if (selectedComponents.isEmpty() && instantiationManager.getComponentTypeSlot() == null && previousDragPoint != null) { // If there's no selection, the only thing to do is update the // selection rectangle and refresh. Rectangle oldSelectionRect = selectionRect == null ? null : new Rectangle(selectionRect); @@ -2135,10 +2135,10 @@ public class Presenter implements IPlugInPort { return; } - if (componentType == null) { - controlPointMap.clear(); - updateSelection(EMPTY_SELECTION); - } +// if (componentType == null) { +// controlPointMap.clear(); +// updateSelection(EMPTY_SELECTION); +// } // try to find a default template if none is provided if (componentType != null && template == null) { diff --git a/diylc/diylc-library/lib/diylc-core.jar b/diylc/diylc-library/lib/diylc-core.jar index e55f3779..e645285a 100644 Binary files a/diylc/diylc-library/lib/diylc-core.jar and b/diylc/diylc-library/lib/diylc-core.jar differ diff --git a/diylc/diylc-swing/lib/diylc-core.jar b/diylc/diylc-swing/lib/diylc-core.jar index e55f3779..e645285a 100644 Binary files a/diylc/diylc-swing/lib/diylc-core.jar and b/diylc/diylc-swing/lib/diylc-core.jar differ 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 da283b69..39d23efe 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 @@ -25,6 +25,7 @@ import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; +import org.diylc.common.ComponentType; import org.diylc.common.IPlugInPort; import org.diylc.swing.plugins.canvas.EmptyTransferable; import org.diylc.swing.plugins.tree.TreePanel.Payload; @@ -45,20 +46,37 @@ class TreeGestureListener implements DragGestureListener { @Override public void dragGestureRecognized(DragGestureEvent dge) { - 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 payload = (Payload) leaf.getUserObject(); - if (payload != null && (payload.getComponentType() != null || payload.getClickListener() != null)) { - if (payload.getComponentType() != null) - presenter.setNewComponentTypeSlot(payload.getComponentType(), null, true); - else - payload.getClickListener().mouseClicked(null); - dge.startDrag(presenter.getCursorAt(dge.getDragOrigin()), new EmptyTransferable(), new TreeSourceListener( - presenter)); + ComponentType type = null; + Payload payload = 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 = (Payload) leaf.getUserObject(); + if (payload != null && (payload.getComponentType() != null || payload.getClickListener() != null)) + type = payload.getComponentType(); + } + } else { + type = presenter.getNewComponentTypeSlot(); + } + + boolean start = false; + if (type == null) + { + if (payload != null && payload.getClickListener() != null) { + payload.getClickListener().mouseClicked(null); + start = true; } } + else { + presenter.setNewComponentTypeSlot(type, null, true); + start = true; + } + + if (start) + dge.startDrag(presenter.getCursorAt(dge.getDragOrigin()), new EmptyTransferable(), + new TreeSourceListener(presenter)); } } diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml index 096da9b0..2d207496 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -2397,7 +2397,15 @@ IMPROVEMENT Create a backup of config file when there is an issue with loading (cross-version) - + + + IMPROVEMENT + Automatically select dropped components from the component tree after they get placed + + + BUG_FIX + Drag&Drop from the tree sometimes picks up a wrong component type + https://github.com/bancika/diy-layout-creator/releases