From b948170d28f709448ac7703e806b3c89bbfc37d6 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 26 Sep 2019 10:01:41 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-18676=20=E3=80=90=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=A0=A1=E9=AA=8C=E3=80=91cpt=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=95=8C=E9=9D=A2=E7=9A=84=E6=8E=A7=E4=BB=B6=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E4=BA=8B=E4=BB=B6=E8=AF=BB=E5=8F=96=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/WorkBookModelAdapter.java | 51 +++++-------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java b/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java index 7b292c3a1..fff25486d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java @@ -2,20 +2,17 @@ package com.fr.design.mainframe; import com.fr.base.Parameter; import com.fr.base.TableData; -import com.fr.base.parameter.ParameterUI; import com.fr.data.TableDataSource; import com.fr.design.DesignModelAdapter; import com.fr.design.bridge.DesignToolbarProvider; import com.fr.form.ui.Widget; import com.fr.main.impl.WorkBook; +import com.fr.main.impl.WorkBookHelper; import com.fr.main.parameter.ReportParameterAttr; -import com.fr.report.cell.CellElement; -import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.FloatElement; -import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.TemplateElementCase; -import com.fr.report.report.Report; import com.fr.script.Calculator; +import com.fr.stable.Filter; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import com.fr.stable.bridge.StableFactory; @@ -31,6 +28,7 @@ import java.util.List; */ public class WorkBookModelAdapter extends DesignModelAdapter { + public WorkBookModelAdapter(JWorkBook jworkbook) { super(jworkbook); } @@ -116,42 +114,21 @@ public class WorkBookModelAdapter extends DesignModelAdapter getWidgetsName() { - List list = new ArrayList(); WorkBook wb = this.getBook(); - ReportParameterAttr parameterAttr = wb.getReportParameterAttr(); - if (parameterAttr != null) { - ParameterUI parameterUI = parameterAttr.getParameterUI(); - if (parameterUI != null) { - Widget[] paraWidgets = parameterUI.getAllWidgets(); - for (int i = 0; i < paraWidgets.length; i++) { - Widget wi = paraWidgets[i]; - if (widgetAccepted(wi)) { - list.add(new WidgetName(wi.getWidgetName())); - } - } + return WorkBookHelper.listWidgetNamesInWorkBook(wb, new Filter() { + @Override + public boolean accept(Widget widget) { + return widgetAccepted(widget); } - } - - for (int i = 0, len = wb.getReportCount(); i < len; i++) { - Report report = wb.getReport(i); - Iterator it = report.iteratorOfElementCase(); - while (it.hasNext()) { - ElementCase ec = (ElementCase) it.next(); - Iterator cs = ec.cellIterator(); - while (cs.hasNext()) { - CellElement ce = (CellElement) cs.next(); - if (ce instanceof DefaultTemplateCellElement) { - Widget widget = ((DefaultTemplateCellElement) ce).getWidget(); - //todo 这边有没有必要统一改成widgetAccepted?暂时不改,插件那边可能会有影响,因为插件有的控件并没有实现DataControl的 - if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) { - list.add(new WidgetName(widget.getWidgetName())); - } - } - } + }, new Filter() { + @Override + public boolean accept(Widget widget) { + //todo 这边有没有必要统一改成widgetAccepted?暂时不改,插件那边可能会有影响,因为插件有的控件并没有实现DataControl的 + return widget != null && StringUtils.isNotEmpty(widget.getWidgetName()); } - } - return list; + }); } /**