From 4ab8a7ec1fd12cd7bdf58f6f1c3e77bcd8547705 Mon Sep 17 00:00:00 2001 From: lucian Date: Tue, 23 Feb 2021 09:41:53 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-48228=20=E3=80=9010.0.15=E3=80=91?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E6=8E=A5=E5=8F=A3-=E6=8F=92?= =?UTF-8?q?=E4=BB=B6jar=E5=8C=85=E4=B8=8D=E5=8C=B9=E9=85=8D=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/PluginErrorRemindHandleProvider.java | 19 ++++++++++++ ...stractPluginErrorRemindHandleProvider.java | 30 +++++++++++++++++++ .../com/fr/env/PluginErrorRemindDialog.java | 14 +++++++++ 3 files changed, 63 insertions(+) create mode 100644 designer-base/src/main/java/com/fr/design/fun/PluginErrorRemindHandleProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginErrorRemindHandleProvider.java diff --git a/designer-base/src/main/java/com/fr/design/fun/PluginErrorRemindHandleProvider.java b/designer-base/src/main/java/com/fr/design/fun/PluginErrorRemindHandleProvider.java new file mode 100644 index 000000000..4e1eb44c2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/PluginErrorRemindHandleProvider.java @@ -0,0 +1,19 @@ +package com.fr.design.fun; + +import com.fr.stable.fun.mark.Selectable; + +/** + * 插件不匹配时设计器提示框的“立即处理”事件 + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2021/2/20 + */ +public interface PluginErrorRemindHandleProvider extends Selectable { + + String MARK_STRING = "PluginErrorRemindHandleProvider"; + + int CURRENT_LEVEL = 1; + + // 打开插件管理 + void openPluginManager(); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginErrorRemindHandleProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginErrorRemindHandleProvider.java new file mode 100644 index 000000000..e8f24a753 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginErrorRemindHandleProvider.java @@ -0,0 +1,30 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.PluginErrorRemindHandleProvider; +import com.fr.stable.fun.assist.Selector; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2021/2/20 + */ +@API(level = PluginErrorRemindHandleProvider.CURRENT_LEVEL) +public abstract class AbstractPluginErrorRemindHandleProvider extends AbstractProvider implements PluginErrorRemindHandleProvider { + + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } + + @Override + public Selector selector() { + return Selector.ALWAYS; + } + +} diff --git a/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java b/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java index 42dae0fa1..dbdb21826 100644 --- a/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java +++ b/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java @@ -1,12 +1,15 @@ package com.fr.env; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.server.PluginManagerAction; +import com.fr.design.fun.PluginErrorRemindHandleProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; import com.fr.general.IOUtils; +import com.fr.stable.bridge.ObjectHolder; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -23,6 +26,7 @@ import java.awt.Frame; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Set; /** * 插件启动失败提示窗 @@ -113,6 +117,16 @@ public class PluginErrorRemindDialog extends JDialog implements ActionListener { @Override public void actionPerformed(ActionEvent e) { this.jDialog.dispose(); + // 先从插件找 + Set providers = ExtraDesignClassManager.getInstance().getArray(PluginErrorRemindHandleProvider.MARK_STRING); + if (providers != null) { + for (PluginErrorRemindHandleProvider provider : providers) { + if (provider.selector().accept(new ObjectHolder())) { + provider.openPluginManager(); + return; + } + } + } super.actionPerformed(e); } } From 96896d5f36d4f146d3b8fb0007bdd7c90784634d Mon Sep 17 00:00:00 2001 From: lucian Date: Wed, 24 Feb 2021 10:33:28 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-47901=20=E5=A1=AB=E6=8A=A5-=E5=AF=BC?= =?UTF-8?q?=E5=85=A5excel-=E5=8F=8C=E5=90=91=E6=89=A9=E5=B1=95=E6=98=AF?= =?UTF-8?q?=EF=BC=8C=E8=A1=A8=E5=A4=B4=E9=83=A8=E5=88=86=E6=89=A9=E5=B1=95?= =?UTF-8?q?=EF=BC=8C=E5=A4=9A=E8=A1=8C=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/PluginErrorRemindHandleProvider.java | 19 ----------- .../fr/design/fun/PluginManagerProvider.java | 20 +++++++++++ ...ava => AbstractPluginManagerProvider.java} | 6 ++-- .../mainframe/toolbar/ToolBarMenuDock.java | 16 ++++++++- .../com/fr/env/PluginErrorRemindDialog.java | 33 +++++++++++-------- 5 files changed, 58 insertions(+), 36 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/fun/PluginErrorRemindHandleProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/PluginManagerProvider.java rename designer-base/src/main/java/com/fr/design/fun/impl/{AbstractPluginErrorRemindHandleProvider.java => AbstractPluginManagerProvider.java} (66%) diff --git a/designer-base/src/main/java/com/fr/design/fun/PluginErrorRemindHandleProvider.java b/designer-base/src/main/java/com/fr/design/fun/PluginErrorRemindHandleProvider.java deleted file mode 100644 index 4e1eb44c2..000000000 --- a/designer-base/src/main/java/com/fr/design/fun/PluginErrorRemindHandleProvider.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fr.design.fun; - -import com.fr.stable.fun.mark.Selectable; - -/** - * 插件不匹配时设计器提示框的“立即处理”事件 - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2021/2/20 - */ -public interface PluginErrorRemindHandleProvider extends Selectable { - - String MARK_STRING = "PluginErrorRemindHandleProvider"; - - int CURRENT_LEVEL = 1; - - // 打开插件管理 - void openPluginManager(); -} diff --git a/designer-base/src/main/java/com/fr/design/fun/PluginManagerProvider.java b/designer-base/src/main/java/com/fr/design/fun/PluginManagerProvider.java new file mode 100644 index 000000000..11fcecc2c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/PluginManagerProvider.java @@ -0,0 +1,20 @@ +package com.fr.design.fun; + +import com.fr.design.actions.UpdateAction; +import com.fr.stable.fun.mark.Selectable; + +/** + * 替换插件管理入口 + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2021/2/20 + */ +public interface PluginManagerProvider extends Selectable { + + String MARK_STRING = "PluginManagerProvider"; + + int CURRENT_LEVEL = 1; + + // 插件管理 + UpdateAction pluginManagerAction(); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginErrorRemindHandleProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginManagerProvider.java similarity index 66% rename from designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginErrorRemindHandleProvider.java rename to designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginManagerProvider.java index e8f24a753..cfffd66f4 100644 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginErrorRemindHandleProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPluginManagerProvider.java @@ -1,6 +1,6 @@ package com.fr.design.fun.impl; -import com.fr.design.fun.PluginErrorRemindHandleProvider; +import com.fr.design.fun.PluginManagerProvider; import com.fr.stable.fun.assist.Selector; import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; @@ -10,8 +10,8 @@ import com.fr.stable.fun.mark.API; * @version 10.0 * Created by Lucian.Chen on 2021/2/20 */ -@API(level = PluginErrorRemindHandleProvider.CURRENT_LEVEL) -public abstract class AbstractPluginErrorRemindHandleProvider extends AbstractProvider implements PluginErrorRemindHandleProvider { +@API(level = PluginManagerProvider.CURRENT_LEVEL) +public abstract class AbstractPluginManagerProvider extends AbstractProvider implements PluginManagerProvider { public int currentAPILevel() { return CURRENT_LEVEL; 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 d1abb908b..d9a7ecf3c 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 @@ -41,6 +41,7 @@ import com.fr.design.actions.server.PluginManagerAction; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.OemProcessor; +import com.fr.design.fun.PluginManagerProvider; import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -72,6 +73,7 @@ import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; +import com.fr.stable.bridge.ObjectHolder; import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; import com.fr.start.OemHandler; @@ -489,7 +491,7 @@ public abstract class ToolBarMenuDock { if (!DesignerMode.isAuthorityEditing()) { if (shouldShowPlugin()) { menuDef.addShortCut( - new PluginManagerAction() + createPluginManagerAction() ); } menuDef.addShortCut( @@ -502,6 +504,18 @@ public abstract class ToolBarMenuDock { return menuDef; } + private ShortCut createPluginManagerAction() { + Set providers = ExtraDesignClassManager.getInstance().getArray(PluginManagerProvider.MARK_STRING); + if (providers != null) { + for (PluginManagerProvider provider : providers) { + if (provider.selector().accept(new ObjectHolder())) { + return provider.pluginManagerAction(); + } + } + } + return new PluginManagerAction(); + } + private ShortCut createGlobalTDAction() { TableDataPaneProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TableDataPaneProcessor.XML_TAG); return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction(); diff --git a/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java b/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java index dbdb21826..1558d72e9 100644 --- a/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java +++ b/designer-base/src/main/java/com/fr/env/PluginErrorRemindDialog.java @@ -1,8 +1,9 @@ package com.fr.env; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.actions.UpdateAction; import com.fr.design.actions.server.PluginManagerAction; -import com.fr.design.fun.PluginErrorRemindHandleProvider; +import com.fr.design.fun.PluginManagerProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; @@ -81,7 +82,7 @@ public class PluginErrorRemindDialog extends JDialog implements ActionListener { UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Plugin_Error_Remind_Deal_With")); cancelButton.addActionListener(this); - okButton.addActionListener(new PluginManagerActionAdapter(this)); + okButton.addActionListener(new PluginManagerHandleAction(this)); // 按钮 JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); @@ -106,28 +107,34 @@ public class PluginErrorRemindDialog extends JDialog implements ActionListener { this.dispose(); } - private static class PluginManagerActionAdapter extends PluginManagerAction { + private static class PluginManagerHandleAction extends UpdateAction { private JDialog jDialog; + private UpdateAction pluginManagerAction; - public PluginManagerActionAdapter(JDialog jDialog) { + public PluginManagerHandleAction(JDialog jDialog) { this.jDialog = jDialog; + initPluginManagerAction(); } - @Override - public void actionPerformed(ActionEvent e) { - this.jDialog.dispose(); - // 先从插件找 - Set providers = ExtraDesignClassManager.getInstance().getArray(PluginErrorRemindHandleProvider.MARK_STRING); + private void initPluginManagerAction() { + Set providers = ExtraDesignClassManager.getInstance().getArray(PluginManagerProvider.MARK_STRING); if (providers != null) { - for (PluginErrorRemindHandleProvider provider : providers) { + for (PluginManagerProvider provider : providers) { if (provider.selector().accept(new ObjectHolder())) { - provider.openPluginManager(); - return; + this.pluginManagerAction = provider.pluginManagerAction(); } } } - super.actionPerformed(e); + if (this.pluginManagerAction == null) { + this.pluginManagerAction = new PluginManagerAction(); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + this.jDialog.dispose(); + this.pluginManagerAction.actionPerformed(e); } } From 202b0292698974c1a148ec201a2a7f02356c02d9 Mon Sep 17 00:00:00 2001 From: lucian Date: Wed, 24 Feb 2021 10:56:25 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-48228=20=E6=8F=92=E4=BB=B6=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=9A=84=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=E4=B8=8D?= =?UTF-8?q?=E5=8F=97shouldShowPlugin=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/toolbar/ToolBarMenuDock.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 d9a7ecf3c..33a2aaadf 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 @@ -489,11 +489,7 @@ public abstract class ToolBarMenuDock { } if (!DesignerMode.isAuthorityEditing()) { - if (shouldShowPlugin()) { - menuDef.addShortCut( - createPluginManagerAction() - ); - } + addPluginManagerAction(menuDef); menuDef.addShortCut( new FunctionManagerAction(), new GlobalParameterAction() @@ -504,16 +500,21 @@ public abstract class ToolBarMenuDock { return menuDef; } - private ShortCut createPluginManagerAction() { + private void addPluginManagerAction(MenuDef menuDef) { Set providers = ExtraDesignClassManager.getInstance().getArray(PluginManagerProvider.MARK_STRING); if (providers != null) { for (PluginManagerProvider provider : providers) { if (provider.selector().accept(new ObjectHolder())) { - return provider.pluginManagerAction(); + menuDef.addShortCut(provider.pluginManagerAction()); + return; } } } - return new PluginManagerAction(); + if (shouldShowPlugin()) { + menuDef.addShortCut( + new PluginManagerAction() + ); + } } private ShortCut createGlobalTDAction() { From 4e6e6aabf4e6e29f98814b224ce128107ab2aecc Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 24 Feb 2021 16:16:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-47694=20=E6=B5=B7=E5=A4=96=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E5=B0=BA=E5=AF=B8=E7=BB=9F=E4=B8=80=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/dialog/BasicPane.java | 13 ++- .../fr/design/i18n/DesignSizeI18nManager.java | 57 +++++++++++++ .../fr/design/i18n/dimension_en.properties | 1 + .../fr/design/i18n/dimension_ja_JP.properties | 0 .../fr/design/i18n/dimension_ko_KR.properties | 0 .../fr/design/i18n/dimension_zh.properties | 1 + .../fr/design/i18n/dimension_zh_TW.properties | 0 .../i18n/DesignSizeI18nManagerTest.java | 80 +++++++++++++++++++ 8 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/i18n/DesignSizeI18nManager.java create mode 100644 designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties create mode 100644 designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties create mode 100644 designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties create mode 100644 designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties create mode 100644 designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties create mode 100644 designer-base/src/test/java/com/fr/design/i18n/DesignSizeI18nManagerTest.java diff --git a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java index e684d81f6..930dde76c 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java @@ -3,6 +3,7 @@ package com.fr.design.dialog; import com.fr.common.annotations.Open; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.DesignSizeI18nManager; import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.core.PropertyChangeAdapter; @@ -33,7 +34,7 @@ public abstract class BasicPane extends JPanel { * @return 对话框 */ public BasicDialog showWindow(Window window, DialogActionListener l) { - return showWindowWithCustomSize(window, l, BasicDialog.DEFAULT); + return showWindowWithCustomSize(window, l, DesignSizeI18nManager.getInstance().i18nDimension(this.i18nText4PopupWindow())); } /** @@ -236,6 +237,14 @@ public abstract class BasicPane extends JPanel { return title4PopupWindow(); } + /** + * 国际化标识 + * @return 默认是取当前类的全限定名 + */ + protected String i18nText4PopupWindow() { + return this.getClass().getName(); + } + /** * 作为名字面板 * @@ -403,4 +412,4 @@ public abstract class BasicPane extends JPanel { } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/i18n/DesignSizeI18nManager.java b/designer-base/src/main/java/com/fr/design/i18n/DesignSizeI18nManager.java new file mode 100644 index 000000000..1dd2306b8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/i18n/DesignSizeI18nManager.java @@ -0,0 +1,57 @@ +package com.fr.design.i18n; + +import com.fr.design.dialog.BasicDialog; +import com.fr.general.GeneralContext; +import com.fr.locale.LocaleManager; +import com.fr.locale.impl.FineLocaleManager; + +import java.awt.Dimension; +import java.util.Map; + +/** + * Created by kerry on 2/23/21 + */ +public class DesignSizeI18nManager { + private static final String I18N_DIMENSION_PATH = "com/fr/design/i18n/dimension"; + private static final String DIMENSION_REGEX = "^[1-9]\\d*\\*[1-9]\\d*$"; + private static final String SEPARATOR_REGEX = "\\*"; + private static final int WIDTH_INDEX = 0; + private static final int HEIGHT_INDEX = 1; + private static final int SPLIT_LENGTH = 2; + + private static DesignSizeI18nManager instance = new DesignSizeI18nManager(); + + public static DesignSizeI18nManager getInstance() { + return instance; + } + + private LocaleManager localeManager = FineLocaleManager.create(); + + private DesignSizeI18nManager() { + localeManager.addResource(I18N_DIMENSION_PATH); + } + + public Dimension i18nDimension(String key) { + if (!containKey(key)) { + return BasicDialog.DEFAULT; + } + String dimension = localeManager.getLocalBundle(GeneralContext.getLocale()).getText(localeManager, key); + return parseDimensionFromText(dimension); + } + + private boolean containKey(String key) { + Map localeKV = localeManager.getLocalBundle(GeneralContext.getLocale()).getKV(localeManager); + return localeKV != null && localeKV.containsKey(key); + } + + private Dimension parseDimensionFromText(String dimensionText) { + if (!dimensionText.matches(DIMENSION_REGEX)) { + return BasicDialog.DEFAULT; + } + String[] arr = dimensionText.split(SEPARATOR_REGEX); + if (arr.length < SPLIT_LENGTH) { + return BasicDialog.DEFAULT; + } + return new Dimension(Integer.parseInt(arr[WIDTH_INDEX]), Integer.parseInt(arr[HEIGHT_INDEX])); + } +} diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties new file mode 100644 index 000000000..1cafa6d35 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties @@ -0,0 +1 @@ +com.fr.design.report.ReportColumnsPane=800*600 diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties new file mode 100644 index 000000000..e69de29bb diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties new file mode 100644 index 000000000..e69de29bb diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties new file mode 100644 index 000000000..69c2fcef4 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties @@ -0,0 +1 @@ +# \u9ED8\u8BA4\u4E3A\u7C7B\u7684\u5168\u9650\u5B9A\u540D\uFF08\u53EF\u81EA\u5B9A\u4E49key\uFF09= width * height diff --git a/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties b/designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties new file mode 100644 index 000000000..e69de29bb diff --git a/designer-base/src/test/java/com/fr/design/i18n/DesignSizeI18nManagerTest.java b/designer-base/src/test/java/com/fr/design/i18n/DesignSizeI18nManagerTest.java new file mode 100644 index 000000000..da9789526 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/i18n/DesignSizeI18nManagerTest.java @@ -0,0 +1,80 @@ +package com.fr.design.i18n; + +import com.fr.general.GeneralContext; +import com.fr.invoke.Reflect; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.awt.Dimension; +import java.util.Locale; + +/** + * Created by kerry on 2/24/21 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(GeneralContext.class) +public class DesignSizeI18nManagerTest { + @Test + public void testI18nDimension() { + Dimension dimension = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.ReportColumnsPane"); + validDimension(dimension, 660, 600); + + PowerMock.mockStatic(GeneralContext.class); + EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.ENGLISH).times(3); + PowerMock.replayAll(); + + dimension = DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.report.ReportColumnsPane"); + validDimension(dimension, 800, 600); + } + + @Test + public void testContainKey() { + PowerMock.mockStatic(GeneralContext.class); + EasyMock.expect(GeneralContext.getLocale()).andReturn(Locale.ENGLISH).times(3); + PowerMock.replayAll(); + + boolean result = Reflect.on(DesignSizeI18nManager.getInstance()).call("containKey", "testKey").get(); + Assert.assertFalse(result); + + result = Reflect.on(DesignSizeI18nManager.getInstance()).call("containKey", "com.fr.design.report.ReportColumnsPane").get(); + Assert.assertTrue(result); + + } + + @Test + public void testParseDimensionFromText() { + String dimensionText = "800*600"; + Dimension result = Reflect.on(DesignSizeI18nManager.getInstance()).call("parseDimensionFromText", dimensionText).get(); + validDimension(result, 800, 600); + + dimensionText = "800* 600"; + result = Reflect.on(DesignSizeI18nManager.getInstance()).call("parseDimensionFromText", dimensionText).get(); + validDimension(result, 660, 600); + + dimensionText = " 800*600"; + result = Reflect.on(DesignSizeI18nManager.getInstance()).call("parseDimensionFromText", dimensionText).get(); + validDimension(result, 660, 600); + + dimensionText = "800*600s"; + result = Reflect.on(DesignSizeI18nManager.getInstance()).call("parseDimensionFromText", dimensionText).get(); + validDimension(result, 660, 600); + + dimensionText = "800s*600"; + result = Reflect.on(DesignSizeI18nManager.getInstance()).call("parseDimensionFromText", dimensionText).get(); + validDimension(result, 660, 600); + + dimensionText = "800-600"; + result = Reflect.on(DesignSizeI18nManager.getInstance()).call("parseDimensionFromText", dimensionText).get(); + validDimension(result, 660, 600); + } + + private void validDimension(Dimension dimension, int width, int height) { + Assert.assertEquals(width, dimension.width); + Assert.assertEquals(height, dimension.height); + } +}