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