Browse Source

REPORT-80695 模板全局查找替换 修改校验逻辑,只允许组件和参数面板控件参与

feature/x
Destiny.Lin 2 years ago
parent
commit
a138f031ef
  1. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java
  2. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java
  3. 23
      designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java
  4. 1
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java
  5. 14
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java
  6. 77
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/CheckUtils.java

2
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java

@ -130,7 +130,7 @@ public enum FrmWidgetType implements SearchFrmWidget, DealWithInfoValue {
public List<WidgetInfo> dealAbsoluteWidget(ITContent content, Widget widget) {
ArrayList<WidgetInfo> widgetInfos = new ArrayList<>();
ITContent newContent = ITContent.copy(content);
widgetInfos.add(new WidgetInfo(newContent));
widgetInfos.add(new WidgetInfo(newContent, true));
return widgetInfos;
}

2
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java

@ -148,7 +148,7 @@ public class SearchWidgetAction implements SearchAction {
newContent.setReplaceObject(widget);
newContent.setJumpAble(false);
newContent.setShowObject(Toolkit.i18nText("Fine-Design_Parameter_Panel"));
widgetInfos.add(new WidgetInfo(newContent));
widgetInfos.add(new WidgetInfo(newContent, true));
}
}

23
designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java

@ -3,6 +3,7 @@ package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.action.content.widget.FrmWidgetType;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.utils.CheckUtils;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
@ -30,11 +31,17 @@ import java.util.Map;
public class WidgetInfo implements Info, DealWithInfoValue {
private ITContent content;
private boolean waterMarkFlag = true;
private boolean need2Check = false;
public WidgetInfo(ITContent content) {
this.content = content;
}
public WidgetInfo(ITContent content, boolean need2Check) {
this.content = content;
this.need2Check = need2Check;
}
@Override
public ITContent getContent() {
return content;
@ -96,7 +103,9 @@ public class WidgetInfo implements Info, DealWithInfoValue {
*/
public WidgetInfo copy(WidgetInfo widgetInfo) {
ITContent content = ITContent.copy(widgetInfo.getContent());
return new WidgetInfo(content);
WidgetInfo info = new WidgetInfo(content);
info.setNeed2Check(widgetInfo.isNeed2Check());
return info;
}
/**
@ -112,6 +121,14 @@ public class WidgetInfo implements Info, DealWithInfoValue {
this.waterMarkFlag = waterMarkFlag;
}
public boolean isNeed2Check() {
return need2Check;
}
public void setNeed2Check(boolean need2Check) {
this.need2Check = need2Check;
}
/**
* ReplaceObject是否存在
*
@ -138,9 +155,9 @@ public class WidgetInfo implements Info, DealWithInfoValue {
this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Not_Empty"));
return false;
}
if (!this.isWaterMark()) {
if (!this.isWaterMark() && this.isNeed2Check()) {
String replacedName = ((Widget)this.getContent().getReplaceObject()).getWidgetName().replace(searchStr, replaceStr);
for (WidgetName name : jTemplate.getModel().getWidgetsName()) {
for (WidgetName name : CheckUtils.getNeed2CheckWidgetsName(jTemplate)) {
String widgetName = name.getName();
if (StringUtils.equals(replacedName, widgetName)) {
this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Exist_Same_Name"));

1
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java

@ -34,6 +34,7 @@ public class ITCheckDialog extends UIDialog {
public ITCheckDialog() {
super(ITReplaceMainDialog.getInstance());
setModal(true);
setTitle(Toolkit.i18nText("Fine-Design_Replace_Check_Title"));
JPanel centerPanel = new JPanel();
JPanel southPanel = new JPanel();

14
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java

@ -213,7 +213,13 @@ public class ITReplaceMainDialog extends UIDialog {
clearContentCount();
if (isITReplaceValid() && checkTemplateChanged(searchContentResultList)) {
if (StringUtils.equals(getSearchStr(), searchStr)) {
checkLegalValiditySelector(searchStr, replaceStr);
String str = GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem());
//如果是控件或组件才要进行合法性校验
if (StringUtils.equals(str, Toolkit.i18nText("Fine-Design_Replace_Component")) || StringUtils.equals(str, Toolkit.i18nText("Fine-Design_Basic_Widget"))) {
checkLegalValiditySelector(searchStr, replaceStr);
} else {
replace(searchStr, replaceStr);
}
} else {
search4Content();
}
@ -273,9 +279,9 @@ public class ITReplaceMainDialog extends UIDialog {
options,
options[0]
);
updateCheckValidList();
//如果选择了直接替换,则直接执行替换
if (optionSelected == 1) {
updateCheckValidList();
replace(searchStr, replaceStr);
} else {
checkLegalValidity();
@ -286,7 +292,6 @@ public class ITReplaceMainDialog extends UIDialog {
* 检测
*/
public void checkLegalValidity() {
updateCheckValidList();
if (contentReplaceFailedCount == 0) {
ToastMsgDialog dialog = DesignerToastMsgUtil.createPromptDialog(Toolkit.i18nText("Fine-Design_Replace_Check_None"));
dialog.setVisible(true);
@ -308,12 +313,15 @@ public class ITReplaceMainDialog extends UIDialog {
checkValidList.add(info);
serialNumber.add(count);
info.getContent().setWrongful(true);
info.getContent().setReplaced(true);
} else {
contentReplaceCount++;
}
count++;
}
}
southPanel.getTableEditorPane().update();
ITTableEditorPane.getEditTable().repaint();
}

77
designer-realize/src/main/java/com/fr/design/actions/replace/utils/CheckUtils.java

@ -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…
Cancel
Save