|
|
|
@ -229,6 +229,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
populateParameterPropertyPane(); |
|
|
|
|
|
|
|
|
|
spacingLineDrawer = new FormSpacingLineDrawer(this); |
|
|
|
|
clearDropTarget(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -822,6 +823,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
draggingModel = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void clearDropTarget() { |
|
|
|
|
this.setDropTarget(null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 更新拖拽model的位置 |
|
|
|
|
*/ |
|
|
|
@ -1243,7 +1248,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
* @param currentDragEvent |
|
|
|
|
*/ |
|
|
|
|
public void startDraggingNewWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) { |
|
|
|
|
if (startDragEvent == null || currentDragEvent == null) { |
|
|
|
|
if (currentDragEvent == null || this.getDropTarget() != null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1251,21 +1256,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
.designer(this) |
|
|
|
|
.creator(xCreator) |
|
|
|
|
.startDragEvent(startDragEvent) |
|
|
|
|
.currentDragEvent(currentDragEvent); |
|
|
|
|
instantiateCreator(xCreator); |
|
|
|
|
addingModel = new AddingModel(xCreator); |
|
|
|
|
.currentDragEvent(currentDragEvent) |
|
|
|
|
.dragNewWidget(true); |
|
|
|
|
this.setDropTarget(new FormCreatorDropTarget(this, xCreator)); |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void instantiateCreator(XCreator creator) { |
|
|
|
|
ModelUtil.renameWidgetName(this.getTarget(), creator); |
|
|
|
|
ComponentAdapter adapter = new CompositeComponentAdapter(this, creator); |
|
|
|
|
adapter.initialize(); |
|
|
|
|
creator.addNotify(); |
|
|
|
|
creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 拖拽表单上的组件 |
|
|
|
|
* |
|
|
|
@ -1274,25 +1270,29 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
* @param currentDragEvent |
|
|
|
|
*/ |
|
|
|
|
public void startDraggingFormWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) { |
|
|
|
|
if (currentDragEvent == null || this.getDropTarget() != null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
draggingModel = new DraggingModel() |
|
|
|
|
.designer(this) |
|
|
|
|
.creator(xCreator) |
|
|
|
|
.startDragEvent(startDragEvent) |
|
|
|
|
.currentDragEvent(currentDragEvent); |
|
|
|
|
xCreator.backupCurrentSize(); |
|
|
|
|
xCreator.backupParent(); |
|
|
|
|
.currentDragEvent(currentDragEvent) |
|
|
|
|
.dragNewWidget(false); |
|
|
|
|
XLayoutContainer container = this.getDraggingHotspotLayout(); |
|
|
|
|
LayoutAdapter adapter = container.getLayoutAdapter(); |
|
|
|
|
adapter.dragging(this.getDraggingModel()); |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 绑定transferHandler,主要实现拖拽结束的回调,在拖拽已有组件的时候有用,需要在回调里面手动把拖拽失败的组件复原,否则组件会消失 |
|
|
|
|
* 绑定transferHandler,貌似这边用的还是低级的DND方式绑定的鼠标手势,高级的可参考ToolBarButton那边,"rootComponent"常量是 |
|
|
|
|
* 从原来的DesignerTransferHandler里面直接搬来的,目前意义还不明确 |
|
|
|
|
* |
|
|
|
|
* @param e |
|
|
|
|
*/ |
|
|
|
|
public void bindTransferHandler(MouseEvent e) { |
|
|
|
|
TransferHandler handler = new DesignerTransferHandler(this, addingModel); |
|
|
|
|
TransferHandler handler = new TransferHandler("rootComponent"); |
|
|
|
|
this.setTransferHandler(handler); |
|
|
|
|
handler.exportAsDrag(this, e, TransferHandler.COPY); |
|
|
|
|
} |
|
|
|
@ -1987,7 +1987,27 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
return spacingLineDrawer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void addWidgetToForm(XCreator creator, int x, int y) { |
|
|
|
|
private void instantiateCreator(XCreator creator) { |
|
|
|
|
ModelUtil.renameWidgetName(this.getTarget(), creator); |
|
|
|
|
creator.addNotify(); |
|
|
|
|
|
|
|
|
|
ComponentAdapter adapter = new CompositeComponentAdapter(this, creator); |
|
|
|
|
adapter.initialize(); |
|
|
|
|
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) { |
|
|
|
|
creator.backupCurrentSize(); |
|
|
|
|
creator.backupParent(); |
|
|
|
|
addWidgetToForm(creator, x, y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void addWidgetToForm(XCreator creator, int x, int y) { |
|
|
|
|
if(creator == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -2000,14 +2020,16 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
boolean success = false; |
|
|
|
|
if (container != null) { |
|
|
|
|
// 如果是容器,则调用其acceptComponent接受组件
|
|
|
|
|
AddingModel model = this.getAddingModel(); |
|
|
|
|
|
|
|
|
|
boolean chartEnter2Para = !addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class); |
|
|
|
|
boolean formSubmit2Adapt = !addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class); |
|
|
|
|
|
|
|
|
|
if (model != null && !chartEnter2Para && !formSubmit2Adapt) { |
|
|
|
|
if (!chartEnter2Para && !formSubmit2Adapt) { |
|
|
|
|
getAddingWidgetListeners().beforeAdded(); |
|
|
|
|
success = model.add2Container(this, container, x, y); |
|
|
|
|
success = container.addWidgetToContainer( |
|
|
|
|
creator, |
|
|
|
|
x + this.getHorizontalScaleValue(), |
|
|
|
|
y + this.getVerticalScaleValue() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
getAddingWidgetListeners().afterAdded(success); |
|
|
|
|
defaultAfterWidgetAdded(success, container); |
|
|
|
@ -2034,6 +2056,8 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void defaultAfterWidgetAdded(boolean addResult, XLayoutContainer container) { |
|
|
|
|
if (addResult) { |
|
|
|
|
// 如果添加成功,则触发相应事件
|
|
|
|
|