diff --git a/designer-base/src/main/java/com/fr/design/i18n/DesignI18nImpl.java b/designer-base/src/main/java/com/fr/design/i18n/DesignI18nImpl.java new file mode 100644 index 0000000000..af759aa3bf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/DesignI18nImpl.java @@ -0,0 +1,71 @@ +package com.fr.design.i18n; + +import com.fr.general.GeneralContext; +import com.fr.general.log.MessageFormatter; +import com.fr.locale.DesignI18nProvider; +import com.fr.locale.InterProviderFactory; +import com.fr.locale.LocaleBundle; +import com.fr.locale.LocaleFiles; +import com.fr.locale.LocaleManager; +import com.fr.locale.impl.FineLocaleManager; + +import java.util.List; +import java.util.Locale; + +public class DesignI18nImpl implements DesignI18nProvider { + + private static DesignI18nImpl instance = new DesignI18nImpl(); + + public static DesignI18nImpl getInstance() { + return instance; + } + + private LocaleManager localeManager = FineLocaleManager.create(); + + private DesignI18nImpl() { + addResource("com/fr/design/i18n/main"); + InterProviderFactory.registerDesignI18nProvider(this); + } + + @Override + public String i18nText(String key) { + return localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, key); + } + + @Override + public String i18nText(String key, Object... args) { + String format = InterProviderFactory.getProvider().getLocText(key); + MessageFormatter.FormattingTuple tuple = MessageFormatter.arrayFormat(format, args); + return localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, tuple.getMessage()); + } + + @Override + public void addResource(String path) { + localeManager.addResource(path); + } + + @Override + public void removeResource(String path) { + localeManager.removeResource(path); + } + + @Override + public LocaleBundle getLocalBundle(Locale locale) { + return localeManager.getLocalBundle(locale); + } + + @Override + public List getReverseList() { + return localeManager.getReverseList(); + } + + @Override + public List getList() { + return localeManager.getList(); + } + + @Override + public void clear() { + localeManager.clear(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/Toolkit.java b/designer-base/src/main/java/com/fr/design/i18n/Toolkit.java index 79bb37bb09..d912c7b2d9 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/Toolkit.java +++ b/designer-base/src/main/java/com/fr/design/i18n/Toolkit.java @@ -1,27 +1,12 @@ package com.fr.design.i18n; -import com.fr.general.GeneralContext; -import com.fr.general.log.MessageFormatter; import com.fr.locale.InterProviderFactory; -import com.fr.locale.LocaleManager; -import com.fr.locale.impl.FineLocaleManager; /** * 设计器国际化类,后面会不再依赖InterProviderFactory */ public class Toolkit { - private static LocaleManager localeManager = FineLocaleManager.create(); - - static { - addResource("com/fr/design/i18n/main"); - } - - public static void addResource(String path) { - - localeManager.addResource(path); - } - /** * 设计器国际化方法 * @@ -29,7 +14,7 @@ public class Toolkit { * @return 国际化值 */ public static String i18nText(String key) { - return localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, key); + return DesignI18nImpl.getInstance().i18nText(key); } /** @@ -41,9 +26,7 @@ public class Toolkit { * @return 国际化值 */ public static String i18nText(String key, Object... args) { - String format = InterProviderFactory.getProvider().getLocText(key); - MessageFormatter.FormattingTuple tuple = MessageFormatter.arrayFormat(format, args); - return localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, tuple.getMessage()); + return DesignI18nImpl.getInstance().i18nText(key, args); } /** diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 4635b22f62..fd7cdbab20 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -24,6 +24,7 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetHelpDialog; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.event.Listener; +import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; @@ -168,8 +169,14 @@ public class XWCardMainBorderLayout extends XWBorderLayout { //新tab默认都有标题 borderStyle.setType(LayoutBorderStyle.TITLE); } - cardLayout.setWidgetName(XWCardLayout.DEFAULT_NAME + tabpaneName.replaceAll(XWCardTagLayout.DEFAULT_NAME, "")); - wCardTitleLayout.setCardName(cardLayout.getWidgetName()); + String newCardLayoutName = XWCardLayout.DEFAULT_NAME + tabpaneName.replaceAll(XWCardTagLayout.DEFAULT_NAME, ""); + cardLayout.setWidgetName(newCardLayoutName); + //修改cardswitchbutton所绑定的cardlayoutname + for (int i = 0, len = wCardTagLayout.getWidgetCount(); i < len; i++) { + CardSwitchButton button = wCardTagLayout.getSwitchButton(i); + button.setCardLayoutName(newCardLayoutName); + } + wCardTitleLayout.setCardName(newCardLayoutName); wCardTagLayout.setNewTab(true); //这边需要设置成默认值兼容之前的title高度(不知道为啥之前的title的高度会改变) if(this.toData().getNorthSize() != 0){ diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index bac7d72476..2b5e5ab621 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -27,7 +27,7 @@ import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.hyperlink.ReportletHyperlinkPane; import com.fr.design.hyperlink.WebHyperlinkPane; -import com.fr.design.i18n.Toolkit; +import com.fr.design.i18n.DesignI18nImpl; import com.fr.design.javascript.EmailPane; import com.fr.design.javascript.JavaScriptImplPane; import com.fr.design.javascript.ParameterJavaScriptPane; @@ -124,7 +124,7 @@ public class DesignerActivator extends Activator { List markers = rightCollectMutable(InterMutableKey.Path); for (LocaleMarker marker : markers) { if (marker.match(LocaleScope.DESIGN)) { - Toolkit.addResource(marker.getPath()); + DesignI18nImpl.getInstance().addResource(marker.getPath()); } } designerModuleStart();