Browse Source

REPORT-18676 【重构提交校验】cpt参数界面的控件入库事件读取不到控件

feature/big-screen
zack 5 years ago
parent
commit
33f1a07b51
  1. 14
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  2. 1
      designer-base/src/main/java/com/fr/design/fun/ParameterWidgetOptionProvider.java
  3. 4
      designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java
  4. 16
      designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java

14
designer-base/src/main/java/com/fr/design/DesignModelAdapter.java

@ -7,8 +7,11 @@ import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateProvider; import com.fr.design.mainframe.JTemplateProvider;
import com.fr.form.ui.DataControl;
import com.fr.form.ui.MultiFileEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.js.WidgetName; import com.fr.stable.js.WidgetName;
import java.util.Iterator; import java.util.Iterator;
@ -214,6 +217,17 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
public abstract List<WidgetName> getWidgetsName(); public abstract List<WidgetName> getWidgetsName();
/**
* 判断是否是值编辑器可以设置的控件类型
* @param widget 控件
* @return 可以设置返回true否则返回false
*/
public boolean widgetAccepted(Widget widget) {
return widget != null
&& StringUtils.isNotEmpty(widget.getWidgetName())
&& (widget instanceof DataControl || widget instanceof MultiFileEditor);
}
/** /**
* 更新缓存的参数 * 更新缓存的参数
*/ */

1
designer-base/src/main/java/com/fr/design/fun/ParameterWidgetOptionProvider.java

@ -17,6 +17,7 @@ public interface ParameterWidgetOptionProvider extends Mutable {
/** /**
* 自定义参数控件的实际类该类需要继承自com.fr.form.ui.Widget * 自定义参数控件的实际类该类需要继承自com.fr.form.ui.Widget
* 如果有控件值属性该类需要实现DataControl接口否则可能有部分功能无法使用比如值编辑器选择控件的时候无法找到插件里的控件
* @return 控件类 * @return 控件类
*/ */
Class<? extends Widget> classForWidget(); Class<? extends Widget> classForWidget();

4
designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java

@ -8,9 +8,7 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.WidgetGatherAdapter; import com.fr.form.main.WidgetGatherAdapter;
import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.DataControl;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.MultiFileEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
@ -74,7 +72,7 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm<Form>>
@Override @Override
public void dealWith(Widget widget) { public void dealWith(Widget widget) {
if (widget instanceof DataControl || widget instanceof MultiFileEditor) { if (widgetAccepted(widget)) {
list.add(new WidgetName(widget.getWidgetName())); list.add(new WidgetName(widget.getWidgetName()));
} }
} }

16
designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.parameter.ParameterUI;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.bridge.DesignToolbarProvider; import com.fr.design.bridge.DesignToolbarProvider;
@ -118,6 +119,20 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
public List<WidgetName> getWidgetsName() { public List<WidgetName> getWidgetsName() {
List<WidgetName> list = new ArrayList<WidgetName>(); List<WidgetName> list = new ArrayList<WidgetName>();
WorkBook wb = this.getBook(); 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()));
}
}
}
}
for (int i = 0, len = wb.getReportCount(); i < len; i++) { for (int i = 0, len = wb.getReportCount(); i < len; i++) {
Report report = wb.getReport(i); Report report = wb.getReport(i);
Iterator it = report.iteratorOfElementCase(); Iterator it = report.iteratorOfElementCase();
@ -128,6 +143,7 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
CellElement ce = (CellElement) cs.next(); CellElement ce = (CellElement) cs.next();
if (ce instanceof DefaultTemplateCellElement) { if (ce instanceof DefaultTemplateCellElement) {
Widget widget = ((DefaultTemplateCellElement) ce).getWidget(); Widget widget = ((DefaultTemplateCellElement) ce).getWidget();
//todo 这边有没有必要统一改成widgetAccepted?暂时不改,插件那边可能会有影响,因为插件有的控件并没有实现DataControl的
if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) { if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) {
list.add(new WidgetName(widget.getWidgetName())); list.add(new WidgetName(widget.getWidgetName()));
} }

Loading…
Cancel
Save