Destiny.Lin
2 years ago
6 changed files with 111 additions and 8 deletions
@ -0,0 +1,77 @@ |
|||||||
|
package com.fr.design.actions.replace.utils; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.JTemplate; |
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.form.main.WidgetGatherAdapter; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import com.fr.main.impl.WorkBookHelper; |
||||||
|
import com.fr.stable.Filter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
import com.fr.stable.js.WidgetName; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 用于合法性检验相关的工具类 |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-10-31 |
||||||
|
*/ |
||||||
|
public class CheckUtils { |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取需要检测的控件名称 |
||||||
|
* |
||||||
|
* @param jTemplate 模板 |
||||||
|
* @return 控件名称列表 |
||||||
|
*/ |
||||||
|
public static List<WidgetName> getNeed2CheckWidgetsName(JTemplate<?, ?> jTemplate) { |
||||||
|
if (jTemplate.getTarget() instanceof WorkBook) { |
||||||
|
return getWorkBookNeedWidgetsName((WorkBook) jTemplate.getTarget()); |
||||||
|
} else if (jTemplate.getTarget() instanceof Form) { |
||||||
|
return getFormNeedWidgetsName((Form) jTemplate.getTarget()); |
||||||
|
} |
||||||
|
return new ArrayList<>(); |
||||||
|
} |
||||||
|
|
||||||
|
private static List<WidgetName> getFormNeedWidgetsName(Form target) { |
||||||
|
final List<WidgetName> list = new ArrayList<WidgetName>(); |
||||||
|
Form.traversalFormWidget(target.getContainer(), new WidgetGatherAdapter() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void dealWith(Widget widget) { |
||||||
|
if (widgetAccepted(widget)) { |
||||||
|
list.add(new WidgetName(widget.getWidgetName())); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean dealWithAllCards() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
}); |
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
private static List<WidgetName> getWorkBookNeedWidgetsName(WorkBook wb) { |
||||||
|
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) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private static boolean widgetAccepted(Widget widget) { |
||||||
|
return widget != null && StringUtils.isNotEmpty(widget.getWidgetName()); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue