From 63cf9064fe8b4e2032908cf60f5f9cb6e505b062 Mon Sep 17 00:00:00 2001 From: Hades Date: Wed, 5 Jun 2019 09:38:04 +0800 Subject: [PATCH] =?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