mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
fixed undo with d&d
This commit is contained in:
+6
-6
@@ -88,6 +88,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
// D&D
|
// D&D
|
||||||
private boolean dragInProgress = false;
|
private boolean dragInProgress = false;
|
||||||
private Point dragStartPoint = null;
|
private Point dragStartPoint = null;
|
||||||
|
private Project preDragProject = null;
|
||||||
|
|
||||||
private IComponentType componentSlot;
|
private IComponentType componentSlot;
|
||||||
|
|
||||||
@@ -431,6 +432,7 @@ public class Presenter implements IPlugInPort {
|
|||||||
LOG.debug(String.format("dragStarted(%s)", point));
|
LOG.debug(String.format("dragStarted(%s)", point));
|
||||||
dragInProgress = true;
|
dragInProgress = true;
|
||||||
dragStartPoint = point;
|
dragStartPoint = point;
|
||||||
|
preDragProject = cloner.deepClone(currentProject);
|
||||||
Point scaledPoint = scalePoint(point);
|
Point scaledPoint = scalePoint(point);
|
||||||
List<IComponentInstance> components = findComponentsAt(scaledPoint);
|
List<IComponentInstance> components = findComponentsAt(scaledPoint);
|
||||||
if (!componentsUnderCursor.isEmpty()) {
|
if (!componentsUnderCursor.isEmpty()) {
|
||||||
@@ -511,18 +513,16 @@ public class Presenter implements IPlugInPort {
|
|||||||
}
|
}
|
||||||
selectionRect = null;
|
selectionRect = null;
|
||||||
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
messageDispatcher.dispatchMessage(EventType.SELECTION_CHANGED, selectedComponents);
|
||||||
} else {
|
}
|
||||||
// There is selection, so we need to finalize the drag&drop
|
// There is selection, so we need to finalize the drag&drop
|
||||||
// operation.
|
// operation.
|
||||||
Project oldProject = cloner.deepClone(currentProject);
|
|
||||||
|
|
||||||
// If there are components selected translate their control points.
|
// If there are components selected translate their control points.
|
||||||
translateSelectedComponents(dragStartPoint, point);
|
// translateSelectedComponents(dragStartPoint, point);
|
||||||
if (!oldProject.equals(currentProject)) {
|
if (!preDragProject.equals(currentProject)) {
|
||||||
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, oldProject, cloner
|
messageDispatcher.dispatchMessage(EventType.PROJECT_MODIFIED, preDragProject, cloner
|
||||||
.deepClone(currentProject), "Move");
|
.deepClone(currentProject), "Move");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
messageDispatcher.dispatchMessage(EventType.REPAINT);
|
||||||
dragInProgress = false;
|
dragInProgress = false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user