From f04c4cfdf916abc61645924c46a1e7bc88a23708 Mon Sep 17 00:00:00 2001 From: Hades Date: Fri, 31 May 2019 16:18:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?KERNEL-582=20=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E5=AE=9A=E5=88=B6=E7=9A=84=E5=9C=B0=E6=96=B9=E4=BC=9A=E8=B6=8A?= =?UTF-8?q?=E6=9D=A5=E8=B6=8A=E5=A4=9A=EF=BC=8C=E6=83=B3=E5=8A=9E=E6=B3=95?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=BF=99=E7=A7=8Dif=20else=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/community/VideoAction.java | 16 +++----- .../java/com/fr/design/i18n/ActionType.java | 32 +++++++++++++++ .../java/com/fr/design/i18n/LocaleCenter.java | 41 +++++++++++++++++++ .../com/fr/design/i18n/LocaleDifference.java | 32 +++++++++++++++ .../impl/AbstractDefaultLocaleAction.java | 41 +++++++++++++++++++ .../design/i18n/impl/ChinaLocaleAction.java | 9 ++++ .../design/i18n/impl/JapanLocaleAction.java | 21 ++++++++++ .../design/i18n/impl/KoreaLocaleAction.java | 6 +++ .../design/i18n/impl/TaiWanLocaleAction.java | 21 ++++++++++ .../fr/design/i18n/impl/USLocaleAction.java | 16 ++++++++ .../mainframe/toolbar/ToolBarMenuDock.java | 5 +-- .../start/CollectUserInformationDialog.java | 21 ++-------- .../main/java/com/fr/start/SplashContext.java | 10 +---- 13 files changed, 231 insertions(+), 40 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/i18n/ActionType.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java create mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java diff --git a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java index 8e9fd5b32..6eea8cc15 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java @@ -1,15 +1,15 @@ package com.fr.design.actions.community; -import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; +import com.fr.design.i18n.ActionType; +import com.fr.design.i18n.LocaleCenter; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; -import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.event.ActionEvent; -import java.util.Locale; public class VideoAction extends UpdateAction { @@ -19,20 +19,14 @@ public class VideoAction extends UpdateAction this.setMenuKeySet(VIDEO); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/video.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/video.png")); } @Override public void actionPerformed(ActionEvent arg0) { - String url; - if (GeneralContext.getLocale().equals(Locale.US)) { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); - } else { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); - } - BrowseUtils.browser(url); + BrowseUtils.browser(LocaleCenter.getInstance().getLocaleAction(GeneralContext.getLocale()).getUrls().get(ActionType.VIDEO)); } public static final MenuKeySet VIDEO = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/i18n/ActionType.java b/designer-base/src/main/java/com/fr/design/i18n/ActionType.java new file mode 100644 index 000000000..1f6b9943a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/ActionType.java @@ -0,0 +1,32 @@ +package com.fr.design.i18n; + +public enum ActionType { + + /** + * 视频教学 + */ + VIDEO("video"), + + /** + * 激活码 + */ + ACTIVATION_CODE("activationCode"), + + /** + * 帮助文档 + */ + HELP_DOCUMENT("helpDocument"), + + /** + * 论坛 + */ + BBS("bbs"); + + + private String description; + + ActionType(String description) { + this.description = description; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java new file mode 100644 index 000000000..79476f15f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java @@ -0,0 +1,41 @@ +package com.fr.design.i18n; + +import com.fr.design.i18n.impl.ChinaLocaleAction; +import com.fr.design.i18n.impl.JapanLocaleAction; +import com.fr.design.i18n.impl.KoreaLocaleAction; +import com.fr.design.i18n.impl.TaiWanLocaleAction; +import com.fr.design.i18n.impl.USLocaleAction; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +public class LocaleCenter { + + private Map actionMap = new HashMap(); + + private LocaleCenter() { + init(); + } + + private void init() { + actionMap.put(Locale.CHINA, new ChinaLocaleAction()); + actionMap.put(Locale.US, new USLocaleAction()); + actionMap.put(Locale.TAIWAN, new TaiWanLocaleAction()); + actionMap.put(Locale.JAPAN, new JapanLocaleAction()); + actionMap.put(Locale.KOREA, new KoreaLocaleAction()); + } + + private static class Holder { + private static final LocaleCenter INSTANCE = new LocaleCenter(); + } + + public static LocaleCenter getInstance() { + return Holder.INSTANCE; + } + + public LocaleDifference getLocaleAction(Locale locale) { + LocaleDifference localeDifference = actionMap.get(locale); + return localeDifference == null ? actionMap.get(Locale.CHINA) : localeDifference; + } +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java new file mode 100644 index 000000000..41a7b26ce --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java @@ -0,0 +1,32 @@ +package com.fr.design.i18n; + +import java.util.List; +import java.util.Map; + +/** + * 国际化之间有不同表现的动作 + */ +public interface LocaleDifference { + + /** + * 返回该国际化所有的url + * @return url + */ + Map getUrls(); + + + /** + * 添加Action + * @param list 列表 + * @param action 对应action + */ + void addAction(List list, Object action); + + /** + * 返回设计器启动画面路径 + * @return 路径 + */ + String getSplashPath(); + + +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java new file mode 100644 index 000000000..d190c990f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java @@ -0,0 +1,41 @@ +package com.fr.design.i18n.impl; + +import com.fr.design.i18n.LocaleDifference; +import com.fr.design.i18n.ActionType; +import com.fr.general.CloudCenter; + +import java.util.EnumMap; +import java.util.List; +import java.util.Map; + +public abstract class AbstractDefaultLocaleAction implements LocaleDifference { + + protected EnumMap urls = new EnumMap(ActionType.class); + + protected void init() { + urls.put(ActionType.BBS, CloudCenter.getInstance().acquireUrlByKind("bbs")); + urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video")); + urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.cn")); + urls.put(ActionType.HELP_DOCUMENT, CloudCenter.getInstance().acquireUrlByKind("help.zh_CN.10")); + } + + @Override + public Map getUrls() { + if (urls.isEmpty()) { + init(); + } + return urls; + } + + @Override + public void addAction(List list, Object action) { + // do nothing + } + + @Override + public String getSplashPath() { + return "/com/fr/design/images/splash_10_en.gif"; + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java new file mode 100644 index 000000000..c10c9b714 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java @@ -0,0 +1,9 @@ +package com.fr.design.i18n.impl; + +public class ChinaLocaleAction extends AbstractDefaultLocaleAction { + + @Override + public String getSplashPath() { + return "/com/fr/design/images/splash_10.gif"; + } +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java new file mode 100644 index 000000000..8a018bee0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java @@ -0,0 +1,21 @@ +package com.fr.design.i18n.impl; + +import com.fr.design.i18n.ActionType; +import com.fr.general.CloudCenter; + +public class JapanLocaleAction extends AbstractDefaultLocaleAction { + + @Override + protected void init() { + super.init(); + urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.jp")); + } + + + @Override + public String getSplashPath() { + return "/com/fr/design/images/splash_10_jp.gif"; + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java new file mode 100644 index 000000000..0216ecdbd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java @@ -0,0 +1,6 @@ +package com.fr.design.i18n.impl; + + +public class KoreaLocaleAction extends AbstractDefaultLocaleAction { + +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java new file mode 100644 index 000000000..2985e7416 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java @@ -0,0 +1,21 @@ +package com.fr.design.i18n.impl; + +import com.fr.design.i18n.ActionType; +import com.fr.general.CloudCenter; + +import java.util.List; + +public class TaiWanLocaleAction extends AbstractDefaultLocaleAction { + + @Override + protected void init() { + super.init(); + urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video.zh_TW")); + urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.tw")); + } + + @Override + public void addAction(List list, Object action) { + list.add(action); + } +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java new file mode 100644 index 000000000..bdd305761 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java @@ -0,0 +1,16 @@ +package com.fr.design.i18n.impl; + +import com.fr.design.i18n.ActionType; +import com.fr.general.CloudCenter; + +public class USLocaleAction extends AbstractDefaultLocaleAction { + + @Override + protected void init() { + super.init(); + urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video.en")); + urls.put(ActionType.HELP_DOCUMENT, CloudCenter.getInstance().acquireUrlByKind("help.en_US.10")); + urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.en")); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 7e0d6b359..52103026a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -47,6 +47,7 @@ import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.UIMenuBar; import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.LocaleCenter; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.ToolBarNewTemplatePane; import com.fr.design.menu.MenuDef; @@ -543,9 +544,7 @@ public abstract class ToolBarMenuDock { shortCuts.add(new CusDemandAction()); shortCuts.add(new CenterAction()); shortCuts.add(new SignAction()); - if (Locale.TAIWAN.equals(GeneralContext.getLocale())) { - shortCuts.add(new FacebookFansAction()); - } + LocaleCenter.getInstance().getLocaleAction(GeneralContext.getLocale()).addAction(shortCuts, new FacebookFansAction()); return shortCuts.toArray(new ShortCut[shortCuts.size()]); } diff --git a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java index c32c2307d..f74fb7966 100644 --- a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java +++ b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java @@ -7,11 +7,11 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.ActionType; +import com.fr.design.i18n.LocaleCenter; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ActiveKeyGenerator; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.CloudCenter; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import javax.swing.*; @@ -31,11 +31,6 @@ public class CollectUserInformationDialog extends UIDialog { private static final int ONLINE_VERIFY_TIMEOUT = 30 * 1000; - private static final String CN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.cn"); - private static final String EN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.en"); - private static final String TW_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.tw"); - private static final String JP_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.jp"); - private UITextField keyTextField; private ActionListener actionListener = new ActionListener() { @@ -130,18 +125,8 @@ public class CollectUserInformationDialog extends UIDialog { private void getKeyAction() { Locale locale = GeneralContext.getLocale(); - String url = EN_LOGIN_HTML; - if (ComparatorUtils.equals(locale, Locale.TAIWAN)) { - url = TW_LOGIN_HTML; - } - if (ComparatorUtils.equals(locale, Locale.CHINA)) { - url = CN_LOGIN_HTML; - } - if (ComparatorUtils.equals(locale, Locale.JAPAN)) { - url = JP_LOGIN_HTML; - } try { - Desktop.getDesktop().browse(new URI(url)); + Desktop.getDesktop().browse(new URI(LocaleCenter.getInstance().getLocaleAction(locale).getUrls().get(ActionType.ACTIVATION_CODE))); } catch (Exception ignored) { } diff --git a/designer-realize/src/main/java/com/fr/start/SplashContext.java b/designer-realize/src/main/java/com/fr/start/SplashContext.java index 17eff62ba..17a4897b3 100644 --- a/designer-realize/src/main/java/com/fr/start/SplashContext.java +++ b/designer-realize/src/main/java/com/fr/start/SplashContext.java @@ -1,6 +1,7 @@ package com.fr.start; import com.fr.design.DesignerEnvManager; +import com.fr.design.i18n.LocaleCenter; import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -166,13 +167,6 @@ public class SplashContext { } private static String getSplashPath() { - Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); - if (Locale.US.equals(locale) || Locale.KOREA.equals(locale) || Locale.TAIWAN.equals(locale)) { - return "/com/fr/design/images/splash_10_en.gif"; - } else if (Locale.JAPAN.equals(locale)) { - return "/com/fr/design/images/splash_10_jp.gif"; - } else { - return "/com/fr/design/images/splash_10.gif"; - } + return LocaleCenter.getInstance().getLocaleAction(DesignerEnvManager.getEnvManager().getLanguage()).getSplashPath(); } } From bfc341f3b0113e61227940f8941f0ec33b91e954 Mon Sep 17 00:00:00 2001 From: Hades Date: Tue, 4 Jun 2019 19:56:13 +0800 Subject: [PATCH 2/4] update --- .../design/actions/community/VideoAction.java | 2 +- .../main/java/com/fr/design/i18n/Action.java | 21 +++++++++++++++ .../java/com/fr/design/i18n/ActionType.java | 6 +++++ .../java/com/fr/design/i18n/LocaleCenter.java | 15 ++++++++++- .../com/fr/design/i18n/LocaleDifference.java | 23 +++++++++++++--- .../impl/AbstractDefaultLocaleAction.java | 27 ++++++++++++++++--- .../design/i18n/impl/ChinaLocaleAction.java | 13 +++++++++ .../design/i18n/impl/JapanLocaleAction.java | 13 +++++++++ .../design/i18n/impl/KoreaLocaleAction.java | 11 ++++++++ .../design/i18n/impl/TaiWanLocaleAction.java | 11 ++++++-- .../fr/design/i18n/impl/USLocaleAction.java | 12 +++++++++ .../mainframe/toolbar/ToolBarMenuDock.java | 10 +++++-- .../start/CollectUserInformationDialog.java | 3 +-- .../main/java/com/fr/start/SplashContext.java | 5 ++-- 14 files changed, 153 insertions(+), 19 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/i18n/Action.java diff --git a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java index 6eea8cc15..e405f3bb5 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java @@ -26,7 +26,7 @@ public class VideoAction extends UpdateAction @Override public void actionPerformed(ActionEvent arg0) { - BrowseUtils.browser(LocaleCenter.getInstance().getLocaleAction(GeneralContext.getLocale()).getUrls().get(ActionType.VIDEO)); + BrowseUtils.browser(LocaleCenter.getInstance().getLocaleAction().getUrls().get(ActionType.VIDEO)); } public static final MenuKeySet VIDEO = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/i18n/Action.java b/designer-base/src/main/java/com/fr/design/i18n/Action.java new file mode 100644 index 000000000..a976ae4b7 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/Action.java @@ -0,0 +1,21 @@ +package com.fr.design.i18n; + +/** + * 包装一些动作 + * @author Hades + * @date 2019/6/4 + */ +public interface Action { + + Action EMPTY_ACTION = new Action() { + @Override + public void todo() { + // do nothing + } + }; + + /** + * 具体动作 + */ + void todo(); +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/ActionType.java b/designer-base/src/main/java/com/fr/design/i18n/ActionType.java index 1f6b9943a..724d3df66 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/ActionType.java +++ b/designer-base/src/main/java/com/fr/design/i18n/ActionType.java @@ -1,5 +1,11 @@ package com.fr.design.i18n; +/** + * 不同语言环境下的action + * + * @author Hades + * @date 2019/5/30 + */ public enum ActionType { /** diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java index 79476f15f..20bc09611 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java +++ b/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java @@ -1,15 +1,24 @@ package com.fr.design.i18n; +import com.fr.design.DesignerEnvManager; import com.fr.design.i18n.impl.ChinaLocaleAction; import com.fr.design.i18n.impl.JapanLocaleAction; import com.fr.design.i18n.impl.KoreaLocaleAction; import com.fr.design.i18n.impl.TaiWanLocaleAction; import com.fr.design.i18n.impl.USLocaleAction; +import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import java.util.HashMap; import java.util.Locale; import java.util.Map; +/** + * 不同语言环境的动作管理 + * + * @author Hades + * @date 2019/5/30 + */ public class LocaleCenter { private Map actionMap = new HashMap(); @@ -34,7 +43,11 @@ public class LocaleCenter { return Holder.INSTANCE; } - public LocaleDifference getLocaleAction(Locale locale) { + public LocaleDifference getLocaleAction() { + Locale locale = GeneralContext.getLocale(); + if (!ComparatorUtils.equals(locale, DesignerEnvManager.getEnvManager().getLanguage())) { + locale = DesignerEnvManager.getEnvManager().getLanguage(); + } LocaleDifference localeDifference = actionMap.get(locale); return localeDifference == null ? actionMap.get(Locale.CHINA) : localeDifference; } diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java index 41a7b26ce..d18ef8b9f 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java +++ b/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java @@ -1,10 +1,14 @@ package com.fr.design.i18n; import java.util.List; +import java.util.Locale; import java.util.Map; /** * 国际化之间有不同表现的动作 + * + * @author Hades + * @date 2019/5/30 */ public interface LocaleDifference { @@ -16,11 +20,17 @@ public interface LocaleDifference { /** - * 添加Action - * @param list 列表 - * @param action 对应action + * 哪些国际化需要执行该动作 + * @param locales */ - void addAction(List list, Object action); + void doAction(Locale ...locales); + + /** + * 构建具体的动作 + * @param action + * @return + */ + LocaleDifference buildAction(Action action); /** * 返回设计器启动画面路径 @@ -28,5 +38,10 @@ public interface LocaleDifference { */ String getSplashPath(); + /** + * 对应的国际化 + * @return + */ + Locale getLocale(); } diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java index d190c990f..9ed01d31d 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java @@ -1,16 +1,28 @@ package com.fr.design.i18n.impl; +import com.fr.design.i18n.Action; import com.fr.design.i18n.LocaleDifference; import com.fr.design.i18n.ActionType; import com.fr.general.CloudCenter; +import com.fr.general.ComparatorUtils; +import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumMap; import java.util.List; +import java.util.Locale; import java.util.Map; +/** + * 一些默认的实现 + * + * @author Hades + * @date 2019/5/30 + */ public abstract class AbstractDefaultLocaleAction implements LocaleDifference { protected EnumMap urls = new EnumMap(ActionType.class); + private Action action = Action.EMPTY_ACTION; protected void init() { urls.put(ActionType.BBS, CloudCenter.getInstance().acquireUrlByKind("bbs")); @@ -28,14 +40,21 @@ public abstract class AbstractDefaultLocaleAction implements LocaleDifference { } @Override - public void addAction(List list, Object action) { - // do nothing + public void doAction(Locale ...locales) { + List localeList = Arrays.asList(locales); + if (localeList.contains(this.getLocale())) { + action.todo(); + } + } + + @Override + public LocaleDifference buildAction(Action action) { + this.action = action; + return this; } @Override public String getSplashPath() { return "/com/fr/design/images/splash_10_en.gif"; } - - } diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java index c10c9b714..d2fc2c7f9 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java @@ -1,9 +1,22 @@ package com.fr.design.i18n.impl; +import java.util.Locale; + +/** + * 简体中文环境具体的表现动作 + * + * @author Hades + * @date 2019/5/30 + */ public class ChinaLocaleAction extends AbstractDefaultLocaleAction { @Override public String getSplashPath() { return "/com/fr/design/images/splash_10.gif"; } + + @Override + public Locale getLocale() { + return Locale.CHINA; + } } diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java index 8a018bee0..81614bbb8 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java @@ -3,6 +3,14 @@ package com.fr.design.i18n.impl; import com.fr.design.i18n.ActionType; import com.fr.general.CloudCenter; +import java.util.Locale; + +/** + * 日文环境具体的表现动作 + * + * @author Hades + * @date 2019/5/30 + */ public class JapanLocaleAction extends AbstractDefaultLocaleAction { @Override @@ -17,5 +25,10 @@ public class JapanLocaleAction extends AbstractDefaultLocaleAction { return "/com/fr/design/images/splash_10_jp.gif"; } + @Override + public Locale getLocale() { + return Locale.JAPAN; + } + } diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java index 0216ecdbd..5a5e9b8ed 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java @@ -1,6 +1,17 @@ package com.fr.design.i18n.impl; +import java.util.Locale; +/** + * 韩文环境具体的表现动作 + * + * @author Hades + * @date 2019/5/30 + */ public class KoreaLocaleAction extends AbstractDefaultLocaleAction { + @Override + public Locale getLocale() { + return Locale.KOREA; + } } diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java index 2985e7416..f9e8df2af 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java @@ -4,7 +4,14 @@ import com.fr.design.i18n.ActionType; import com.fr.general.CloudCenter; import java.util.List; +import java.util.Locale; +/** + * 繁体中文具体的表现动作 + * + * @author Hades + * @date 2019/5/30 + */ public class TaiWanLocaleAction extends AbstractDefaultLocaleAction { @Override @@ -15,7 +22,7 @@ public class TaiWanLocaleAction extends AbstractDefaultLocaleAction { } @Override - public void addAction(List list, Object action) { - list.add(action); + public Locale getLocale() { + return Locale.TAIWAN; } } diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java index bdd305761..4acfc3db1 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java +++ b/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java @@ -3,6 +3,14 @@ package com.fr.design.i18n.impl; import com.fr.design.i18n.ActionType; import com.fr.general.CloudCenter; +import java.util.Locale; + +/** + * 英文环境具体的表现动作 + * + * @author Hades + * @date 2019/5/30 + */ public class USLocaleAction extends AbstractDefaultLocaleAction { @Override @@ -13,4 +21,8 @@ public class USLocaleAction extends AbstractDefaultLocaleAction { urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.en")); } + @Override + public Locale getLocale() { + return Locale.US; + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 52103026a..3fad25f6f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -47,6 +47,7 @@ import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.UIMenuBar; import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Action; import com.fr.design.i18n.LocaleCenter; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.ToolBarNewTemplatePane; @@ -533,7 +534,7 @@ public abstract class ToolBarMenuDock { * @return 社区菜单的子菜单 */ public ShortCut[] createCommunityShortCuts() { - java.util.List shortCuts = new ArrayList(); + final java.util.List shortCuts = new ArrayList(); shortCuts.add(new BBSAction()); shortCuts.add(new VideoAction()); shortCuts.add(new TutorialAction()); @@ -544,7 +545,12 @@ public abstract class ToolBarMenuDock { shortCuts.add(new CusDemandAction()); shortCuts.add(new CenterAction()); shortCuts.add(new SignAction()); - LocaleCenter.getInstance().getLocaleAction(GeneralContext.getLocale()).addAction(shortCuts, new FacebookFansAction()); + LocaleCenter.getInstance().getLocaleAction().buildAction(new Action() { + @Override + public void todo() { + shortCuts.add(new FacebookFansAction()); + } + }).doAction(Locale.TAIWAN); return shortCuts.toArray(new ShortCut[shortCuts.size()]); } diff --git a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java index f74fb7966..1ec071281 100644 --- a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java +++ b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java @@ -124,9 +124,8 @@ public class CollectUserInformationDialog extends UIDialog { private void getKeyAction() { - Locale locale = GeneralContext.getLocale(); try { - Desktop.getDesktop().browse(new URI(LocaleCenter.getInstance().getLocaleAction(locale).getUrls().get(ActionType.ACTIVATION_CODE))); + Desktop.getDesktop().browse(new URI(LocaleCenter.getInstance().getLocaleAction().getUrls().get(ActionType.ACTIVATION_CODE))); } catch (Exception ignored) { } diff --git a/designer-realize/src/main/java/com/fr/start/SplashContext.java b/designer-realize/src/main/java/com/fr/start/SplashContext.java index 17a4897b3..9fcdad122 100644 --- a/designer-realize/src/main/java/com/fr/start/SplashContext.java +++ b/designer-realize/src/main/java/com/fr/start/SplashContext.java @@ -1,6 +1,5 @@ package com.fr.start; -import com.fr.design.DesignerEnvManager; import com.fr.design.i18n.LocaleCenter; import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.event.Event; @@ -25,7 +24,7 @@ import java.util.concurrent.TimeUnit; public class SplashContext { public static final String SPLASH_PATH = getSplashPath(); - public static final String SPLASH_CACHE_NAME = SPLASH_PATH.substring(SPLASH_PATH.lastIndexOf("/") + 1); + public static final String SPLASH_CACHE_NAME = SPLASH_PATH.substring(SPLASH_PATH.lastIndexOf('/') + 1); private static final int FETCH_ONLINE_MAX_TIMES = 50; private static final SplashContext SPLASH_CONTEXT = new SplashContext(); @@ -167,6 +166,6 @@ public class SplashContext { } private static String getSplashPath() { - return LocaleCenter.getInstance().getLocaleAction(DesignerEnvManager.getEnvManager().getLanguage()).getSplashPath(); + return LocaleCenter.getInstance().getLocaleAction().getSplashPath(); } } From 63cf9064fe8b4e2032908cf60f5f9cb6e505b062 Mon Sep 17 00:00:00 2001 From: Hades Date: Wed, 5 Jun 2019 09:38:04 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-17656=20=E5=86=B3=E7=AD=96=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E6=8A=A5=E8=A1=A8=E5=9D=97=E5=A4=8D=E5=88=B6=E5=90=8E?= =?UTF-8?q?=E5=80=BC=E8=A2=AB=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/community/VideoAction.java | 16 +++-- .../main/java/com/fr/design/i18n/Action.java | 21 ------- .../java/com/fr/design/i18n/ActionType.java | 38 ------------ .../java/com/fr/design/i18n/LocaleCenter.java | 54 ----------------- .../com/fr/design/i18n/LocaleDifference.java | 47 --------------- .../impl/AbstractDefaultLocaleAction.java | 60 ------------------- .../design/i18n/impl/ChinaLocaleAction.java | 22 ------- .../design/i18n/impl/JapanLocaleAction.java | 34 ----------- .../design/i18n/impl/KoreaLocaleAction.java | 17 ------ .../design/i18n/impl/TaiWanLocaleAction.java | 28 --------- .../fr/design/i18n/impl/USLocaleAction.java | 28 --------- .../mainframe/toolbar/ToolBarMenuDock.java | 13 ++-- .../com/fr/grid/GridCornerMouseHandler.java | 2 + .../start/CollectUserInformationDialog.java | 22 ++++++- .../main/java/com/fr/start/SplashContext.java | 15 +++-- 15 files changed, 47 insertions(+), 370 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/Action.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/ActionType.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java delete mode 100644 designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java diff --git a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java index e405f3bb5..7fa6314d6 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java @@ -1,15 +1,15 @@ package com.fr.design.actions.community; +import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; -import com.fr.design.i18n.ActionType; -import com.fr.design.i18n.LocaleCenter; import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; +import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; -import com.fr.general.IOUtils; import javax.swing.*; import java.awt.event.ActionEvent; +import java.util.Locale; public class VideoAction extends UpdateAction { @@ -19,14 +19,20 @@ public class VideoAction extends UpdateAction this.setMenuKeySet(VIDEO); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/video.png")); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/video.png")); } @Override public void actionPerformed(ActionEvent arg0) { - BrowseUtils.browser(LocaleCenter.getInstance().getLocaleAction().getUrls().get(ActionType.VIDEO)); + String url; + if (GeneralContext.getLocale().equals(Locale.US)) { + url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); + } else { + url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); + } + BrowseUtils.browser(url); } public static final MenuKeySet VIDEO = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/i18n/Action.java b/designer-base/src/main/java/com/fr/design/i18n/Action.java deleted file mode 100644 index a976ae4b7..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/Action.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fr.design.i18n; - -/** - * 包装一些动作 - * @author Hades - * @date 2019/6/4 - */ -public interface Action { - - Action EMPTY_ACTION = new Action() { - @Override - public void todo() { - // do nothing - } - }; - - /** - * 具体动作 - */ - void todo(); -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/ActionType.java b/designer-base/src/main/java/com/fr/design/i18n/ActionType.java deleted file mode 100644 index 724d3df66..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/ActionType.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.fr.design.i18n; - -/** - * 不同语言环境下的action - * - * @author Hades - * @date 2019/5/30 - */ -public enum ActionType { - - /** - * 视频教学 - */ - VIDEO("video"), - - /** - * 激活码 - */ - ACTIVATION_CODE("activationCode"), - - /** - * 帮助文档 - */ - HELP_DOCUMENT("helpDocument"), - - /** - * 论坛 - */ - BBS("bbs"); - - - private String description; - - ActionType(String description) { - this.description = description; - } - -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java deleted file mode 100644 index 20bc09611..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.fr.design.i18n; - -import com.fr.design.DesignerEnvManager; -import com.fr.design.i18n.impl.ChinaLocaleAction; -import com.fr.design.i18n.impl.JapanLocaleAction; -import com.fr.design.i18n.impl.KoreaLocaleAction; -import com.fr.design.i18n.impl.TaiWanLocaleAction; -import com.fr.design.i18n.impl.USLocaleAction; -import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralContext; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * 不同语言环境的动作管理 - * - * @author Hades - * @date 2019/5/30 - */ -public class LocaleCenter { - - private Map actionMap = new HashMap(); - - private LocaleCenter() { - init(); - } - - private void init() { - actionMap.put(Locale.CHINA, new ChinaLocaleAction()); - actionMap.put(Locale.US, new USLocaleAction()); - actionMap.put(Locale.TAIWAN, new TaiWanLocaleAction()); - actionMap.put(Locale.JAPAN, new JapanLocaleAction()); - actionMap.put(Locale.KOREA, new KoreaLocaleAction()); - } - - private static class Holder { - private static final LocaleCenter INSTANCE = new LocaleCenter(); - } - - public static LocaleCenter getInstance() { - return Holder.INSTANCE; - } - - public LocaleDifference getLocaleAction() { - Locale locale = GeneralContext.getLocale(); - if (!ComparatorUtils.equals(locale, DesignerEnvManager.getEnvManager().getLanguage())) { - locale = DesignerEnvManager.getEnvManager().getLanguage(); - } - LocaleDifference localeDifference = actionMap.get(locale); - return localeDifference == null ? actionMap.get(Locale.CHINA) : localeDifference; - } -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java b/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java deleted file mode 100644 index d18ef8b9f..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fr.design.i18n; - -import java.util.List; -import java.util.Locale; -import java.util.Map; - -/** - * 国际化之间有不同表现的动作 - * - * @author Hades - * @date 2019/5/30 - */ -public interface LocaleDifference { - - /** - * 返回该国际化所有的url - * @return url - */ - Map getUrls(); - - - /** - * 哪些国际化需要执行该动作 - * @param locales - */ - void doAction(Locale ...locales); - - /** - * 构建具体的动作 - * @param action - * @return - */ - LocaleDifference buildAction(Action action); - - /** - * 返回设计器启动画面路径 - * @return 路径 - */ - String getSplashPath(); - - /** - * 对应的国际化 - * @return - */ - Locale getLocale(); - -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java deleted file mode 100644 index 9ed01d31d..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.fr.design.i18n.impl; - -import com.fr.design.i18n.Action; -import com.fr.design.i18n.LocaleDifference; -import com.fr.design.i18n.ActionType; -import com.fr.general.CloudCenter; -import com.fr.general.ComparatorUtils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.EnumMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -/** - * 一些默认的实现 - * - * @author Hades - * @date 2019/5/30 - */ -public abstract class AbstractDefaultLocaleAction implements LocaleDifference { - - protected EnumMap urls = new EnumMap(ActionType.class); - private Action action = Action.EMPTY_ACTION; - - protected void init() { - urls.put(ActionType.BBS, CloudCenter.getInstance().acquireUrlByKind("bbs")); - urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video")); - urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.cn")); - urls.put(ActionType.HELP_DOCUMENT, CloudCenter.getInstance().acquireUrlByKind("help.zh_CN.10")); - } - - @Override - public Map getUrls() { - if (urls.isEmpty()) { - init(); - } - return urls; - } - - @Override - public void doAction(Locale ...locales) { - List localeList = Arrays.asList(locales); - if (localeList.contains(this.getLocale())) { - action.todo(); - } - } - - @Override - public LocaleDifference buildAction(Action action) { - this.action = action; - return this; - } - - @Override - public String getSplashPath() { - return "/com/fr/design/images/splash_10_en.gif"; - } -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java deleted file mode 100644 index d2fc2c7f9..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.fr.design.i18n.impl; - -import java.util.Locale; - -/** - * 简体中文环境具体的表现动作 - * - * @author Hades - * @date 2019/5/30 - */ -public class ChinaLocaleAction extends AbstractDefaultLocaleAction { - - @Override - public String getSplashPath() { - return "/com/fr/design/images/splash_10.gif"; - } - - @Override - public Locale getLocale() { - return Locale.CHINA; - } -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java deleted file mode 100644 index 81614bbb8..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.fr.design.i18n.impl; - -import com.fr.design.i18n.ActionType; -import com.fr.general.CloudCenter; - -import java.util.Locale; - -/** - * 日文环境具体的表现动作 - * - * @author Hades - * @date 2019/5/30 - */ -public class JapanLocaleAction extends AbstractDefaultLocaleAction { - - @Override - protected void init() { - super.init(); - urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.jp")); - } - - - @Override - public String getSplashPath() { - return "/com/fr/design/images/splash_10_jp.gif"; - } - - @Override - public Locale getLocale() { - return Locale.JAPAN; - } - - -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java deleted file mode 100644 index 5a5e9b8ed..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fr.design.i18n.impl; - -import java.util.Locale; - -/** - * 韩文环境具体的表现动作 - * - * @author Hades - * @date 2019/5/30 - */ -public class KoreaLocaleAction extends AbstractDefaultLocaleAction { - - @Override - public Locale getLocale() { - return Locale.KOREA; - } -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java deleted file mode 100644 index f9e8df2af..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fr.design.i18n.impl; - -import com.fr.design.i18n.ActionType; -import com.fr.general.CloudCenter; - -import java.util.List; -import java.util.Locale; - -/** - * 繁体中文具体的表现动作 - * - * @author Hades - * @date 2019/5/30 - */ -public class TaiWanLocaleAction extends AbstractDefaultLocaleAction { - - @Override - protected void init() { - super.init(); - urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video.zh_TW")); - urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.tw")); - } - - @Override - public Locale getLocale() { - return Locale.TAIWAN; - } -} diff --git a/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java b/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java deleted file mode 100644 index 4acfc3db1..000000000 --- a/designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.fr.design.i18n.impl; - -import com.fr.design.i18n.ActionType; -import com.fr.general.CloudCenter; - -import java.util.Locale; - -/** - * 英文环境具体的表现动作 - * - * @author Hades - * @date 2019/5/30 - */ -public class USLocaleAction extends AbstractDefaultLocaleAction { - - @Override - protected void init() { - super.init(); - urls.put(ActionType.VIDEO, CloudCenter.getInstance().acquireUrlByKind("bbs.video.en")); - urls.put(ActionType.HELP_DOCUMENT, CloudCenter.getInstance().acquireUrlByKind("help.en_US.10")); - urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.en")); - } - - @Override - public Locale getLocale() { - return Locale.US; - } -} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 3fad25f6f..7e0d6b359 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -47,8 +47,6 @@ import com.fr.design.gui.imenu.UIMenu; import com.fr.design.gui.imenu.UIMenuBar; import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.gui.itoolbar.UIToolbar; -import com.fr.design.i18n.Action; -import com.fr.design.i18n.LocaleCenter; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.ToolBarNewTemplatePane; import com.fr.design.menu.MenuDef; @@ -534,7 +532,7 @@ public abstract class ToolBarMenuDock { * @return 社区菜单的子菜单 */ public ShortCut[] createCommunityShortCuts() { - final java.util.List shortCuts = new ArrayList(); + java.util.List shortCuts = new ArrayList(); shortCuts.add(new BBSAction()); shortCuts.add(new VideoAction()); shortCuts.add(new TutorialAction()); @@ -545,12 +543,9 @@ public abstract class ToolBarMenuDock { shortCuts.add(new CusDemandAction()); shortCuts.add(new CenterAction()); shortCuts.add(new SignAction()); - LocaleCenter.getInstance().getLocaleAction().buildAction(new Action() { - @Override - public void todo() { - shortCuts.add(new FacebookFansAction()); - } - }).doAction(Locale.TAIWAN); + if (Locale.TAIWAN.equals(GeneralContext.getLocale())) { + shortCuts.add(new FacebookFansAction()); + } return shortCuts.toArray(new ShortCut[shortCuts.size()]); } diff --git a/designer-realize/src/main/java/com/fr/grid/GridCornerMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/GridCornerMouseHandler.java index 4c4342291..e68bd907b 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridCornerMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/GridCornerMouseHandler.java @@ -29,6 +29,8 @@ public class GridCornerMouseHandler extends MouseInputAdapter { private void doSelectAll() { ElementCasePane reportPane = this.gridCorner.getElementCasePane(); + // 全选时,停止编辑状态 + reportPane.getGrid().stopEditing(); ColumnRow lastColumnRow = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane); reportPane.setSelection(new CellSelection(0, 0, lastColumnRow.getColumn(), lastColumnRow.getRow())); diff --git a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java index 1ec071281..c32c2307d 100644 --- a/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java +++ b/designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java @@ -7,11 +7,11 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.i18n.ActionType; -import com.fr.design.i18n.LocaleCenter; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ActiveKeyGenerator; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.CloudCenter; +import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import javax.swing.*; @@ -31,6 +31,11 @@ public class CollectUserInformationDialog extends UIDialog { private static final int ONLINE_VERIFY_TIMEOUT = 30 * 1000; + private static final String CN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.cn"); + private static final String EN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.en"); + private static final String TW_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.tw"); + private static final String JP_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.jp"); + private UITextField keyTextField; private ActionListener actionListener = new ActionListener() { @@ -124,8 +129,19 @@ public class CollectUserInformationDialog extends UIDialog { private void getKeyAction() { + Locale locale = GeneralContext.getLocale(); + String url = EN_LOGIN_HTML; + if (ComparatorUtils.equals(locale, Locale.TAIWAN)) { + url = TW_LOGIN_HTML; + } + if (ComparatorUtils.equals(locale, Locale.CHINA)) { + url = CN_LOGIN_HTML; + } + if (ComparatorUtils.equals(locale, Locale.JAPAN)) { + url = JP_LOGIN_HTML; + } try { - Desktop.getDesktop().browse(new URI(LocaleCenter.getInstance().getLocaleAction().getUrls().get(ActionType.ACTIVATION_CODE))); + Desktop.getDesktop().browse(new URI(url)); } catch (Exception ignored) { } diff --git a/designer-realize/src/main/java/com/fr/start/SplashContext.java b/designer-realize/src/main/java/com/fr/start/SplashContext.java index 9fcdad122..441bf0f60 100644 --- a/designer-realize/src/main/java/com/fr/start/SplashContext.java +++ b/designer-realize/src/main/java/com/fr/start/SplashContext.java @@ -1,6 +1,6 @@ package com.fr.start; -import com.fr.design.i18n.LocaleCenter; +import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; public class SplashContext { public static final String SPLASH_PATH = getSplashPath(); - public static final String SPLASH_CACHE_NAME = SPLASH_PATH.substring(SPLASH_PATH.lastIndexOf('/') + 1); + public static final String SPLASH_CACHE_NAME = SPLASH_PATH.substring(SPLASH_PATH.lastIndexOf("/") + 1); private static final int FETCH_ONLINE_MAX_TIMES = 50; private static final SplashContext SPLASH_CONTEXT = new SplashContext(); @@ -166,6 +166,13 @@ public class SplashContext { } private static String getSplashPath() { - return LocaleCenter.getInstance().getLocaleAction().getSplashPath(); + Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); + if (Locale.US.equals(locale) || Locale.KOREA.equals(locale) || Locale.TAIWAN.equals(locale)) { + return "/com/fr/design/images/splash_10_en.gif"; + } else if (Locale.JAPAN.equals(locale)) { + return "/com/fr/design/images/splash_10_jp.gif"; + } else { + return "/com/fr/design/images/splash_10.gif"; + } } -} +} \ No newline at end of file From 7d209fba578597d85cd0e2709a1e73ebf62cf85a Mon Sep 17 00:00:00 2001 From: Hades Date: Wed, 5 Jun 2019 09:40:43 +0800 Subject: [PATCH 4/4] update --- .../main/java/com/fr/design/actions/community/VideoAction.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java index 7fa6314d6..4fabbd6da 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java @@ -6,6 +6,7 @@ import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.event.ActionEvent; @@ -19,7 +20,7 @@ public class VideoAction extends UpdateAction this.setMenuKeySet(VIDEO); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/video.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/video.png")); }