|
|
|
@ -1,12 +1,17 @@
|
|
|
|
|
package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
import com.fr.base.Parameter; |
|
|
|
|
import com.fr.base.chart.BaseChartCollection; |
|
|
|
|
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.DesignState; |
|
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
|
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.beans.AdapterBus; |
|
|
|
|
import com.fr.design.designer.beans.LayoutAdapter; |
|
|
|
@ -22,6 +27,7 @@ import com.fr.design.designer.beans.actions.PasteAction;
|
|
|
|
|
import com.fr.design.designer.beans.adapters.layout.DefaultDesignerBaseOperate; |
|
|
|
|
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.DesignerEditListener; |
|
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
@ -39,6 +45,7 @@ import com.fr.design.designer.creator.XLayoutContainer;
|
|
|
|
|
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
|
|
|
|
import com.fr.design.designer.creator.XWAbsoluteLayout; |
|
|
|
|
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.cardlayout.XWCardMainBorderLayout; |
|
|
|
|
import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; |
|
|
|
@ -47,19 +54,27 @@ import com.fr.design.event.DesignerOpenedListener;
|
|
|
|
|
import com.fr.design.file.HistoryTemplateListPane; |
|
|
|
|
import com.fr.design.form.util.XCreatorConstants; |
|
|
|
|
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.menu.MenuDef; |
|
|
|
|
import com.fr.design.menu.ShortCut; |
|
|
|
|
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.ParameterPropertyPane; |
|
|
|
|
import com.fr.design.roleAuthority.RolesAlreadyEditedPane; |
|
|
|
|
import com.fr.design.utils.ComponentUtils; |
|
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
|
import com.fr.form.FormElementCaseContainerProvider; |
|
|
|
|
import com.fr.form.FormElementCaseProvider; |
|
|
|
|
import com.fr.form.main.Form; |
|
|
|
|
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.PaddingMargin; |
|
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
@ -93,6 +108,7 @@ import java.awt.Graphics2D;
|
|
|
|
|
import java.awt.Insets; |
|
|
|
|
import java.awt.Point; |
|
|
|
|
import java.awt.Rectangle; |
|
|
|
|
import java.awt.Toolkit; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.awt.geom.AffineTransform; |
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
@ -101,7 +117,10 @@ import java.lang.reflect.Method;
|
|
|
|
|
import java.lang.reflect.Proxy; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -173,6 +192,8 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
private static final int H_GAP = 105; |
|
|
|
|
private static final int SUBMIT_BUTTON_H_LOCATION = 270; |
|
|
|
|
|
|
|
|
|
private AddingWidgetListenerTable addingWidgetListeners; |
|
|
|
|
|
|
|
|
|
public FormDesigner(Form form) { |
|
|
|
|
this(form, null); |
|
|
|
|
} |
|
|
|
@ -187,6 +208,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
this.setBackground(Color.WHITE); |
|
|
|
|
// 初始化
|
|
|
|
|
edit = new CreatorEventListenerTable(); |
|
|
|
|
addingWidgetListeners = new AddingWidgetListenerTable(); |
|
|
|
|
selectionModel = new SelectionModel(this); |
|
|
|
|
stateModel = new StateModel(this); |
|
|
|
|
desigerMode = createFormDesignerTargetMode(); |
|
|
|
@ -606,6 +628,10 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
return edit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AddingWidgetListenerTable getAddingWidgetListeners() { |
|
|
|
|
return addingWidgetListeners; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 增加监听事件 |
|
|
|
|
* |
|
|
|
@ -1222,13 +1248,15 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
* @param currentDragEvent |
|
|
|
|
*/ |
|
|
|
|
public void startDraggingNewWidget(XCreator xCreator, MouseEvent startDragEvent, MouseEvent currentDragEvent) { |
|
|
|
|
if (startDragEvent != null && currentDragEvent != null) { |
|
|
|
|
draggingModel = new DraggingModel() |
|
|
|
|
.designer(this) |
|
|
|
|
.creator(xCreator) |
|
|
|
|
.startDragEvent(startDragEvent) |
|
|
|
|
.currentDragEvent(currentDragEvent); |
|
|
|
|
if (startDragEvent == null || currentDragEvent == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
draggingModel = new DraggingModel() |
|
|
|
|
.designer(this) |
|
|
|
|
.creator(xCreator) |
|
|
|
|
.startDragEvent(startDragEvent) |
|
|
|
|
.currentDragEvent(currentDragEvent); |
|
|
|
|
addingModel = new AddingModel(this, xCreator); |
|
|
|
|
this.setDropTarget(new FormCreatorDropTarget(this)); |
|
|
|
|
repaint(); |
|
|
|
@ -1952,4 +1980,109 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
|
|
|
|
|
public FormSpacingLineDrawer getSpacingLineDrawer() { |
|
|
|
|
return spacingLineDrawer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void addWidgetToForm(int x, int y) { |
|
|
|
|
if(addingModel == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 当前鼠标所在的组件
|
|
|
|
|
XCreator hoveredComponent = this.getComponentAt(x, y); |
|
|
|
|
// 获取该组件所在的焦点容器
|
|
|
|
|
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); |
|
|
|
|
boolean success = false; |
|
|
|
|
if (container != null) { |
|
|
|
|
//XWCardTagLayout 切换添加状态到普通状态
|
|
|
|
|
container.stopAddingState(this); |
|
|
|
|
|
|
|
|
|
// 如果是容器,则调用其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) { |
|
|
|
|
getAddingWidgetListeners().beforeAdded(); |
|
|
|
|
success = model.add2Container(this, container, x, y); |
|
|
|
|
} |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|