From f1b68a1798bdff583d3f387fc18e0667b591d6b2 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 20 Oct 2016 10:04:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/BasicTableDataTreePane.java | 8 +++++++- .../data/datapane/TableDataTreePane.java | 19 ++++++++++++++----- .../mainframe/FormCreatorDropTarget.java | 9 ++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/designer_base/src/com/fr/design/data/BasicTableDataTreePane.java b/designer_base/src/com/fr/design/data/BasicTableDataTreePane.java index a6fd601a82..45cd0cea70 100644 --- a/designer_base/src/com/fr/design/data/BasicTableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/BasicTableDataTreePane.java @@ -424,7 +424,13 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp this.setSmallIcon(BaseUtils.readIcon(IconPathConstants.TD_CONNECTION_ICON_PATH)); } } - public void addTableData(TableDataSource tableDataSource){ + + /** + * 合并数据集 + * @param srcName 数据集来源(比如报表块,就是报表块的名称) + * @param tableDataSource 数据集 + */ + public void addTableData(String srcName, TableDataSource tableDataSource) { } } 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 911b0d9c94..618c2edec2 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataTreePane.java @@ -270,18 +270,27 @@ public class TableDataTreePane extends BasicTableDataTreePane { return dataTree; } - public void addTableData(TableDataSource tableDataSource) { + /** + * 合并数据集 + * @param srcName 数据集来源(比如报表块,就是报表块的名称) + * @param tableDataSource 数据集 + */ + public void addTableData(String srcName, TableDataSource tableDataSource) { DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); TableDataSource tds = tc.getBook(); Iterator tdIterator = tableDataSource.getTableDataNameIterator(); while (tdIterator.hasNext()) { String tdName = (String) tdIterator.next(); TableData td = tableDataSource.getTableData(tdName); - if (tds.getTableData(tdName) != null) { - tds.putTableData(tdName + "-fr-el", td); - } else { - tds.putTableData(tdName, td); + if (tds.getTableData(tdName) != null) {//如果有同名的就拼上来源名称 + tdName = srcName + tdName; + } + int i = 0; + while (tds.getTableData(tdName) != null) { + i++;//如果拼上名字后依然已经存在就加编号 + tdName += i; } + tds.putTableData(tdName, td); } tc.fireTargetModified(); tc.parameterChanged(); diff --git a/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java index 91c39f988f..7e7035bb73 100644 --- a/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -14,6 +14,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; import com.fr.design.utils.ComponentUtils; import com.fr.form.share.ShareLoader; +import com.fr.form.ui.ElCaseBindInfo; import com.fr.form.ui.SharableElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.general.Inter; @@ -83,9 +84,11 @@ public class FormCreatorDropTarget extends DropTarget { //tab布局添加的时候是初始化了XWCardLayout,实际上最顶层的布局是XWCardMainBorderLayout XCreator addingXCreator = addingModel.getXCreator(); if (addingXCreator.isShared()) { - SharableElementCaseEditor sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(addingXCreator.getShareId()); - if (sharableEditor != null) { - TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(sharableEditor.getTableDataSource()); + String shareId = addingXCreator.getShareId(); + 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()); } } Widget widget = (addingXCreator.getTopLayout() != null) ? (addingXCreator.getTopLayout().toData()) : addingXCreator.toData();