diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java index d3efcae4aa..adb0e48472 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java @@ -7,7 +7,7 @@ import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableSelfCreator; import com.fr.design.gui.controlpane.UnrepeatedNameHelper; -import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.i18n.Toolkit; import com.fr.general.ComparatorUtils; import com.fr.stable.Nameable; import com.fr.stable.StringUtils; @@ -18,79 +18,74 @@ import java.util.Arrays; import java.util.List; public class ParameterArrayPane extends JListControlPane { - /** - * Constructor. - */ - public ParameterArrayPane() { - super(); - this.addModNameActionListener(new ModNameActionListener() { - public void nameModed(int index, String oldName, String newName) { - populateSelectedValue(); - } + /** + * Constructor. + */ + public ParameterArrayPane() { + super(); + this.addModNameActionListener((index, oldName, newName) -> populateSelectedValue()); + this.addEditingListener(new PropertyChangeAdapter() { + public void propertyChange() { + Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters(); + String[] allListNames = nameableList.getAllNames(); + allListNames[editingIndex] = StringUtils.EMPTY; + String tempName = getEditingName(); + if (StringUtils.isEmpty(tempName)) { + nameableList.stopEditing(); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name")); + setIllegalIndex(editingIndex); + return; + } + if (!ComparatorUtils.equals(tempName, selectedName) + && isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) { + nameableList.stopEditing(); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), + Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name")); + setIllegalIndex(editingIndex); + } + } + }); + } - }); - this.addEditingListener(new PropertyChangeAdapter() { - public void propertyChange() { - Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters(); - String[] allListNames = nameableList.getAllNames(); - allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; - String tempName = getEditingName(); - if (StringUtils.isEmpty(tempName)) { - nameableList.stopEditing(); - FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name")); - setIllegalIndex(editingIndex); - return; - } - if (!ComparatorUtils.equals(tempName, selectedName) - && isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) { - nameableList.stopEditing(); - FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name")); - setIllegalIndex(editingIndex); - } - } - }); - } + @Override + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Engine_Schedule_Template_Parameter"); + } - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_Schedule_Template_Parameter"); - } - - /** - * 创建模板参数设置组件 - * - * @return 模板参数设置组件 - */ - public NameableCreator[] createNameableCreators() { - return new NameableCreator[]{ - new NameableSelfCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_Parameter_Name"), Parameter.class, ParameterPane.class) { - public Parameter createNameable(UnrepeatedNameHelper helper) { - // 返回参数设置面板. - return new Parameter(helper.createUnrepeatedName("p")); - } + /** + * 创建模板参数设置组件 + * + * @return 模板参数设置组件 + */ + public NameableCreator[] createNameableCreators() { + return new NameableCreator[]{ + new NameableSelfCreator(Toolkit.i18nText("Fine-Design_Basic_Engine_Parameter_Name"), Parameter.class, ParameterPane.class) { + public Parameter createNameable(UnrepeatedNameHelper helper) { + // 返回参数设置面板. + return new Parameter(helper.createUnrepeatedName("p")); + } - @Override - public String createTooltip() { - return null; - } - } - }; - } + @Override + public String createTooltip() { + return null; + } + } + }; + } - /** - * 更新参数 + /** + * 更新参数 * * @return 更新后的参数 - */ - public Parameter[] updateParameters() { - // Nameable[]居然不能强转成Parameter[],一定要这么写... - Nameable[] res = this.update(); - Parameter[] res_array = new Parameter[res.length]; - java.util.Arrays.asList(res).toArray(res_array); + */ + public Parameter[] updateParameters() { + // Nameable[]居然不能强转成Parameter[],一定要这么写... + Nameable[] res = this.update(); + Parameter[] res_array = new Parameter[res.length]; + Arrays.asList(res).toArray(res_array); - return res_array; - } + return res_array; + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java index da44fa510f..d2befc90c8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java @@ -124,7 +124,10 @@ public class ContentCellRender implements ListCellRenderer { private String getReplacedString(String modelName, String string) { //需要考虑modelName有空格的情况 //比如现在是work boo k 搜索词是workb,应该要替换的部分是work b - //先去掉空格进行匹配 + //先去掉已经匹配替换过的部分,因为考虑到分词的情况,可能会进行多次替换 + final String regex = "\\|\\|"; + modelName = modelName.replaceAll(regex, StringUtils.EMPTY); + //再去掉空格进行匹配 String noBlackName = modelName.replaceAll(StringUtils.BLANK, StringUtils.EMPTY).toLowerCase(); int index = noBlackName.indexOf(string.toLowerCase()); if (index == -1) { @@ -141,4 +144,5 @@ public class ContentCellRender implements ListCellRenderer { } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index d3bd1f6370..0497828c7e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -112,7 +112,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { name = name.replaceAll(StringUtils.BLANK, StringUtils.EMPTY); if (name.contains(searchText)) { FileModel model = new FileModel(node.getName(), node.getEnvPath()); - if (!AlphaFineHelper.getFilterResult().contains(model)) { + if (!AlphaFineHelper.getFilterResult().contains(model) && !filterModelList.contains(model)) { AlphaFineHelper.checkCancel(); filterModelList.add(model); } diff --git a/designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java b/designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java index 9daa70f3a0..d5f3a8206e 100644 --- a/designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java +++ b/designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java @@ -1,7 +1,9 @@ package com.fr.design.mainframe.alphafine.cell.render; +import com.fr.stable.StringUtils; import org.junit.Test; + import static org.junit.Assert.*; /** @@ -13,11 +15,20 @@ public class ContentCellRenderTest { @Test public void highLightModelName() { + final String regex = ""; String searchText = "workb"; ContentCellRender contentCellRender = new ContentCellRender(searchText,new String[]{searchText}); String workbook = contentCellRender.highLightModelName("workbook", new String[]{searchText}); assertTrue(workbook.endsWith("workbook")); workbook = contentCellRender.highLightModelName("work book", new String[]{searchText}); assertTrue(workbook.endsWith("work book")); + + searchText = "我是空格"; + contentCellRender = new ContentCellRender(searchText, new String[]{"我是空格", "我是", "空格"}); + workbook = contentCellRender.highLightModelName("我是 空格", new String[]{searchText}); + assertEquals(workbook.replaceFirst(regex, StringUtils.EMPTY), workbook.replaceAll(regex, StringUtils.EMPTY)); + + workbook = contentCellRender.highLightModelName("我是是 空格", new String[]{"我是空格", "我是", "空格"}); + assertNotEquals(workbook.replaceFirst(regex, StringUtils.EMPTY), workbook.replaceAll(regex, StringUtils.EMPTY)); } } \ No newline at end of file