diff --git a/designer_base/src/com/fr/design/data/BasicTableDataTreePane.java b/designer_base/src/com/fr/design/data/BasicTableDataTreePane.java index a76d4a1059..92f02d5f4f 100644 --- a/designer_base/src/com/fr/design/data/BasicTableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/BasicTableDataTreePane.java @@ -428,11 +428,11 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp } /** - * 合并数据集 + * 合并数据集并返回自动更改数据集名字的新老名字键值对 * @param srcName 数据集来源(比如报表块,就是报表块的名称) * @param tableDataSource 数据集 */ - public void addTableData(String srcName, TableDataSource tableDataSource) { - + public Map addTableData(String srcName, TableDataSource tableDataSource) { + return new HashMap<>(0); } } diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java index 219093c6d9..959abc98f1 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java @@ -275,13 +275,15 @@ public class TableDataTreePane extends BasicTableDataTreePane { * @param srcName 数据集来源(比如报表块,就是报表块的名称) * @param tableDataSource 数据集 */ - public void addTableData(String srcName, TableDataSource tableDataSource) { + public Map addTableData(String srcName, TableDataSource tableDataSource) { + Map tdNameMap=new HashMap<>(); allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook()); DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); TableDataSource tds = tc.getBook(); Iterator tdIterator = tableDataSource.getTableDataNameIterator(); while (tdIterator.hasNext()) { String tdName = (String) tdIterator.next(); + String oldName = tdName; TableData td = tableDataSource.getTableData(tdName); if (tds.getTableData(tdName) != null || isDsNameRepeaded(tdName)) {//如果有同名的就拼上来源名称 tdName = srcName + tdName; @@ -292,8 +294,12 @@ public class TableDataTreePane extends BasicTableDataTreePane { tdName += i; } tds.putTableData(tdName, td); + if (!ComparatorUtils.equals(oldName, tdName)) { + tdNameMap.put(oldName, tdName); + } } tc.parameterChanged(); dataTree.refresh(); + return tdNameMap; } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java index 7e7035bb73..b4bfe270f1 100644 --- a/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -26,6 +26,7 @@ import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; +import java.util.Map; /** * 添加模式下鼠标事件处理器。 @@ -88,7 +89,9 @@ public class FormCreatorDropTarget extends DropTarget { SharableElementCaseEditor sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); ElCaseBindInfo bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); if (sharableEditor != null && bindInfo != null) { - TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(),sharableEditor.getTableDataSource()); + Map tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource()); + //合并数据集之后,可能会有数据集名称变化,做一下联动 + sharableEditor.batchRenameTdName(tdNameMap); } } Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();