From e5db574c466690c7fd3bf404cc35e90d1f7a528a Mon Sep 17 00:00:00 2001 From: Yyming Date: Tue, 15 Sep 2020 14:43:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-39757=20AlphaFine=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=90=AB=E7=A9=BA=E6=A0=BC=E7=9A=84=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 11 +-- .../tabledatapane/DBTableDataPane.java | 2 +- .../alphafine/cell/model/BottomModel.java | 4 +- .../alphafine/component/AlphaFineDialog.java | 80 +++++++++---------- .../manager/impl/FileSearchManager.java | 5 +- .../manager/impl/FileSearchManagerTest.java | 79 ++++++++++++++++++ 6 files changed, 125 insertions(+), 56 deletions(-) create mode 100644 designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 68bb917114..da2f0e0dc7 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -218,14 +218,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (needCheckEnv) { checkNameEnvMap(); } - - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - @Override - public void envChanged() { - - designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX); - designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME); - } + GeneralContext.addEnvChangedListener(() -> { + designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX); + designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME); }); } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 23e6f46136..d1beacb1d8 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -218,7 +218,7 @@ public class DBTableDataPane extends AbstractTableDataPane { paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); List existParameterList = editorPane.update(); - Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); + Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[0]); editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps)); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java index c8f92721cb..503a4f413d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java @@ -49,9 +49,7 @@ public class BottomModel extends AlphaCellModel { public void doAction() { try { Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_GO_TO_FORUM)); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } catch (URISyntaxException e) { + } catch (IOException | URISyntaxException e) { FineLoggerFactory.getLogger().error(e.getMessage()); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java index 044a484b16..2654aca90e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java @@ -819,56 +819,52 @@ public class AlphaFineDialog extends UIDialog { } }); - Timer timer = new Timer(TIMER_DELAY, new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (!alreadyInitHot && StringUtils.isEmpty(searchTextField.getText())) { - alreadyInitHot = true; + Timer timer = new Timer(TIMER_DELAY, e -> { + if (!alreadyInitHot && StringUtils.isEmpty(searchTextField.getText())) { + alreadyInitHot = true; + removeSearchResult(); + refreshContainer(); + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { + initHotPane(); + setSize(AlphaFineConstants.FULL_SIZE); + } else { + setSize(AlphaFineConstants.FIELD_SIZE); + } + refreshContainer(); + return; + } else if (beforeSearchStr.equals(searchTextField.getText()) && StringUtils.isNotEmpty(beforeSearchStr)) { + if (alreadySearch) { + return; + } else { + removeHotPane(); removeSearchResult(); refreshContainer(); - if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { - initHotPane(); - setSize(AlphaFineConstants.FULL_SIZE); - } else { - setSize(AlphaFineConstants.FIELD_SIZE); - } - refreshContainer(); - return; - } else if (beforeSearchStr.equals(searchTextField.getText()) && StringUtils.isNotEmpty(beforeSearchStr)) { - if (alreadySearch) { - return; + if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedSegmentationCheckbox()) { + //是高级搜索 + if (searchTextField.getText().toLowerCase().startsWith(ADVANCED_SEARCH_MARK)) { + segmentationResult = SegmentationManager.getInstance().startSegmentation(getStoreText(searchTextField.getText().toLowerCase())); + } + //是普通搜索 + else { + segmentationResult = SegmentationManager.getInstance().startSegmentation(searchTextField.getText().toLowerCase()); + } } else { - removeHotPane(); - removeSearchResult(); - refreshContainer(); - if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedSegmentationCheckbox()) { - //是高级搜索 - if (searchTextField.getText().toLowerCase().startsWith(ADVANCED_SEARCH_MARK)) { - segmentationResult = SegmentationManager.getInstance().startSegmentation(getStoreText(searchTextField.getText().toLowerCase())); - } - //是普通搜索 - else { - segmentationResult = SegmentationManager.getInstance().startSegmentation(searchTextField.getText().toLowerCase()); - } + if (StringUtils.isEmpty(getRealSearchText(searchTextField.getText()))) { + segmentationResult = null; } else { - if (StringUtils.isEmpty(getRealSearchText(searchTextField.getText()))) { - segmentationResult = null; - } else { - segmentationResult = new String[]{getRealSearchText(searchTextField.getText())}; - } + segmentationResult = new String[]{getRealSearchText(searchTextField.getText())}; } - doSearch(searchTextField.getText().toLowerCase()); - alreadySearch = true; } - } else { - beforeSearchStr = searchTextField.getText(); - alreadySearch = false; - } - if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) { - alreadyInitHot = false; + doSearch(searchTextField.getText().toLowerCase()); + alreadySearch = true; } + } else { + beforeSearchStr = searchTextField.getText(); + alreadySearch = false; + } + if (beforeSearchStr.equals(searchTextField.getText()) && beforeSearchStr.length() != 0) { + alreadyInitHot = false; } - }); timer.start(); } 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 17c58998df..c867390702 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 @@ -108,14 +108,15 @@ public class FileSearchManager implements AlphaFineSearchProvider { private void doSearch(String searchText) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { for (FileNode node : fileNodes) { - if (node.getName().toLowerCase().contains(searchText)) { + String name = node.getName().toLowerCase(); + name = name.replaceAll(StringUtils.BLANK,StringUtils.EMPTY); + if (name.contains(searchText)) { FileModel model = new FileModel(node.getName(), node.getEnvPath()); if (!AlphaFineHelper.getFilterResult().contains(model)) { AlphaFineHelper.checkCancel(); filterModelList.add(model); } } - } } } diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java new file mode 100644 index 0000000000..093fb533c7 --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java @@ -0,0 +1,79 @@ +package com.fr.design.mainframe.alphafine.search.manager.impl; + +import com.fr.base.FRContext; +import com.fr.base.extension.FileExtension; +import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; +import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.file.filetree.FileNode; +import com.fr.invoke.Reflect; +import com.fr.stable.project.ProjectConstants; +import com.fr.web.core.SessionPoolManager; +import com.fr.web.utils.WebUtils; +import org.easymock.EasyMock; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + +/** + * @author Yyming + * @version 10.0 + * Created by Yyming on 2020/9/15 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({AlphaFineHelper.class,DesignerEnvManager.class}) +@SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper") +public class FileSearchManagerTest { + + @Test + public void doSearch() { + String searchText = "workb"; + FileSearchManager instance = FileSearchManager.getInstance(); + FileNode fileNode1 = EasyMock.createMock(FileNode.class); + FileNode fileNode2 = EasyMock.createMock(FileNode.class); + EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes(); + EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes(); + EasyMock.expect(fileNode1.getEnvPath()).andReturn("").anyTimes(); + EasyMock.expect(fileNode2.getEnvPath()).andReturn("").anyTimes(); + EasyMock.replay(fileNode1,fileNode2); + FileNode[] fileNodes = { fileNode1, fileNode2 }; + Reflect.on(instance).set("fileNodes",fileNodes); + + AlphaFineConfigManager configManager = EasyMock.createMock(AlphaFineConfigManager.class); + EasyMock.expect(configManager.isContainTemplate()).andReturn(true).anyTimes(); + EasyMock.replay(configManager); + + DesignerEnvManager manager = EasyMock.createMock(DesignerEnvManager.class); + EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(configManager).anyTimes(); + EasyMock.replay(manager); + PowerMock.mockStatic(DesignerEnvManager.class); + DesignerEnvManager.getEnvManager(); + PowerMock.expectLastCall().andReturn(manager).anyTimes(); + PowerMock.replay(DesignerEnvManager.class); + + List list = new ArrayList<>(); + PowerMock.mockStatic(AlphaFineHelper.class); + AlphaFineHelper.getFilterResult(); + PowerMock.expectLastCall().andReturn(list).anyTimes(); + AlphaFineHelper.findFolderName(""); + PowerMock.expectLastCall().andReturn("").anyTimes(); + AlphaFineHelper.checkCancel(); + PowerMock.expectLastCall().andVoid().anyTimes(); + PowerMock.replay(AlphaFineHelper.class); + + SearchResult alphaCellModels = new SearchResult(); + Reflect.on(instance).set("filterModelList",alphaCellModels); + Reflect.on(instance).call("doSearch",searchText); + assertEquals(alphaCellModels.size(),2); + } +} \ No newline at end of file From 3559ecc77756b6f63e388b6d6d3f539426013bd2 Mon Sep 17 00:00:00 2001 From: Yyming Date: Tue, 15 Sep 2020 14:59:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-39757=20=E5=B0=91=E4=B8=AA=E7=A9=BA?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/search/manager/impl/FileSearchManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 c867390702..1af1ce48fd 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 @@ -109,7 +109,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainTemplate()) { for (FileNode node : fileNodes) { String name = node.getName().toLowerCase(); - name = name.replaceAll(StringUtils.BLANK,StringUtils.EMPTY); + name = name.replaceAll(StringUtils.BLANK, StringUtils.EMPTY); if (name.contains(searchText)) { FileModel model = new FileModel(node.getName(), node.getEnvPath()); if (!AlphaFineHelper.getFilterResult().contains(model)) { @@ -123,6 +123,7 @@ public class FileSearchManager implements AlphaFineSearchProvider { /** * 搜索模板内容 + * * @param searchText */ private void doFileContentSearch(String searchText) { From 6033271af219eab9019ecd4063a3f9677ea23176 Mon Sep 17 00:00:00 2001 From: "Yuan.Wang" <1536296691@qq.com> Date: Tue, 15 Sep 2020 15:35:13 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-39894=20=E4=B8=8D=E5=B0=86=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94=E5=B8=83=E5=B1=80=E5=92=8C=E7=BB=9D=E5=AF=B9?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E7=9A=84=E5=AD=90=E7=B1=BB=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E9=A1=B6=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/designer/creator/XCreator.java | 7 +++++++ .../fr/design/designer/creator/XWAbsoluteBodyLayout.java | 4 ++++ .../java/com/fr/design/designer/creator/XWFitLayout.java | 5 +++++ .../com/fr/design/designer/creator/XWParameterLayout.java | 6 ++++-- .../design/designer/creator/cardlayout/XWTabFitLayout.java | 4 ++++ .../main/java/com/fr/design/mainframe/TopXCreators.java | 3 +++ 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 5eb284c7ba..ec83a1f9a5 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -805,4 +805,11 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return false; } + /** + * 是否支持置顶显示 + */ + public boolean isTopable() { + return true; + } + } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index 9a7d6dc975..2c88e62525 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -131,4 +131,8 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { return false; } + @Override + public boolean isTopable() { + return false; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 06aca3c1b3..3e425b4cd9 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -1222,6 +1222,11 @@ public class XWFitLayout extends XLayoutContainer { return false; } + @Override + public boolean isTopable() { + return false; + } + public boolean switch2FitBodyLayout(XCreator creator) { try { XWFitLayout xfl = (XWFitLayout) creator.getBackupParent(); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java index 3fc35a265c..1d37024d98 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java @@ -251,6 +251,8 @@ public class XWParameterLayout extends XWAbsoluteLayout { return false; } - - + @Override + public boolean isTopable() { + return false; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index 8d5d232fa6..a706674c7b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -639,4 +639,8 @@ public class XWTabFitLayout extends XWFitLayout { checkVisible(); } + @Override + public boolean isTopable() { + return true; + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java index 4c5ba6527e..89b261bb9a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java @@ -58,6 +58,9 @@ public class TopXCreators extends JComponent { SelectionModel selectionModel = designer.getSelectionModel(); XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); for (XCreator creator : xCreators) { + if (!creator.isTopable()) { + continue; + } XWCardMainBorderLayout topXMainBorderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); add(new TopXCreator(designer, creator)); if (topXMainBorderLayout != null) { From 9b25fb0625ff48a20f042c7881331cdc217f47ff Mon Sep 17 00:00:00 2001 From: Yyming Date: Wed, 16 Sep 2020 11:16:26 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-39757=20=E5=A4=84=E7=90=86=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E8=AF=8D=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cell/render/ContentCellRender.java | 24 +++-- .../alphafine/component/AlphaFineDialog.java | 88 ++++++++----------- .../alphafine/preview/PluginPreviewPane.java | 2 +- .../alphafine/preview/RobotPreviewPane.java | 4 +- .../manager/impl/FileSearchManager.java | 6 +- .../manager/impl/SegmentationManager.java | 5 +- .../cell/render/ContentCellRenderTest.java | 23 +++++ 7 files changed, 82 insertions(+), 70 deletions(-) create mode 100644 designer-realize/src/test/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRenderTest.java 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 07f5b4d4ed..da44fa510f 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 @@ -106,11 +106,10 @@ public class ContentCellRender implements ListCellRenderer { if (strings == null) { return modelName; } - for (int i = 0; i < strings.length; i++) { - String primaryStr = getReplacedString(modelName, strings[i]); - modelName = modelName.replaceAll("(?i)" + strings[i], "|" + strings[i] + "|"); + for (String string : strings) { + String primaryStr = getReplacedString(modelName, string); if (StringUtils.isNotEmpty(primaryStr)) { - modelName = modelName.replaceAll(strings[i], primaryStr); + modelName = modelName.replaceAll("(?i)" + primaryStr, "|" + primaryStr + "|"); } } modelName = "