Browse Source

REPORT-66884 修正拖拽组件时候备份组件的时机

bugfix/11.0
方磊 3 years ago
parent
commit
776c38aa4e
  1. 10
      designer-form/src/main/java/com/fr/design/designer/beans/models/DraggingModel.java
  2. 6
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  3. 20
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  4. 7
      designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java

10
designer-form/src/main/java/com/fr/design/designer/beans/models/DraggingModel.java

@ -14,7 +14,6 @@ public class DraggingModel {
private MouseEvent currentDragEvent;
private int creatorLeftTopX = -999; // 隐藏
private int creatorLeftTopY = -999; // 隐藏
private boolean dragNewWidget; // 是否正在拖拽一个新的组件下来
public DraggingModel() {
@ -40,11 +39,6 @@ public class DraggingModel {
return this;
}
public DraggingModel dragNewWidget(boolean dragNewWidget) {
this.dragNewWidget = dragNewWidget;
return this;
}
public FormDesigner getDesigner() {
return designer;
}
@ -79,10 +73,6 @@ public class DraggingModel {
return creatorLeftTopY;
}
public boolean isDragNewWidget() {
return dragNewWidget;
}
public void moveTo(int x, int y) {
XLayoutContainer container = designer.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter();

6
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -264,11 +264,7 @@ public class FormCreatorDropTarget extends DropTarget {
Point loc = dtde.getLocation();
int x = designer.getRelativeX(loc.x);
int y = designer.getRelativeY(loc.y);
if (model.isDragNewWidget()) {
designer.addNewWidget(creator, x, y);
} else {
designer.changeWidgetPlace(creator, x, y);
}
designer.addWidgetToForm(creator, x, y);
// 放到事件末尾执行
SwingUtilities.invokeLater(new Runnable() {
@Override

20
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1252,12 +1252,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return;
}
instantiateCreator(xCreator);
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent)
.dragNewWidget(true);
.currentDragEvent(currentDragEvent);
this.setDropTarget(new FormCreatorDropTarget(this, xCreator));
repaint();
}
@ -1273,12 +1273,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
if (currentDragEvent == null || this.getDropTarget() != null) {
return;
}
backUpCreator(xCreator);
draggingModel = new DraggingModel()
.designer(this)
.creator(xCreator)
.startDragEvent(startDragEvent)
.currentDragEvent(currentDragEvent)
.dragNewWidget(false);
.currentDragEvent(currentDragEvent);
XLayoutContainer container = this.getDraggingHotspotLayout();
LayoutAdapter adapter = container.getLayoutAdapter();
adapter.dragging(this.getDraggingModel());
@ -1990,7 +1990,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return spacingLineDrawer;
}
private void instantiateCreator(XCreator creator) {
public void instantiateCreator(XCreator creator) {
ModelUtil.renameWidgetName(this.getTarget(), creator);
creator.addNotify();
@ -1999,18 +1999,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter);
}
public void addNewWidget(XCreator creator, int x, int y) {
instantiateCreator(creator);
addWidgetToForm(creator, x, y);
}
public void changeWidgetPlace(XCreator creator, int x, int y) {
public void backUpCreator(XCreator creator) {
creator.backupCurrentSize();
creator.backupParent();
addWidgetToForm(creator, x, y);
}
private void addWidgetToForm(XCreator creator, int x, int y) {
public void addWidgetToForm(XCreator creator, int x, int y) {
if(creator == null) {
return;
}

7
designer-realize/src/main/java/com/fr/design/mainframe/guide/creator/GuideCreateUtils.java

@ -130,12 +130,13 @@ public class GuideCreateUtils {
return;
}
FormDesigner designer = GuideCreateUtils.getFormDesigner();
designer.getSelectionModel().selectACreator(xLayoutContainer);
if (dragNewComponent) {
designer.addNewWidget(xCreator, xLayoutContainer.getX(), xLayoutContainer.getY());
designer.instantiateCreator(xCreator);
} else {
designer.changeWidgetPlace(xCreator, xLayoutContainer.getX(), xLayoutContainer.getY());
designer.backUpCreator(xCreator);
}
designer.getSelectionModel().selectACreator(xLayoutContainer);
designer.addWidgetToForm(xCreator, xLayoutContainer.getX(), xLayoutContainer.getY());
designer.getSelectionModel().selectACreator(xCreator);
}

Loading…
Cancel
Save