Browse Source

KERNEL-582 国际化定制的地方会越来越多,想办法去掉这种if else写法 && REPORT-18522 将所有海外版设计器的信息回传功能阉割

bugfix/10.0
Hades 5 years ago
parent
commit
4e218c7456
  1. 6
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 18
      designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java
  3. 31
      designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java
  4. 35
      designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java
  5. 36
      designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java
  6. 35
      designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java
  7. 27
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  8. 22
      designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java
  9. 14
      designer-realize/src/main/java/com/fr/start/SplashContext.java

6
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -14,6 +14,7 @@ import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.locale.impl.ProductImproveMark;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.update.push.DesignerPushUpdateConfigManager;
import com.fr.design.style.color.ColorSelectConfigManager;
@ -23,6 +24,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import com.fr.general.xml.GeneralXMLTools;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
@ -688,7 +691,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @return 是否加入产品改良
*/
public boolean isJoinProductImprove() {
return Locale.CHINA.equals(GeneralContext.getLocale()) && this.joinProductImprove;
LocaleMark<Boolean> localeMark = LocaleCenter.getMark(ProductImproveMark.class);
return localeMark.getValue() && this.joinProductImprove;
}
/**

18
designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java

@ -1,16 +1,16 @@
package com.fr.design.actions.community;
import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.locale.impl.VideoMark;
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 com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.Locale;
public class VideoAction extends UpdateAction
{
@ -27,14 +27,8 @@ public class VideoAction extends UpdateAction
@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);
LocaleMark<String> localeMark = LocaleCenter.getMark(VideoMark.class);
BrowseUtils.browser(localeMark.getValue());
}
public static final MenuKeySet VIDEO = new MenuKeySet() {
@Override

31
designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java

@ -0,0 +1,31 @@
package com.fr.design.locale.impl;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author Hades
* @date 2019/6/24
*/
public class ProductImproveMark implements LocaleMark<Boolean> {
private Map<Locale, Boolean> map = new HashMap<>();
public ProductImproveMark() {
map.put(Locale.CHINA, true);
map.put(Locale.TAIWAN, false);
map.put(Locale.US, false);
map.put(Locale.KOREA, false);
map.put(Locale.JAPAN, false);
}
@Override
public Boolean getValue() {
Boolean result = map.get(GeneralContext.getLocale());
return result == null ? false : result;
}
}

35
designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java

@ -0,0 +1,35 @@
package com.fr.design.locale.impl;
import com.fr.design.DesignerEnvManager;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author Hades
* @date 2019/6/24
*/
public class SplashMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<Locale, String>();
private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif";
private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_10_en.gif";
private static final String SPLASH_JP_PATH = "/com/fr/design/images/splash_10_jp.gif";
public SplashMark() {
map.put(Locale.CHINA, SPLASH_PATH);
map.put(Locale.KOREA, SPLASH_EN_PATH);
map.put(Locale.JAPAN, SPLASH_JP_PATH);
map.put(Locale.US, SPLASH_EN_PATH);
map.put(Locale.TAIWAN, SPLASH_EN_PATH);
}
@Override
public String getValue() {
String result = map.get(DesignerEnvManager.getEnvManager().getLanguage());
return result == null ? SPLASH_EN_PATH : result;
}
}

36
designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java

@ -0,0 +1,36 @@
package com.fr.design.locale.impl;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author Hades
* @date 2019/6/24
*/
public class UserInfoMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<>();
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");
public UserInfoMark() {
map.put(Locale.CHINA, CN_LOGIN_HTML);
map.put(Locale.KOREA, EN_LOGIN_HTML);
map.put(Locale.JAPAN, JP_LOGIN_HTML);
map.put(Locale.US, EN_LOGIN_HTML);
map.put(Locale.TAIWAN, TW_LOGIN_HTML);
}
@Override
public String getValue() {
String result = map.get(GeneralContext.getLocale());
return result == null ? EN_LOGIN_HTML : result;
}
}

35
designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java

@ -0,0 +1,35 @@
package com.fr.design.locale.impl;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author Hades
* @date 2019/6/24
*/
public class VideoMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<>();
private static final String VIDEO_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en");
private static final String VIDEO_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.video");
private static final String VIDEO_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.video.tw");
public VideoMark() {
map.put(Locale.CHINA, VIDEO_CN);
map.put(Locale.KOREA, VIDEO_EN);
map.put(Locale.JAPAN, VIDEO_EN);
map.put(Locale.US, VIDEO_EN);
map.put(Locale.TAIWAN, VIDEO_TW);
}
@Override
public String getValue() {
String result = map.get(GeneralContext.getLocale());
return result == null ? VIDEO_EN : result;
}
}

27
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -58,6 +58,9 @@ import com.fr.design.remote.action.RemoteDesignAuthManagerAction;
import com.fr.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleAction;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.impl.SupportLocaleImpl;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginRuntime;
@ -240,7 +243,7 @@ public abstract class ToolBarMenuDock {
public MenuDef[] menus(final ToolBarMenuDockPlus plus) {
//删除之前创建的插件菜单监听
clearPluginListeners();
java.util.List<MenuDef> menuList = new java.util.ArrayList<MenuDef>();
final java.util.List<MenuDef> menuList = new java.util.ArrayList<MenuDef>();
// 添加文件菜单
menuList.add(createFileMenuDef(plus));
@ -258,10 +261,13 @@ public abstract class ToolBarMenuDock {
// 添加帮助菜单
menuList.add(createHelpMenuDef());
if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)) {
// 添加社区菜单
addCommunityMenuDef(menuList);
}
LocaleCenter.buildAction(new LocaleAction() {
@Override
public void execute() {
addCommunityMenuDef(menuList);
}
}, SupportLocaleImpl.COMMUNITY);
// 添加全部UpdateAction到actionmanager中
addAllUpdateActionsToList(menuList);
@ -532,7 +538,7 @@ public abstract class ToolBarMenuDock {
* @return 社区菜单的子菜单
*/
public ShortCut[] createCommunityShortCuts() {
java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>();
final java.util.List<ShortCut> shortCuts = new ArrayList<ShortCut>();
shortCuts.add(new BBSAction());
shortCuts.add(new VideoAction());
shortCuts.add(new TutorialAction());
@ -543,9 +549,12 @@ 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.buildAction(new LocaleAction() {
@Override
public void execute() {
shortCuts.add(new FacebookFansAction());
}
}, SupportLocaleImpl.FACEBOOK);
return shortCuts.toArray(new ShortCut[shortCuts.size()]);
}

22
designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java

@ -8,11 +8,14 @@ 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.layout.FRGUIPaneFactory;
import com.fr.design.locale.impl.UserInfoMark;
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 com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import javax.swing.*;
import javax.swing.border.TitledBorder;
@ -31,11 +34,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() {
@ -129,19 +127,9 @@ 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;
}
LocaleMark<String> localeMark = LocaleCenter.getMark(UserInfoMark.class);
try {
Desktop.getDesktop().browse(new URI(url));
Desktop.getDesktop().browse(new URI(localeMark.getValue()));
} catch (Exception ignored) {
}

14
designer-realize/src/main/java/com/fr/start/SplashContext.java

@ -1,12 +1,14 @@
package com.fr.start;
import com.fr.design.DesignerEnvManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.locale.impl.SplashMark;
import com.fr.design.mainframe.bbs.BBSConstants;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import com.fr.module.ModuleEvent;
import com.fr.stable.StringUtils;
@ -168,13 +170,7 @@ 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";
}
LocaleMark<String> localeMark = LocaleCenter.getMark(SplashMark.class);
return localeMark.getValue();
}
}
Loading…
Cancel
Save