From 39904502896f6936069c7da48bb60f4e810a20cb Mon Sep 17 00:00:00 2001 From: "Yuan.Wang" <1536296691@qq.com> Date: Tue, 15 Sep 2020 11:54:22 +0800 Subject: [PATCH 1/9] =?UTF-8?q?REPORT-39861=20=E5=90=91=E9=A1=B6=E5=B1=82?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0tab=E6=97=B6=E5=90=8C=E6=97=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=A2=AB=E9=80=89=E6=8B=A9=E7=9A=84=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/mainframe/TopXCreators.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 426f167eaf..4c5ba6527e 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 @@ -59,8 +59,11 @@ public class TopXCreators extends JComponent { XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); for (XCreator creator : xCreators) { XWCardMainBorderLayout topXMainBorderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); - TopXCreator topXCreator = topXMainBorderLayout == null ? new TopXCreator(designer, creator) : new TopXCreator(designer, topXMainBorderLayout); - add(topXCreator); + add(new TopXCreator(designer, creator)); + if (topXMainBorderLayout != null) { + add(new TopXCreator(designer, topXMainBorderLayout)); + } + } } From e5db574c466690c7fd3bf404cc35e90d1f7a528a Mon Sep 17 00:00:00 2001 From: Yyming Date: Tue, 15 Sep 2020 14:43:06 +0800 Subject: [PATCH 2/9] =?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 3/9] =?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 4/9] =?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 643c946415e4c347b7afcec00df864abc84e5b71 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 15 Sep 2020 18:49:51 +0800 Subject: [PATCH 5/9] =?UTF-8?q?REPORT-38872=20=E8=AE=BE=E8=AE=A1=E5=99=A8h?= =?UTF-8?q?ttps=E8=AF=81=E4=B9=A6=E5=AF=86=E7=A0=81=E6=98=8E=E6=96=87?= =?UTF-8?q?=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../env/RemoteDesignerWorkspaceInfo.java | 38 ++++++++++- .../src/main/java/com/fr/env/EnvListPane.java | 24 ++++++- .../env/RemoteDesignerWorkspaceInfoTest.java | 67 +++++++++++++++++++ 3 files changed, 125 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 2f30f70b97..37a671eeb8 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -40,6 +40,12 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { private WorkspaceConnectionInfo connection; + /** + * 标记下新创建的远程工作目录 兼容存留的远程目录客户升级后再回退 读取为密文 + * 仅保证当前新增是加密的 + */ + private boolean newCreated; + public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); info.connection = connection; @@ -79,12 +85,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return remindTime; } + public boolean isNewCreated() { + return newCreated; + } + + public void setNewCreated(boolean newCreated) { + this.newCreated = newCreated; + } + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { this.name = reader.getAttrAsString("name", StringUtils.EMPTY); this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); + this.newCreated = reader.getAttrAsBoolean("newCreated", false); } if (reader.isChildNode()) { String tagName = reader.getTagName(); @@ -92,32 +107,49 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { String url = reader.getAttrAsString("url", StringUtils.EMPTY); String username = reader.getAttrAsString("username", StringUtils.EMPTY); //密码解密 - String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); + String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n")); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); - String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); + String certSecretKey = readCertSecretKey(reader); boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true); this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd); } } } + private String readCertSecretKey(XMLableReader reader) { + if (isNewCreated()) { + return SecurityToolbox.defaultDecrypt(reader.getAttrAsString("certSecretKey", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n")); + } else { + return reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); + } + } + @Override public void writeXML(XMLPrintWriter writer) { writer.attr("name", name); writer.attr("remindTime", remindTime); + writer.attr("newCreated", isNewCreated()); if (this.connection != null) { writer.startTAG("Connection"); writer.attr("url", connection.getUrl()); writer.attr("username", connection.getUserName()); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("certPath", connection.getCertPath()); - writer.attr("certSecretKey", connection.getCertSecretKey()); + writeCertSecretKey(writer); writer.attr("rememberPwd", connection.isRememberPwd()); writer.end(); } } + private void writeCertSecretKey(XMLPrintWriter writer) { + if (isNewCreated()) { + writer.attr("certSecretKey", SecurityToolbox.defaultEncrypt(connection.getCertSecretKey())); + } else { + writer.attr("certSecretKey", connection.getCertSecretKey()); + } + } + @Override @SuppressWarnings("squid:S2975") public Object clone() throws CloneNotSupportedException { diff --git a/designer-base/src/main/java/com/fr/env/EnvListPane.java b/designer-base/src/main/java/com/fr/env/EnvListPane.java index 911a7b22f8..2d875cb458 100644 --- a/designer-base/src/main/java/com/fr/env/EnvListPane.java +++ b/designer-base/src/main/java/com/fr/env/EnvListPane.java @@ -3,6 +3,7 @@ package com.fr.env; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.controlpane.JListControlPane; @@ -17,8 +18,10 @@ import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.*; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; /** * @author yaohwu @@ -98,11 +101,30 @@ public class EnvListPane extends JListControlPane { DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); //这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖 Nameable[] res = this.update(); + Set set = findNewWorkSpaceInfo(res); mgr.clearAllEnv(); for (Nameable re : res) { NameObject nameObject = (NameObject) re; - mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject()); + DesignerWorkspaceInfo info = (DesignerWorkspaceInfo) nameObject.getObject(); + if (set.contains(re) && info.getType() == DesignerWorkspaceType.Remote) { + RemoteDesignerWorkspaceInfo newInfo = (RemoteDesignerWorkspaceInfo) info; + newInfo.setNewCreated(true); + mgr.putEnv(nameObject.getName(), newInfo); + } else { + mgr.putEnv(nameObject.getName(), info); + } } return this.getSelectedName(); } + + private Set findNewWorkSpaceInfo(Nameable[] res) { + Set set = new HashSet<>(); + for (Nameable val : res) { + NameObject nameObject = (NameObject) val; + if (DesignerEnvManager.getEnvManager().getWorkspaceInfo(nameObject.getName()) == null) { + set.add(val); + } + } + return set; + } } diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java index 54dbae3b02..d6e89cd93f 100644 --- a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java @@ -1,9 +1,16 @@ package com.fr.design.env; +import com.fr.invoke.Reflect; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReaderHelper; +import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnectionInfo; import junit.framework.TestCase; import org.junit.Assert; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; + /** * @author hades * @version 10.0 @@ -22,4 +29,64 @@ public class RemoteDesignerWorkspaceInfoTest extends TestCase { Assert.assertFalse(workspaceInfo3.checkValid()); } + public void testReadXml() { + String xml0 = ""; + String xml1 = ""; + byte[] bytes0 = xml0.getBytes(); + byte[] bytes1 = xml1.getBytes(); + RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); + ByteArrayInputStream in0 = new ByteArrayInputStream(bytes0); + ByteArrayInputStream in1 = new ByteArrayInputStream(bytes1); + + try { + XMLableReader reader0 = XMLReaderHelper.createXMLableReader(in0, XMLPrintWriter.XML_ENCODER); + Reflect.on(reader0).set("state", 1); + info.setNewCreated(true); + info.readXML(reader0); + Assert.assertEquals("xxxxxxx", info.getConnection().getCertSecretKey()); + + XMLableReader reader1 = XMLReaderHelper.createXMLableReader(in1, XMLPrintWriter.XML_ENCODER); + Reflect.on(reader1).set("state", 1); + info.setNewCreated(false); + info.readXML(reader1); + Assert.assertEquals("xxxxxxx", info.getConnection().getCertSecretKey()); + } catch (Exception ignore) { + + } + } + + public void testWriteXml() { + ByteArrayOutputStream out0 = new ByteArrayOutputStream(); + XMLPrintWriter writer0 = XMLPrintWriter.create(out0); + RemoteDesignerWorkspaceInfo info0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("127.0.0.1", "1", "1", "/xxx", "xxxxx", true)); + info0.setNewCreated(true); + info0.writeXML(writer0); + writer0.close(); + String result0 = new String(out0.toByteArray()); + Assert.assertTrue(result0.contains("certSecretKey")); + Assert.assertFalse(result0.contains("certSecretKey=\"xxxxx\"")); + + ByteArrayOutputStream out1 = new ByteArrayOutputStream(); + XMLPrintWriter writer1 = XMLPrintWriter.create(out1); + RemoteDesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("127.0.0.1", "1", "1", "/xxx", "xxxxx", true)); + info1.writeXML(writer1); + writer1.close(); + String result1 = new String(out1.toByteArray()); + Assert.assertTrue(result1.contains("certSecretKey")); + Assert.assertTrue(result1.contains("certSecretKey=\"xxxxx\"")); + + } + } From 9b25fb0625ff48a20f042c7881331cdc217f47ff Mon Sep 17 00:00:00 2001 From: Yyming Date: Wed, 16 Sep 2020 11:16:26 +0800 Subject: [PATCH 6/9] =?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 = "