Browse Source

update

bugfix/10.0
Hades 6 years ago
parent
commit
bfc341f3b0
  1. 2
      designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java
  2. 21
      designer-base/src/main/java/com/fr/design/i18n/Action.java
  3. 6
      designer-base/src/main/java/com/fr/design/i18n/ActionType.java
  4. 15
      designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java
  5. 23
      designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java
  6. 27
      designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java
  7. 13
      designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java
  8. 13
      designer-base/src/main/java/com/fr/design/i18n/impl/JapanLocaleAction.java
  9. 11
      designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java
  10. 11
      designer-base/src/main/java/com/fr/design/i18n/impl/TaiWanLocaleAction.java
  11. 12
      designer-base/src/main/java/com/fr/design/i18n/impl/USLocaleAction.java
  12. 10
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  13. 3
      designer-realize/src/main/java/com/fr/start/CollectUserInformationDialog.java
  14. 5
      designer-realize/src/main/java/com/fr/start/SplashContext.java

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

@ -26,7 +26,7 @@ public class VideoAction extends UpdateAction
@Override @Override
public void actionPerformed(ActionEvent arg0) 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() { public static final MenuKeySet VIDEO = new MenuKeySet() {

21
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();
}

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

@ -1,5 +1,11 @@
package com.fr.design.i18n; package com.fr.design.i18n;
/**
* 不同语言环境下的action
*
* @author Hades
* @date 2019/5/30
*/
public enum ActionType { public enum ActionType {
/** /**

15
designer-base/src/main/java/com/fr/design/i18n/LocaleCenter.java

@ -1,15 +1,24 @@
package com.fr.design.i18n; package com.fr.design.i18n;
import com.fr.design.DesignerEnvManager;
import com.fr.design.i18n.impl.ChinaLocaleAction; import com.fr.design.i18n.impl.ChinaLocaleAction;
import com.fr.design.i18n.impl.JapanLocaleAction; import com.fr.design.i18n.impl.JapanLocaleAction;
import com.fr.design.i18n.impl.KoreaLocaleAction; import com.fr.design.i18n.impl.KoreaLocaleAction;
import com.fr.design.i18n.impl.TaiWanLocaleAction; import com.fr.design.i18n.impl.TaiWanLocaleAction;
import com.fr.design.i18n.impl.USLocaleAction; import com.fr.design.i18n.impl.USLocaleAction;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
/**
* 不同语言环境的动作管理
*
* @author Hades
* @date 2019/5/30
*/
public class LocaleCenter { public class LocaleCenter {
private Map<Locale, LocaleDifference> actionMap = new HashMap<Locale, LocaleDifference>(); private Map<Locale, LocaleDifference> actionMap = new HashMap<Locale, LocaleDifference>();
@ -34,7 +43,11 @@ public class LocaleCenter {
return Holder.INSTANCE; 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); LocaleDifference localeDifference = actionMap.get(locale);
return localeDifference == null ? actionMap.get(Locale.CHINA) : localeDifference; return localeDifference == null ? actionMap.get(Locale.CHINA) : localeDifference;
} }

23
designer-base/src/main/java/com/fr/design/i18n/LocaleDifference.java

@ -1,10 +1,14 @@
package com.fr.design.i18n; package com.fr.design.i18n;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
/** /**
* 国际化之间有不同表现的动作 * 国际化之间有不同表现的动作
*
* @author Hades
* @date 2019/5/30
*/ */
public interface LocaleDifference { public interface LocaleDifference {
@ -16,11 +20,17 @@ public interface LocaleDifference {
/** /**
* 添加Action * 哪些国际化需要执行该动作
* @param list 列表 * @param locales
* @param action 对应action
*/ */
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(); String getSplashPath();
/**
* 对应的国际化
* @return
*/
Locale getLocale();
} }

27
designer-base/src/main/java/com/fr/design/i18n/impl/AbstractDefaultLocaleAction.java

@ -1,16 +1,28 @@
package com.fr.design.i18n.impl; package com.fr.design.i18n.impl;
import com.fr.design.i18n.Action;
import com.fr.design.i18n.LocaleDifference; import com.fr.design.i18n.LocaleDifference;
import com.fr.design.i18n.ActionType; import com.fr.design.i18n.ActionType;
import com.fr.general.CloudCenter; 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.EnumMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
/**
* 一些默认的实现
*
* @author Hades
* @date 2019/5/30
*/
public abstract class AbstractDefaultLocaleAction implements LocaleDifference { public abstract class AbstractDefaultLocaleAction implements LocaleDifference {
protected EnumMap<ActionType, String> urls = new EnumMap<ActionType, String>(ActionType.class); protected EnumMap<ActionType, String> urls = new EnumMap<ActionType, String>(ActionType.class);
private Action action = Action.EMPTY_ACTION;
protected void init() { protected void init() {
urls.put(ActionType.BBS, CloudCenter.getInstance().acquireUrlByKind("bbs")); urls.put(ActionType.BBS, CloudCenter.getInstance().acquireUrlByKind("bbs"));
@ -28,14 +40,21 @@ public abstract class AbstractDefaultLocaleAction implements LocaleDifference {
} }
@Override @Override
public void addAction(List list, Object action) { public void doAction(Locale ...locales) {
// do nothing List<Locale> localeList = Arrays.asList(locales);
if (localeList.contains(this.getLocale())) {
action.todo();
}
}
@Override
public LocaleDifference buildAction(Action action) {
this.action = action;
return this;
} }
@Override @Override
public String getSplashPath() { public String getSplashPath() {
return "/com/fr/design/images/splash_10_en.gif"; return "/com/fr/design/images/splash_10_en.gif";
} }
} }

13
designer-base/src/main/java/com/fr/design/i18n/impl/ChinaLocaleAction.java

@ -1,9 +1,22 @@
package com.fr.design.i18n.impl; package com.fr.design.i18n.impl;
import java.util.Locale;
/**
* 简体中文环境具体的表现动作
*
* @author Hades
* @date 2019/5/30
*/
public class ChinaLocaleAction extends AbstractDefaultLocaleAction { public class ChinaLocaleAction extends AbstractDefaultLocaleAction {
@Override @Override
public String getSplashPath() { public String getSplashPath() {
return "/com/fr/design/images/splash_10.gif"; return "/com/fr/design/images/splash_10.gif";
} }
@Override
public Locale getLocale() {
return Locale.CHINA;
}
} }

13
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.design.i18n.ActionType;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import java.util.Locale;
/**
* 日文环境具体的表现动作
*
* @author Hades
* @date 2019/5/30
*/
public class JapanLocaleAction extends AbstractDefaultLocaleAction { public class JapanLocaleAction extends AbstractDefaultLocaleAction {
@Override @Override
@ -17,5 +25,10 @@ public class JapanLocaleAction extends AbstractDefaultLocaleAction {
return "/com/fr/design/images/splash_10_jp.gif"; return "/com/fr/design/images/splash_10_jp.gif";
} }
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
} }

11
designer-base/src/main/java/com/fr/design/i18n/impl/KoreaLocaleAction.java

@ -1,6 +1,17 @@
package com.fr.design.i18n.impl; package com.fr.design.i18n.impl;
import java.util.Locale;
/**
* 韩文环境具体的表现动作
*
* @author Hades
* @date 2019/5/30
*/
public class KoreaLocaleAction extends AbstractDefaultLocaleAction { public class KoreaLocaleAction extends AbstractDefaultLocaleAction {
@Override
public Locale getLocale() {
return Locale.KOREA;
}
} }

11
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 com.fr.general.CloudCenter;
import java.util.List; import java.util.List;
import java.util.Locale;
/**
* 繁体中文具体的表现动作
*
* @author Hades
* @date 2019/5/30
*/
public class TaiWanLocaleAction extends AbstractDefaultLocaleAction { public class TaiWanLocaleAction extends AbstractDefaultLocaleAction {
@Override @Override
@ -15,7 +22,7 @@ public class TaiWanLocaleAction extends AbstractDefaultLocaleAction {
} }
@Override @Override
public void addAction(List list, Object action) { public Locale getLocale() {
list.add(action); return Locale.TAIWAN;
} }
} }

12
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.design.i18n.ActionType;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import java.util.Locale;
/**
* 英文环境具体的表现动作
*
* @author Hades
* @date 2019/5/30
*/
public class USLocaleAction extends AbstractDefaultLocaleAction { public class USLocaleAction extends AbstractDefaultLocaleAction {
@Override @Override
@ -13,4 +21,8 @@ public class USLocaleAction extends AbstractDefaultLocaleAction {
urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.en")); urls.put(ActionType.ACTIVATION_CODE, CloudCenter.getInstance().acquireUrlByKind("frlogin.en"));
} }
@Override
public Locale getLocale() {
return Locale.US;
}
} }

10
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.imenu.UIMenuBar;
import com.fr.design.gui.itoolbar.UILargeToolbar; import com.fr.design.gui.itoolbar.UILargeToolbar;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Action;
import com.fr.design.i18n.LocaleCenter; import com.fr.design.i18n.LocaleCenter;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.ToolBarNewTemplatePane; import com.fr.design.mainframe.ToolBarNewTemplatePane;
@ -533,7 +534,7 @@ public abstract class ToolBarMenuDock {
* @return 社区菜单的子菜单 * @return 社区菜单的子菜单
*/ */
public ShortCut[] createCommunityShortCuts() { 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 BBSAction());
shortCuts.add(new VideoAction()); shortCuts.add(new VideoAction());
shortCuts.add(new TutorialAction()); shortCuts.add(new TutorialAction());
@ -544,7 +545,12 @@ public abstract class ToolBarMenuDock {
shortCuts.add(new CusDemandAction()); shortCuts.add(new CusDemandAction());
shortCuts.add(new CenterAction()); shortCuts.add(new CenterAction());
shortCuts.add(new SignAction()); 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()]); return shortCuts.toArray(new ShortCut[shortCuts.size()]);
} }

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

