|
|
@ -1,14 +1,21 @@ |
|
|
|
package com.fr.design.mainframe; |
|
|
|
package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.Parameter; |
|
|
|
import com.fr.base.Parameter; |
|
|
|
|
|
|
|
import com.fr.base.chart.BaseChartCollection; |
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
import com.fr.base.vcs.DesignerMode; |
|
|
|
|
|
|
|
import com.fr.chart.chartattr.ChartCollection; |
|
|
|
|
|
|
|
import com.fr.chartx.attr.ChartProvider; |
|
|
|
import com.fr.design.DesignModelAdapter; |
|
|
|
import com.fr.design.DesignModelAdapter; |
|
|
|
import com.fr.design.DesignState; |
|
|
|
import com.fr.design.DesignState; |
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.base.mode.DesignModeContext; |
|
|
|
import com.fr.design.base.mode.DesignModeContext; |
|
|
|
|
|
|
|
import com.fr.design.data.DesignTableDataManager; |
|
|
|
|
|
|
|
import com.fr.design.data.datapane.TableDataTreePane; |
|
|
|
import com.fr.design.designer.TargetComponent; |
|
|
|
import com.fr.design.designer.TargetComponent; |
|
|
|
import com.fr.design.designer.beans.AdapterBus; |
|
|
|
import com.fr.design.designer.beans.AdapterBus; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.ComponentAdapter; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.LayoutAdapter; |
|
|
|
import com.fr.design.designer.beans.Painter; |
|
|
|
import com.fr.design.designer.beans.Painter; |
|
|
|
import com.fr.design.designer.beans.actions.CopyAction; |
|
|
|
import com.fr.design.designer.beans.actions.CopyAction; |
|
|
|
import com.fr.design.designer.beans.actions.CutAction; |
|
|
|
import com.fr.design.designer.beans.actions.CutAction; |
|
|
@ -18,9 +25,11 @@ import com.fr.design.designer.beans.actions.MoveToBottomAction; |
|
|
|
import com.fr.design.designer.beans.actions.MoveToTopAction; |
|
|
|
import com.fr.design.designer.beans.actions.MoveToTopAction; |
|
|
|
import com.fr.design.designer.beans.actions.MoveUpAction; |
|
|
|
import com.fr.design.designer.beans.actions.MoveUpAction; |
|
|
|
import com.fr.design.designer.beans.actions.PasteAction; |
|
|
|
import com.fr.design.designer.beans.actions.PasteAction; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.adapters.component.CompositeComponentAdapter; |
|
|
|
import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate; |
|
|
|
import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate; |
|
|
|
import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate; |
|
|
|
import com.fr.design.designer.beans.adapters.layout.DesignerBaseOperate; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.adapters.layout.FRParameterLayoutAdapter; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.events.AddingWidgetListenerTable; |
|
|
|
import com.fr.design.designer.beans.events.CreatorEventListenerTable; |
|
|
|
import com.fr.design.designer.beans.events.CreatorEventListenerTable; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEditListener; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEditListener; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
@ -28,6 +37,8 @@ import com.fr.design.designer.beans.location.Direction; |
|
|
|
import com.fr.design.designer.beans.location.Location; |
|
|
|
import com.fr.design.designer.beans.location.Location; |
|
|
|
import com.fr.design.designer.beans.location.RootResizeDirection; |
|
|
|
import com.fr.design.designer.beans.location.RootResizeDirection; |
|
|
|
import com.fr.design.designer.beans.models.AddingModel; |
|
|
|
import com.fr.design.designer.beans.models.AddingModel; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.models.DraggingModel; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.models.ModelUtil; |
|
|
|
import com.fr.design.designer.beans.models.SelectionModel; |
|
|
|
import com.fr.design.designer.beans.models.SelectionModel; |
|
|
|
import com.fr.design.designer.beans.models.StateModel; |
|
|
|
import com.fr.design.designer.beans.models.StateModel; |
|
|
|
import com.fr.design.designer.creator.XChartEditor; |
|
|
|
import com.fr.design.designer.creator.XChartEditor; |
|
|
@ -37,6 +48,7 @@ import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
|
|
|
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
|
|
|
import com.fr.design.designer.creator.XWAbsoluteLayout; |
|
|
|
import com.fr.design.designer.creator.XWAbsoluteLayout; |
|
|
|
import com.fr.design.designer.creator.XWBorderLayout; |
|
|
|
import com.fr.design.designer.creator.XWBorderLayout; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XWFitLayout; |
|
|
|
import com.fr.design.designer.creator.XWParameterLayout; |
|
|
|
import com.fr.design.designer.creator.XWParameterLayout; |
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; |
|
|
|
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; |
|
|
|
import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; |
|
|
|
import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; |
|
|
@ -45,19 +57,27 @@ import com.fr.design.event.DesignerOpenedListener; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
import com.fr.design.form.util.XCreatorConstants; |
|
|
|
import com.fr.design.form.util.XCreatorConstants; |
|
|
|
import com.fr.design.fun.RightSelectionHandlerProvider; |
|
|
|
import com.fr.design.fun.RightSelectionHandlerProvider; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.chart.info.ChartInfoCollector; |
|
|
|
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; |
|
|
|
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; |
|
|
|
import com.fr.design.menu.MenuDef; |
|
|
|
import com.fr.design.menu.MenuDef; |
|
|
|
import com.fr.design.menu.ShortCut; |
|
|
|
import com.fr.design.menu.ShortCut; |
|
|
|
import com.fr.design.menu.ToolBarDef; |
|
|
|
import com.fr.design.menu.ToolBarDef; |
|
|
|
|
|
|
|
import com.fr.design.mod.bean.ChangeItem; |
|
|
|
|
|
|
|
import com.fr.design.mod.bean.ContentChangeItem; |
|
|
|
|
|
|
|
import com.fr.design.mod.event.TableDataModifyEvent; |
|
|
|
import com.fr.design.parameter.ParaDefinitePane; |
|
|
|
import com.fr.design.parameter.ParaDefinitePane; |
|
|
|
import com.fr.design.parameter.ParameterPropertyPane; |
|
|
|
import com.fr.design.parameter.ParameterPropertyPane; |
|
|
|
import com.fr.design.roleAuthority.RolesAlreadyEditedPane; |
|
|
|
import com.fr.design.roleAuthority.RolesAlreadyEditedPane; |
|
|
|
import com.fr.design.utils.ComponentUtils; |
|
|
|
import com.fr.design.utils.ComponentUtils; |
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
|
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
import com.fr.form.FormElementCaseContainerProvider; |
|
|
|
import com.fr.form.FormElementCaseContainerProvider; |
|
|
|
import com.fr.form.FormElementCaseProvider; |
|
|
|
import com.fr.form.FormElementCaseProvider; |
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.parameter.FormSubmitButton; |
|
|
|
import com.fr.form.parameter.FormSubmitButton; |
|
|
|
|
|
|
|
import com.fr.form.share.SharableWidgetProvider; |
|
|
|
|
|
|
|
import com.fr.form.share.ShareLoader; |
|
|
|
|
|
|
|
import com.fr.form.share.editor.SharableEditorProvider; |
|
|
|
import com.fr.form.ui.EditorHolder; |
|
|
|
import com.fr.form.ui.EditorHolder; |
|
|
|
import com.fr.form.ui.PaddingMargin; |
|
|
|
import com.fr.form.ui.PaddingMargin; |
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
import com.fr.form.ui.Widget; |
|
|
@ -91,6 +111,7 @@ import java.awt.Graphics2D; |
|
|
|
import java.awt.Insets; |
|
|
|
import java.awt.Insets; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.Rectangle; |
|
|
|
import java.awt.Rectangle; |
|
|
|
|
|
|
|
import java.awt.Toolkit; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.geom.AffineTransform; |
|
|
|
import java.awt.geom.AffineTransform; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
@ -99,7 +120,10 @@ import java.lang.reflect.Method; |
|
|
|
import java.lang.reflect.Proxy; |
|
|
|
import java.lang.reflect.Proxy; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -144,6 +168,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
private transient StateModel stateModel; |
|
|
|
private transient StateModel stateModel; |
|
|
|
// 添加状态下的model,存储添加状态下的临时状态,比如要添加的组件、当前鼠标位置等等
|
|
|
|
// 添加状态下的model,存储添加状态下的临时状态,比如要添加的组件、当前鼠标位置等等
|
|
|
|
private transient AddingModel addingModel; |
|
|
|
private transient AddingModel addingModel; |
|
|
|
|
|
|
|
private transient DraggingModel draggingModel; |
|
|
|
// 当前负责额外渲染的painter,主要目的用来渲染添加组件的位置提示,它通常由外部类设置,在
|
|
|
|
// 当前负责额外渲染的painter,主要目的用来渲染添加组件的位置提示,它通常由外部类设置,在
|
|
|
|
// 设计器渲染时被调用渲染这些位置提示。
|
|
|
|
// 设计器渲染时被调用渲染这些位置提示。
|
|
|
|
private transient Painter painter; |
|
|
|
private transient Painter painter; |
|
|
@ -170,6 +195,8 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
private static final int H_GAP = 105; |
|
|
|
private static final int H_GAP = 105; |
|
|
|
private static final int SUBMIT_BUTTON_H_LOCATION = 270; |
|
|
|
private static final int SUBMIT_BUTTON_H_LOCATION = 270; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private AddingWidgetListenerTable addingWidgetListeners; |
|
|
|
|
|
|
|
|
|
|
|
public FormDesigner(Form form) { |
|
|
|
public FormDesigner(Form form) { |
|
|
|
this(form, null); |
|
|
|
this(form, null); |
|
|
|
} |
|
|
|
} |
|
|
@ -184,6 +211,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
this.setBackground(Color.WHITE); |
|
|
|
this.setBackground(Color.WHITE); |
|
|
|
// 初始化
|
|
|
|
// 初始化
|
|
|
|
edit = new CreatorEventListenerTable(); |
|
|
|
edit = new CreatorEventListenerTable(); |
|
|
|
|
|
|
|
addingWidgetListeners = new AddingWidgetListenerTable(); |
|
|
|
selectionModel = new SelectionModel(this); |
|
|
|
selectionModel = new SelectionModel(this); |
|
|
|
stateModel = new StateModel(this); |
|
|
|
stateModel = new StateModel(this); |
|
|
|
desigerMode = createFormDesignerTargetMode(); |
|
|
|
desigerMode = createFormDesignerTargetMode(); |
|
|
@ -201,6 +229,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
populateParameterPropertyPane(); |
|
|
|
populateParameterPropertyPane(); |
|
|
|
|
|
|
|
|
|
|
|
spacingLineDrawer = new FormSpacingLineDrawer(this); |
|
|
|
spacingLineDrawer = new FormSpacingLineDrawer(this); |
|
|
|
|
|
|
|
clearDropTarget(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -603,6 +632,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
return edit; |
|
|
|
return edit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AddingWidgetListenerTable getAddingWidgetListeners() { |
|
|
|
|
|
|
|
return addingWidgetListeners; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 增加监听事件 |
|
|
|
* 增加监听事件 |
|
|
|
* |
|
|
|
* |
|
|
@ -783,6 +816,35 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 停止拖拽 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void stopDragging() { |
|
|
|
|
|
|
|
draggingModel = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void clearDropTarget() { |
|
|
|
|
|
|
|
this.setDropTarget(null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 更新拖拽model的位置 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void updateDraggingPosition(int x, int y) { |
|
|
|
|
|
|
|
if (draggingModel != null) { |
|
|
|
|
|
|
|
draggingModel.moveTo(x, y); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 重置拖拽model的位置 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void resetDraggingPosition() { |
|
|
|
|
|
|
|
if (draggingModel != null) { |
|
|
|
|
|
|
|
draggingModel.reset(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置其UI类为DesignerUI,负责渲染 |
|
|
|
* 设置其UI类为DesignerUI,负责渲染 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -1109,8 +1171,8 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
return addingModel; |
|
|
|
return addingModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setAddingModel(AddingModel addingModel) { |
|
|
|
public DraggingModel getDraggingModel() { |
|
|
|
this.addingModel = addingModel; |
|
|
|
return draggingModel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public XCreator getComponentAt(MouseEvent e) { |
|
|
|
public XCreator getComponentAt(MouseEvent e) { |
|
|
@ -1179,50 +1241,84 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 拖拽准备 |
|
|
|
* 拖入新的组件 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param xCreator 组件 |
|
|
|
* @param xCreator |
|
|
|
|
|
|
|
* @param startDragEvent |
|
|
|
|
|
|
|
* @param currentDragEvent |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void startDraggingBean(XCreator xCreator) { |
|
|
|
public void startDraggingNewWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) { |
|
|
|
// 根据所选择的组件的BeanInfo生成相应的AddingModel
|
|
|
|
if (currentDragEvent == null || this.getDropTarget() != null) { |
|
|
|
// AddingModel和StateModel不一样,适合当前选择的组件相关的
|
|
|
|
return; |
|
|
|
addingModel = new AddingModel(this, xCreator); |
|
|
|
} |
|
|
|
this.setDropTarget(new FormCreatorDropTarget(this)); |
|
|
|
|
|
|
|
// 触发状态添加模式事件
|
|
|
|
draggingModel = new DraggingModel() |
|
|
|
|
|
|
|
.designer(this) |
|
|
|
|
|
|
|
.creator(xCreator) |
|
|
|
|
|
|
|
.startDragEvent(startDragEvent) |
|
|
|
|
|
|
|
.currentDragEvent(currentDragEvent) |
|
|
|
|
|
|
|
.dragNewWidget(true); |
|
|
|
|
|
|
|
this.setDropTarget(new FormCreatorDropTarget(this, xCreator)); |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 拖拽时相关处理 |
|
|
|
* 拖拽表单上的组件 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param xCreator 组件 |
|
|
|
* @param xCreator |
|
|
|
* @param lastPressEvent 鼠标事件 |
|
|
|
* @param startDragEvent |
|
|
|
* @param x 坐标x |
|
|
|
* @param currentDragEvent |
|
|
|
* @param y 坐标y |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void startDraggingFormWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) { |
|
|
|
public void startDraggingComponent(XCreator xCreator, MouseEvent lastPressEvent, int x, int y) { |
|
|
|
if (currentDragEvent == null || this.getDropTarget() != null) { |
|
|
|
// 根据所选择的组件的BeanInfo生成相应的AddingModel
|
|
|
|
return; |
|
|
|
// AddingModel和StateModel不一样,适合当前选择的组件相关的
|
|
|
|
} |
|
|
|
this.addingModel = new AddingModel(xCreator, x, y); |
|
|
|
draggingModel = new DraggingModel() |
|
|
|
TransferHandler handler = new DesignerTransferHandler(this, addingModel); |
|
|
|
.designer(this) |
|
|
|
setTransferHandler(handler); |
|
|
|
.creator(xCreator) |
|
|
|
handler.exportAsDrag(this, lastPressEvent, TransferHandler.COPY); |
|
|
|
.startDragEvent(startDragEvent) |
|
|
|
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); |
|
|
|
.currentDragEvent(currentDragEvent) |
|
|
|
parent.getLayoutAdapter().dragStart(xCreator, selectionModel); |
|
|
|
.dragNewWidget(false); |
|
|
|
this.setDropTarget(new FormCreatorDropTarget(this)); |
|
|
|
XLayoutContainer container = this.getDraggingHotspotLayout(); |
|
|
|
// 触发状态添加模式事件
|
|
|
|
LayoutAdapter adapter = container.getLayoutAdapter(); |
|
|
|
|
|
|
|
adapter.dragging(this.getDraggingModel()); |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void draggingComponent(int x, int y){ |
|
|
|
/** |
|
|
|
XCreator xCreator = this.addingModel.getXCreator(); |
|
|
|
* 绑定transferHandler,貌似这边用的还是低级的DND方式绑定的鼠标手势,高级的可参考ToolBarButton那边,"rootComponent"常量是 |
|
|
|
|
|
|
|
* 从原来的DesignerTransferHandler里面直接搬来的,目前意义还不明确 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param e |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void bindTransferHandler(MouseEvent e) { |
|
|
|
|
|
|
|
TransferHandler handler = new TransferHandler("rootComponent"); |
|
|
|
|
|
|
|
this.setTransferHandler(handler); |
|
|
|
|
|
|
|
handler.exportAsDrag(this, e, TransferHandler.COPY); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 触发父组件布局的dragStart事件,目前只在非固定布局下有用,用来删除占位块 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param xCreator |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void fireParentLayoutDragStart(XCreator xCreator) { |
|
|
|
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); |
|
|
|
XLayoutContainer parent = XCreatorUtils.getParentXLayoutContainer(xCreator); |
|
|
|
if (parent!= null && parent.getLayoutAdapter()!=null){ |
|
|
|
if (parent != null) { |
|
|
|
parent.getLayoutAdapter().dragOver(xCreator, selectionModel, x, y); |
|
|
|
parent.getLayoutAdapter().dragStart(xCreator, selectionModel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 触发状态添加模式事件
|
|
|
|
/** |
|
|
|
repaint(); |
|
|
|
* 获取拖拽当前鼠标所在位置的布局 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public XLayoutContainer getDraggingHotspotLayout() { |
|
|
|
|
|
|
|
DraggingModel model = this.draggingModel; |
|
|
|
|
|
|
|
MouseEvent dragEvent = model.getCurrentDragEvent(); |
|
|
|
|
|
|
|
XCreator hotspot = this.getComponentAt(dragEvent.getX(), dragEvent.getY()); |
|
|
|
|
|
|
|
return XCreatorUtils.getHotspotContainer(hotspot); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -1890,4 +1986,131 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection |
|
|
|
public FormSpacingLineDrawer getSpacingLineDrawer() { |
|
|
|
public FormSpacingLineDrawer getSpacingLineDrawer() { |
|
|
|
return spacingLineDrawer; |
|
|
|
return spacingLineDrawer; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addingModel = new AddingModel(creator); |
|
|
|
|
|
|
|
// 当前鼠标所在的组件
|
|
|
|
|
|
|
|
XCreator hoveredComponent = this.getComponentAt(x, y); |
|
|
|
|
|
|
|
// 获取该组件所在的焦点容器
|
|
|
|
|
|
|
|
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); |
|
|
|
|
|
|
|
boolean success = false; |
|
|
|
|
|
|
|
if (container != null) { |
|
|
|
|
|
|
|
// 如果是容器,则调用其acceptComponent接受组件
|
|
|
|
|
|
|
|
boolean chartEnter2Para = !addingModel.getXCreator().canEnterIntoParaPane() && container.acceptType(XWParameterLayout.class); |
|
|
|
|
|
|
|
boolean formSubmit2Adapt = !addingModel.getXCreator().canEnterIntoAdaptPane() && container.acceptType(XWFitLayout.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!chartEnter2Para && !formSubmit2Adapt) { |
|
|
|
|
|
|
|
getAddingWidgetListeners().beforeAdded(); |
|
|
|
|
|
|
|
success = container.addWidgetToContainer( |
|
|
|
|
|
|
|
creator, |
|
|
|
|
|
|
|
x + this.getHorizontalScaleValue(), |
|
|
|
|
|
|
|
y + this.getVerticalScaleValue() |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
getAddingWidgetListeners().afterAdded(success); |
|
|
|
|
|
|
|
defaultAfterWidgetAdded(success, container); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 取消提示
|
|
|
|
|
|
|
|
this.setPainter(null); |
|
|
|
|
|
|
|
// 切换添加状态到普通状态
|
|
|
|
|
|
|
|
this.stopAddingState(); |
|
|
|
|
|
|
|
getAddingWidgetListeners().clearListeners(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void dealChartBuryingPoint(Widget widget) { |
|
|
|
|
|
|
|
List<BaseChartCollection> chartCollections = widget.getChartCollections(); |
|
|
|
|
|
|
|
for (BaseChartCollection baseChartCollection : chartCollections) { |
|
|
|
|
|
|
|
ChartCollection chartCollection = (ChartCollection) baseChartCollection; |
|
|
|
|
|
|
|
for (int i = 0, size = chartCollection.getChartCount(); i < size; i++) { |
|
|
|
|
|
|
|
ChartProvider chart = chartCollection.getChart(i, ChartProvider.class); |
|
|
|
|
|
|
|
//是否是共享的复用组件
|
|
|
|
|
|
|
|
boolean isReuse = StringUtils.isNotEmpty(this.addingModel.getXCreator().getShareId()); |
|
|
|
|
|
|
|
ChartInfoCollector.getInstance().collection(chart, null, isReuse); |
|
|
|
|
|
|
|
ChartInfoCollector.getInstance().checkTestChart(chart); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void defaultAfterWidgetAdded(boolean addResult, XLayoutContainer container) { |
|
|
|
|
|
|
|
if (addResult) { |
|
|
|
|
|
|
|
// 如果添加成功,则触发相应事件
|
|
|
|
|
|
|
|
XCreator xCreator = container.acceptType(XWParameterLayout.class) ? this.getParaComponent() : this.getRootComponent(); |
|
|
|
|
|
|
|
//SetSelection时要确保选中的是最顶层的布局
|
|
|
|
|
|
|
|
//tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout
|
|
|
|
|
|
|
|
XCreator addingXCreator = addingModel.getXCreator(); |
|
|
|
|
|
|
|
Widget widget = (addingXCreator.getBackupParent() != null && addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData(); |
|
|
|
|
|
|
|
//图表埋点
|
|
|
|
|
|
|
|
dealChartBuryingPoint(widget); |
|
|
|
|
|
|
|
if (addingXCreator.isShared()) { |
|
|
|
|
|
|
|
if (container.acceptType(XWAbsoluteLayout.class)) { |
|
|
|
|
|
|
|
// 绝对布局中新添加的共享组件默认锁定尺寸比例
|
|
|
|
|
|
|
|
Rectangle bounds = new Rectangle(addingXCreator.getBounds()); |
|
|
|
|
|
|
|
Widget addingWidget = addingXCreator.toData(); |
|
|
|
|
|
|
|
if (addingWidget != null && bounds.width > 0 && bounds.height > 0) { |
|
|
|
|
|
|
|
addingXCreator.toData().setAspectRatioLocked(true); |
|
|
|
|
|
|
|
addingXCreator.toData().setAspectRatioBackup(1.0 * bounds.width / bounds.height); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String shareId = addingXCreator.getShareId(); |
|
|
|
|
|
|
|
SharableEditorProvider sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); |
|
|
|
|
|
|
|
SharableWidgetProvider bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); |
|
|
|
|
|
|
|
Map<String, String> tdNameMap = Collections.emptyMap(); |
|
|
|
|
|
|
|
if (sharableEditor != null && bindInfo != null) { |
|
|
|
|
|
|
|
tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource(), true); |
|
|
|
|
|
|
|
//合并数据集之后,可能会有数据集名称变化,做一下联动
|
|
|
|
|
|
|
|
//共享的组件拿的时候都是克隆的,这边改拖拽中克隆的对象而非新克隆对象,上面这个新克隆的对象只是为了拿数据集
|
|
|
|
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
|
|
|
|
for (Map.Entry<String, String> entry : tdNameMap.entrySet()) { |
|
|
|
|
|
|
|
this.getTarget().renameTableData(widget, entry.getKey(), entry.getValue()); |
|
|
|
|
|
|
|
map.put(entry.getKey(), entry.getValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!map.isEmpty()) { |
|
|
|
|
|
|
|
DesignTableDataManager.fireDSChanged(map); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
EventDispatcher.fire(TableDataModifyEvent.INSTANCE, new ContentChangeItem(tdNameMap, widget, ChangeItem.TABLE_DATA_NAME)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.getSelectionModel().setSelectedCreators( |
|
|
|
|
|
|
|
FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget})); |
|
|
|
|
|
|
|
if (!addingModel.isAddedIllegal()) { |
|
|
|
|
|
|
|
this.getEditListenerTable().fireCreatorModified(addingModel.getXCreator(), DesignerEvent.CREATOR_ADDED); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Toolkit.getDefaultToolkit().beep(); |
|
|
|
|
|
|
|
// 拖入失败 取消选中
|
|
|
|
|
|
|
|
XCreator creator = addingModel.getXCreator(); |
|
|
|
|
|
|
|
if (creator != null) { |
|
|
|
|
|
|
|
creator.setSelected(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|