Browse Source

Merge pull request #1146 in DESIGN/design from ~ZACK/design:release/10.0 to release/10.0

* commit 'b948170d28f709448ac7703e806b3c89bbfc37d6':
  REPORT-18676 【重构提交校验】cpt参数界面的控件入库事件读取不到控件
  REPORT-18676 【重构提交校验】cpt参数界面的控件入库事件读取不到控件
feature/big-screen
zack 5 years ago
parent
commit
99a4852789
  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. 35
      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.JTemplate;
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.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.js.WidgetName;
import java.util.Iterator;
@ -214,6 +217,17 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
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
* 如果有控件值属性该类需要实现DataControl接口否则可能有部分功能无法使用比如值编辑器选择控件的时候无法找到插件里的控件
* @return 控件类
*/
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.WidgetGatherAdapter;
import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.DataControl;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.MultiFileEditor;
import com.fr.form.ui.Widget;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
@ -74,7 +72,7 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm<Form>>
@Override
public void dealWith(Widget widget) {
if (widget instanceof DataControl || widget instanceof MultiFileEditor) {
if (widgetAccepted(widget)) {
list.add(new WidgetName(widget.getWidgetName()));
}
}

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

@ -7,14 +7,12 @@ 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;
@ -30,6 +28,7 @@ import java.util.List;
*/
public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook> {
public WorkBookModelAdapter(JWorkBook jworkbook) {
super(jworkbook);
}
@ -115,27 +114,21 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
*
* @return widgetName 控件列表.
*/
@Override
public List<WidgetName> getWidgetsName() {
List<WidgetName> list = new ArrayList<WidgetName>();
WorkBook wb = this.getBook();
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();
if (widget != null && StringUtils.isNotEmpty(widget.getWidgetName())) {
list.add(new WidgetName(widget.getWidgetName()));
}
}
}
return WorkBookHelper.listWidgetNamesInWorkBook(wb, new Filter<Widget>() {
@Override
public boolean accept(Widget widget) {
return widgetAccepted(widget);
}
}, new Filter<Widget>() {
@Override
public boolean accept(Widget widget) {
//todo 这边有没有必要统一改成widgetAccepted?暂时不改,插件那边可能会有影响,因为插件有的控件并没有实现DataControl的
return widget != null && StringUtils.isNotEmpty(widget.getWidgetName());
}
return list;
});
}
/**

Loading…
Cancel
Save