@ -124,9 +124,8 @@ public class CollectUserInformationDialog extends UIDialog {
private void getKeyAction() { private void getKeyAction() {
Locale locale = GeneralContext.getLocale();
try { 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) { } catch (Exception ignored) {
} }

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

@ -1,6 +1,5 @@
package com.fr.start; package com.fr.start;
import com.fr.design.DesignerEnvManager;
import com.fr.design.i18n.LocaleCenter; import com.fr.design.i18n.LocaleCenter;
import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.design.mainframe.bbs.BBSConstants;
import com.fr.event.Event; import com.fr.event.Event;
@ -25,7 +24,7 @@ import java.util.concurrent.TimeUnit;
public class SplashContext { public class SplashContext {
public static final String SPLASH_PATH = getSplashPath(); 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 int FETCH_ONLINE_MAX_TIMES = 50;
private static final SplashContext SPLASH_CONTEXT = new SplashContext(); private static final SplashContext SPLASH_CONTEXT = new SplashContext();
@ -167,6 +166,6 @@ public class SplashContext {
} }
private static String getSplashPath() { private static String getSplashPath() {
return LocaleCenter.getInstance().getLocaleAction(DesignerEnvManager.getEnvManager().getLanguage()).getSplashPath(); return LocaleCenter.getInstance().getLocaleAction().getSplashPath();
} }
} }

Loading…
Cancel
Save