From 9200a190d6724f68dfd8975c3fcd2c0a544c1b47 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 30 Jul 2019 11:12:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-19857=20=E8=8B=B1=E6=96=87=E7=89=88a?= =?UTF-8?q?lphafine=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=201.=20=E6=8A=8A?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=9B=BD=E9=99=85=E5=8C=96=E7=9A=84=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E5=92=8C=20=E7=82=B9=E5=87=BB=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=89=8D=E8=83=BD=E6=9B=B4=E6=96=B0=20?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=E8=A7=A3=E8=80=A6=E3=80=82=E6=94=BE?= =?UTF-8?q?=E5=88=B0=E5=90=AF=E5=8A=A8=E7=9A=84=E6=97=B6=E5=80=99=E5=81=9A?= =?UTF-8?q?=E3=80=82=202.=20=E9=85=8D=E7=BD=AE=E4=B8=8D=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E4=BA=8E=20searchOnline=20=E8=80=8C=E6=98=AF=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E4=B8=AD=E8=8B=B1=E6=96=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../help/alphafine/AlphaFineAction.java | 6 +----- .../help/alphafine/AlphaFineConfigPane.java | 21 ++++++++++++++----- .../mainframe/alphafine/AlphaFineHelper.java | 20 ++++++++++++++++++ .../fr/start/module/DesignerActivator.java | 4 +++- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java index dda1fb68bc..f78d341a53 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java @@ -1,6 +1,5 @@ package com.fr.design.actions.help.alphafine; -import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; @@ -11,7 +10,7 @@ import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; import com.fr.general.IOUtils; -import javax.swing.*; +import javax.swing.KeyStroke; import java.awt.event.ActionEvent; /** @@ -51,9 +50,6 @@ public class AlphaFineAction extends UpdateAction { final AlphaFineConfigPane alphaFineConfigPane = new AlphaFineConfigPane(); final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); - if (!FRContext.isChineseEnv()) { - manager.setSearchOnLine(false); - } alphaFineConfigPane.populate(manager); DialogActionListener dialogActionListener = new DialogActionAdapter() { public void doOk() { diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index c886e3c93a..d261de57c3 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -189,23 +189,34 @@ public class AlphaFineConfigPane extends BasicPane { } public void populate(AlphaFineConfigManager alphaFineConfigManager) { + this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled()); - this.searchOnlineCheckbox.setEnabled(FRContext.isChineseEnv()); + + boolean enabled4Locale = FRContext.isChineseEnv(); + + this.searchOnlineCheckbox.setEnabled(enabled4Locale); this.searchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine()); + this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction()); this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate()); this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent()); + this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine()); - this.containDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.containDocumentCheckbox.setEnabled(enabled4Locale); + this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine()); - this.containPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.containPluginCheckbox.setEnabled(enabled4Locale); + this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine()); - this.containRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.containRecommendCheckbox.setEnabled(enabled4Locale); + this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts())); this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox()); + this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine()); - this.needIntelligentCustomerService.setEnabled(alphaFineConfigManager.isSearchOnLine()); + this.needIntelligentCustomerService.setEnabled(enabled4Locale); + shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts()); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java index 1057d92868..dd5a01349e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java @@ -15,6 +15,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager; +import com.fr.general.GeneralContext; import com.fr.general.ProcessCanceledException; import com.fr.general.http.HttpToolbox; import com.fr.json.JSON; @@ -33,6 +34,25 @@ public class AlphaFineHelper { public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed")); private static AlphaFineDialog alphaFineDialog; private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com"; + + private AlphaFineHelper() { + + } + + /** + * 根据国际化调整配置 + */ + public static void switchConfig4Locale() { + + AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); + if (!GeneralContext.isChineseEnv()) { + manager.setSearchOnLine(false); + manager.setContainDocument(false); + manager.setContainPlugin(false); + manager.setContainRecommend(false); + manager.setNeedIntelligentCustomerService(false); + } + } /** * 弹出alphafine搜索面板 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 fe423131dd..b1a546184a 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 @@ -47,6 +47,7 @@ import com.fr.design.mainframe.InformationCollector; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetToolBarPane; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.bbs.BBSGuestPane; import com.fr.design.mainframe.bbs.UserInfoPane; import com.fr.design.mainframe.form.FormECCompositeProvider; @@ -134,8 +135,9 @@ public class DesignerActivator extends Activator { DesignerSocketIO.update(); UserInfoPane.getInstance().updateBBSUserInfo(); storePassport(); + AlphaFineHelper.switchConfig4Locale(); } - + private void loadLogAppender() { logHandler = new LogHandler() { final DesignerLogAppender logAppender = new DesignerLogAppender(); From 47540321b5829aa21eb03177b32625842a00b626 Mon Sep 17 00:00:00 2001 From: Harrison Date: Tue, 30 Jul 2019 11:35:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/AlphaFineHelperTest.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java new file mode 100644 index 0000000000..3c14275b7c --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java @@ -0,0 +1,46 @@ +package com.fr.design.mainframe.alphafine; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; +import com.fr.general.GeneralContext; +import org.easymock.EasyMock; +import org.junit.Assert; +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 static org.junit.Assert.*; + +@RunWith(PowerMockRunner.class) +public class AlphaFineHelperTest { + + @Test + @PrepareForTest({GeneralContext.class, DesignerEnvManager.class}) + @SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper") + public void testSwitchConfig4Locale() throws Exception { + + PowerMock.mockStatic(GeneralContext.class); + EasyMock.expect(GeneralContext.isChineseEnv()).andReturn(true).times(1).andReturn(false).times(1); + + DesignerEnvManager manager = EasyMock.mock(DesignerEnvManager.class); + EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(new AlphaFineConfigManager()).anyTimes(); + EasyMock.replay(manager); + + PowerMock.mockStatic(DesignerEnvManager.class); + EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes(); + + PowerMock.replayAll(); + + AlphaFineHelper.switchConfig4Locale(); + AlphaFineConfigManager config = manager.getAlphaFineConfigManager(); + Assert.assertEquals(true, config.isSearchOnLine()); + + AlphaFineHelper.switchConfig4Locale(); + Assert.assertEquals(false, config.isSearchOnLine()); + + + } +} \ No newline at end of file