dnd improvements

This commit is contained in:
Branislav Stojkovic
2019-02-03 09:58:19 +01:00
parent 91389ef09b
commit 6e9169242a
6 changed files with 74 additions and 61 deletions
@@ -1459,9 +1459,7 @@ public class Presenter implements IPlugInPort {
Point scaledPoint = scalePoint(point); Point scaledPoint = scalePoint(point);
if (!dragInProgress) { if (!dragInProgress && instantiationManager.getComponentSlot() == null) {
if (instantiationManager.getComponentSlot() != null)
addPendingComponentsToProject(scaledPoint, instantiationManager.getComponentTypeSlot(), null);
return; return;
} }
@@ -1488,6 +1486,9 @@ public class Presenter implements IPlugInPort {
// selectedComponents); // selectedComponents);
// messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED, // messageDispatcher.dispatchMessage(EventType.SELECTION_SIZE_CHANGED,
// calculateSelectionDimension()); // calculateSelectionDimension());
} else if (instantiationManager.getComponentSlot() != null) {
preDragProject = currentProject.clone();
addPendingComponentsToProject(scaledPoint, instantiationManager.getComponentTypeSlot(), null);
} else { } else {
updateSelection(selectedComponents); updateSelection(selectedComponents);
} }
@@ -2134,6 +2135,11 @@ public class Presenter implements IPlugInPort {
return; return;
} }
if (componentType == null) {
controlPointMap.clear();
updateSelection(EMPTY_SELECTION);
}
// try to find a default template if none is provided // try to find a default template if none is provided
if (componentType != null && template == null) { if (componentType != null && template == null) {
String defaultTemplate = getDefaultVariant(componentType.getCategory(), componentType.getName()); String defaultTemplate = getDefaultVariant(componentType.getCategory(), componentType.getName());
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -37,6 +37,7 @@ import org.diylc.common.IPlugInPort;
*/ */
class TreeSourceListener implements DragSourceListener { class TreeSourceListener implements DragSourceListener {
@SuppressWarnings("unused")
private IPlugInPort presenter; private IPlugInPort presenter;
public TreeSourceListener(IPlugInPort presenter) { public TreeSourceListener(IPlugInPort presenter) {
@@ -46,7 +47,8 @@ class TreeSourceListener implements DragSourceListener {
@Override @Override
public void dragDropEnd(DragSourceDropEvent dsde) { public void dragDropEnd(DragSourceDropEvent dsde) {
presenter.dragEnded(null); // if (!dsde.getDropSuccess())
// presenter.setNewComponentTypeSlot(null, null, false);
} }
@Override @Override
@@ -1,22 +1,27 @@
/* /*
*
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors. DIY Layout Creator (DIYLC).
* Copyright (c) 2009-2018 held jointly by the individual authors.
* This file is part of DIYLC.
* This file is part of DIYLC.
* DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation, either version 3 of the DIYLC is free software: you can redistribute it and/or modify
* License, or (at your option) any later version. it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even (at your option) any later version.
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. DIYLC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* <http://www.gnu.org/licenses/>. GNU General Public License for more details.
*/
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.swing.plugins.tree; package org.diylc.swing.plugins.tree;
import java.awt.Point;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetDropEvent;