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);
} }
@@ -2133,6 +2134,11 @@ public class Presenter implements IPlugInPort {
setNewComponentTypeSlot(null, null, false); setNewComponentTypeSlot(null, null, false);
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) {
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -26,7 +26,7 @@ import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent; import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent; import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener; import java.awt.dnd.DragSourceListener;
import org.diylc.common.IPlugInPort; import org.diylc.common.IPlugInPort;
@@ -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) {
@@ -45,8 +46,9 @@ 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,62 +1,67 @@
/* /*
*
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
*
* 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
* License, or (at your option) any later version.
*
* DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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;
import java.awt.dnd.DnDConstants; DIY Layout Creator (DIYLC).
import java.awt.dnd.DropTargetDragEvent; Copyright (c) 2009-2018 held jointly by the individual authors.
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import org.diylc.common.IPlugInPort; 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 License, or
(at your option) any later version.
/** DIYLC is distributed in the hope that it will be useful,
* {@link DropTargetListener} for {@link TreePanel}. but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* @author Branislav Stojkovic GNU General Public License for more details.
*/
class TreeTargetListener implements DropTargetListener {
private IPlugInPort presenter; You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
public TreeTargetListener(IPlugInPort presenter) { */
super(); package org.diylc.swing.plugins.tree;
this.presenter = presenter;
} import java.awt.Point;
import java.awt.dnd.DnDConstants;
@Override import java.awt.dnd.DropTargetDragEvent;
public void dragEnter(DropTargetDragEvent dtde) {} import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
@Override import java.awt.dnd.DropTargetListener;
public void dragExit(DropTargetEvent dte) {}
import org.diylc.common.IPlugInPort;
@Override
public void dragOver(DropTargetDragEvent dtde) {
dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); /**
} * {@link DropTargetListener} for {@link TreePanel}.
*
@Override * @author Branislav Stojkovic
public void drop(DropTargetDropEvent dtde) { */
presenter.setNewComponentTypeSlot(null, null, false); class TreeTargetListener implements DropTargetListener {
}
private IPlugInPort presenter;
@Override
public void dropActionChanged(DropTargetDragEvent dtde) { public TreeTargetListener(IPlugInPort presenter) {
} super();
} this.presenter = presenter;
}
@Override
public void dragEnter(DropTargetDragEvent dtde) {}
@Override
public void dragExit(DropTargetEvent dte) {}
@Override
public void dragOver(DropTargetDragEvent dtde) {
dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE);
}
@Override
public void drop(DropTargetDropEvent dtde) {
presenter.setNewComponentTypeSlot(null, null, false);
}
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
}
}