From 2f8216cd831e7ae6d83d323bfc75e19fb774a8c9 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 26 Sep 2022 13:45:48 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-75998=20=E8=BF=9B=E5=85=A5=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E8=80=85=E8=B0=83=E8=AF=95&=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=A8=A1=E5=BC=8F=E9=80=BB=E8=BE=91=E5=A4=84?= =?UTF-8?q?=E7=90=86=E3=80=81=E5=AE=8C=E5=96=84=E9=80=9A=E9=85=8D=E7=AC=A6?= =?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E7=95=8C=E9=9D=A2=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=8B=BE=E9=80=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/AllowAuthorityEditAction.java | 8 ++ .../fr/design/module/DesignModuleFactory.java | 13 +++ .../fr/design/preview/DeveloperPreview.java | 8 ++ .../action/ShowSearchResultAction.java | 4 +- .../replace/ui/ITReplaceMainDialog.java | 26 +++++- .../replace/ui/ITReplaceNorthPanel.java | 5 +- .../replace/ui/ITReplaceSouthPanel.java | 7 +- .../actions/replace/ui/ITTableButton.java | 1 - .../actions/replace/ui/ITTableEditorPane.java | 4 +- .../actions/replace/utils/ShowValueUtils.java | 79 +++++++++++++++---- .../fr/start/module/DesignerActivator.java | 2 + 11 files changed, 133 insertions(+), 24 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java b/designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java index 1a0509d267..bb26e17118 100644 --- a/designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java @@ -4,11 +4,14 @@ import com.fr.base.svg.IconUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; +import com.fr.design.module.DesignModuleFactory; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.*; +import com.fr.invoke.Reflect; +import com.fr.log.FineLoggerFactory; /** * Author : daisy @@ -61,6 +64,11 @@ public class AllowAuthorityEditAction extends TemplateComponentAction { DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance()); EastRegionContainerPane.getInstance().removeParameterPane(); + try { + Reflect.on(DesignModuleFactory.getReplacePane().newInstance()).call("close"); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } //画虚线 return true; diff --git a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java index baed29be47..60a4dfcf18 100644 --- a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java +++ b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java @@ -50,6 +50,7 @@ public class DesignModuleFactory { private Class ITReplaceAction; private Class formParaDesigner; private Class paraPropertyPane; + private Class replacePane; private Class formHierarchyPaneCls; private Class widgetPropertyPane; private Class buttonDetailPaneClass; @@ -131,6 +132,18 @@ public class DesignModuleFactory { return instance.ITReplaceAction; } + /** + * 注册一下查找替换面板 + * @param r + */ + public static void registerReplacePane(Class r){ + instance.replacePane = r; + } + + public static Class getReplacePane(){ + return instance.replacePane; + } + public static void registerParaPropertyPaneClass(Class p) { instance.paraPropertyPane = p; } diff --git a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java index 69e514b408..5c0a623857 100644 --- a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java +++ b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java @@ -6,9 +6,12 @@ import com.fr.design.fun.impl.AbstractPreviewProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; +import com.fr.design.module.DesignModuleFactory; import com.fr.design.worker.WorkerManager; import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.general.web.ParameterConstants; +import com.fr.invoke.Reflect; +import com.fr.log.FineLoggerFactory; import java.util.HashMap; import java.util.Map; @@ -47,6 +50,11 @@ public class DeveloperPreview extends AbstractPreviewProvider { @Override public void onClick(JTemplate jt) { super.onClick(jt); + try { + Reflect.on(DesignModuleFactory.getReplacePane().newInstance()).call("close"); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } SwingWorker worker = WorkerManager.getInstance().getWorker(jt.getRuntimeId()); if (worker instanceof CallbackSaveWorker) { CallbackSaveWorker callbackSaveWorker = (CallbackSaveWorker) worker; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java index 601b3d09e5..f555de9689 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java @@ -75,7 +75,7 @@ public enum ShowSearchResultAction implements ShowValue { } else { Map stringHashMap = info.getValue(); String content = stringHashMap.getOrDefault(objectContentKey, StringUtils.EMPTY); - if (content.contains(str) && StringUtils.isNotEmpty(content)) { + if (ShowValueUtils.contains(content,str) && StringUtils.isNotEmpty(content)) { info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); info.getContent().setOldShowStr(content); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); @@ -416,6 +416,6 @@ public enum ShowSearchResultAction implements ShowValue { * @return */ public boolean isTitleNameValid(Title title, String str){ - return title != null && GeneralUtils.objectToString(title.getTextObject()).contains(str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject())); + return title != null && ShowValueUtils.contains(GeneralUtils.objectToString(title.getTextObject()),str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject())); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index f145cae021..2a922902f7 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -52,8 +52,9 @@ public class ITReplaceMainDialog extends UIDialog { private ITReplaceWestPanel westPanel; private boolean searchFlag; private String searchStr; + private static boolean existed = false; - private ITReplaceMainDialog() { + public ITReplaceMainDialog() { super(DesignerContext.getDesignerFrame()); init(); } @@ -66,6 +67,7 @@ public class ITReplaceMainDialog extends UIDialog { initFrame(); fitScreen(); ITReplaceFlag = true; + existed = true; } /** @@ -309,6 +311,28 @@ public class ITReplaceMainDialog extends UIDialog { } } + /** + * 面板是否存在 + * @return + */ + public static boolean isExisted() { + return existed; + } + + public static void setExisted(boolean existed) { + ITReplaceMainDialog.existed = existed; + } + + + /** + * 进入权限编辑状态&开发者调试时关闭面板 + */ + public static void close(){ + if (isExisted()){ + getInstance().dispose(); + setExisted(false); + } + } /** * 检测结果是否合法 */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index bc4e82255f..a4fe1fef0f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -47,6 +47,7 @@ public class ITReplaceNorthPanel { private static final int HEIGHT = 161; private static final int BUTTON_WIDTH = 60; private static final int BUTTON_GAP = 20; + private static final int MATCH_WIDTH = 70; private int findLabelX, findLabelY, findLabelWidth, findLabelHeight; @@ -83,7 +84,7 @@ public class ITReplaceNorthPanel { resultLabel = new UILabel(); String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; - String[] replaceInputItems = new String[]{""}; + String[] replaceInputItems = new String[]{StringUtils.EMPTY}; findCombobox = new UIComboBox(findItems.toArray()); rangeCombobox = new UIComboBox(rangeItems); findInputCombobox = new UIComboBox(findInputItems.toArray()) { @@ -247,7 +248,7 @@ public class ITReplaceNorthPanel { private void setUIRadioButtonBounds(int x, int y, int templateWidth) { matchX = x + templateWidth / 60; matchY = y + 90; - matchWidth = templateWidth; + matchWidth = MATCH_WIDTH; matchHeight = 25; matchRadioButton.setBounds(matchX, matchY, matchWidth, matchHeight); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java index 7db6b52850..8921dce5ff 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -18,7 +18,12 @@ public class ITReplaceSouthPanel { public ITReplaceSouthPanel() { itTableEditor = new ITTableEditor(); tableEditorPane = new ITTableEditorPane<>(itTableEditor); - RowSorter sorter = new TableRowSorter(itTableEditor); + RowSorter sorter = new TableRowSorter(itTableEditor){ + @Override + public boolean isSortable(int column) { + return column != 0 || column != 6; + } + }; tableEditorPane.getEditTable().setRowSorter(sorter); tableEditorPane.getEditTable().setSelectionBackground(new Color(217, 235, 254)); tableEditorPane.getEditTable().setRowHeight(tableEditorPane.getEditTable().getRowHeight() / 2 + tableEditorPane.getEditTable().getRowHeight()); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java index 4c94cc1147..03717a725c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java @@ -43,7 +43,6 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { ITReplaceMainDialog.setITReplaceFlag(true); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(new TRL(GeneralUtils.objectToString(content.getTrlString()))); - ReportComponentComposite composite = (ReportComponentComposite) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentReportComponentPane(); } ITReplaceMainDialog.setITReplaceFlag(false); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java index 928c2da67d..c35f2ef14d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java @@ -71,7 +71,7 @@ public class ITTableEditorPane extends BasicPane { int row = ((JTable) e.getSource()).rowAtPoint(e.getPoint()); int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint()); if (col == 0) { - ITContent content = (ITContent) editTable.getValueAt(row, 7); + ITContent content = (ITContent) editTable.getValueAt(row, 6); if (content.isSelected()) { content.setSelected(false); editTable.setValueAt(content.isSelected(), row, col); @@ -187,7 +187,7 @@ public class ITTableEditorPane extends BasicPane { */ public static void selectAllOrNull(Boolean value) { for (int i = 0; i < getEditTable().getRowCount(); i++) { - ((ITContent) (getEditTable().getValueAt(i, 7))).setSelected(value); + ((ITContent) (getEditTable().getValueAt(i, 6))).setSelected(value); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index b215a16c6d..b7da5fc23c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -1,9 +1,8 @@ package com.fr.design.actions.replace.utils; -import com.fr.design.actions.replace.info.Info; - +import com.fr.design.actions.replace.ui.ITReplaceMainDialog; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; @@ -30,6 +29,20 @@ public class ShowValueUtils { public static final String ANY_THING_REGEX = "."; public static final String NUMBER_REGEX = "[0-9]"; public static final String ENGLISH_REGEX = "[a-zA-Z]"; + private static List specialCharList = new ArrayList<>(); + static { + //正则特殊字符:? * () [] {} ^ $ + //如果是? 并采用通配符 ,会自动转成“.” 所以 ? 不用处理 + //$同理 + specialCharList.add("*"); + specialCharList.add("("); + specialCharList.add(")"); + specialCharList.add("["); + specialCharList.add("]"); + specialCharList.add("{"); + specialCharList.add("}"); + specialCharList.add("^"); + } /** * 获取除内容外其他一次性展示所有的内容(名称、水印...) @@ -42,9 +55,7 @@ public class ShowValueUtils { if (StringUtils.isEmpty(searchStr)) { return str; } else { - return "
" + - replaceAll(str, searchStr, "" + searchStr + "") + - "
"; + return updateHighlight(str, searchStr); } } @@ -57,7 +68,11 @@ public class ShowValueUtils { * @return 替换后的字符串 */ public static String replaceAll(String str, String regex, String replacement) { - return str.replace(regex, replacement); + if (ITReplaceMainDialog.isMatched()) { + return str.replaceAll(changeRegex(regex), replacement); + } else { + return str.replace(regex, replacement); + } } /** @@ -70,6 +85,10 @@ public class ShowValueUtils { regex = regex.replace(NUMBER, NUMBER_REGEX); regex = regex.replace(ENGLISH, ENGLISH_REGEX); regex = regex.replace(ANY_THING, ANY_THING_REGEX); + String change = "\\"; + for (int i = 0 ; i < specialCharList.size() ; i ++){ + regex = regex.replace(specialCharList.get(i),change + specialCharList.get(i)); + } return regex; } @@ -101,18 +120,36 @@ public class ShowValueUtils { return pairs; } + /** - * 更新高亮状态 + * 更新高亮 * - * @param info - * @param replaceStr + * @param str + * @param searchStr + * @return */ - public static void updateHighlight(Info info, String replaceStr) { - String s = info.getInfoShowStr(info); - s = s.replace(info.getContent().getLastSearchStr(), "" + replaceStr + ""); - info.getContent().setShowStr( - "
" + s + "
" - ); + public static String updateHighlight(String str, String searchStr) { + if (ITReplaceMainDialog.isMatched()) { + String result = str; + Pattern pattern = Pattern.compile(changeRegex(searchStr)); + Matcher matcher = pattern.matcher(str); + String head = ""; + String tail = ""; + int size = head.length() + tail.length(); + int index = 0; + StringBuilder builder = new StringBuilder(str); + while (matcher.find()) { + builder.replace(matcher.start() + index, matcher.end() + index, head + matcher.group() + tail); + index += size; + } + return "
" + + builder.toString() + + "
"; + } else { + return "
" + + replaceAll(str, searchStr, "" + searchStr + "") + + "
"; + } } @@ -146,4 +183,16 @@ public class ShowValueUtils { } return failReturn; } + + public static boolean contains(String originStr, String matchStr) { + if (ITReplaceMainDialog.isMatched()) { + String str = changeRegex(matchStr); + Pattern pattern = Pattern.compile(str); + Matcher matcher = pattern.matcher(originStr); + return matcher.find(); + } else { + return originStr.contains(matchStr); + } + + } } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index af32f596c4..1a04c79ac9 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -32,6 +32,7 @@ import com.fr.design.actions.insert.flot.FormulaFloatAction; import com.fr.design.actions.insert.flot.ImageFloatAction; import com.fr.design.actions.insert.flot.TextBoxFloatAction; import com.fr.design.actions.replace.ITReplaceAction; +import com.fr.design.actions.replace.ui.ITReplaceMainDialog; import com.fr.design.bridge.DesignToolbarProvider; import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.env.DesignerWorkspaceLoader; @@ -466,6 +467,7 @@ public class DesignerActivator extends Activator implements Prepare { DesignModuleFactory.registerNewFormActionClass(NewFormAction.class); DesignModuleFactory.registerReplaceActionClass(ITReplaceAction.class); + DesignModuleFactory.registerReplacePane(ITReplaceMainDialog.class); DesignModuleFactory.registerFormParaDesignerClass(FormParaDesigner.class); DesignModuleFactory.registerParaPropertyPaneClass(ParameterPropertyPane.class); DesignModuleFactory.registerFormHierarchyPaneClass(FormHierarchyTreePane.class);