From 21acd863e90469a4266e42f88b43f88777448b4c Mon Sep 17 00:00:00 2001 From: Harrison Date: Wed, 29 Aug 2018 16:16:55 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-10965=20[10.0=E5=86=92=E7=83=9F]?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A7=E4=BB=B6js=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=8F=B3=E9=94=AE=E6=93=8D=E4=BD=9C=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/rtextarea/RecordableTextAction.java | 11 ++-- .../util/RTextAreaActionI18nMappingUtil.java | 60 +++++++++++++++++++ 2 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/gui/syntax/util/RTextAreaActionI18nMappingUtil.java diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RecordableTextAction.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RecordableTextAction.java index 7487f9fa83..9fc0bf93e5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RecordableTextAction.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RecordableTextAction.java @@ -11,13 +11,14 @@ package com.fr.design.gui.syntax.ui.rtextarea; -import java.awt.event.ActionEvent; -import java.util.ResourceBundle; +import com.fr.design.gui.syntax.util.RTextAreaActionI18nMappingUtil; + import javax.swing.Icon; import javax.swing.KeyStroke; import javax.swing.text.DefaultEditorKit; import javax.swing.text.JTextComponent; import javax.swing.text.TextAction; +import java.awt.event.ActionEvent; /** @@ -258,9 +259,9 @@ public abstract class RecordableTextAction extends TextAction { * property. */ public void setProperties(String keyRoot) { - setName(com.fr.design.i18n.Toolkit.i18nText(keyRoot + ".Name")); - setMnemonic(com.fr.design.i18n.Toolkit.i18nText(keyRoot + ".Mnemonic").charAt(0)); - setShortDescription(com.fr.design.i18n.Toolkit.i18nText(keyRoot + ".Desc")); + setName(com.fr.design.i18n.Toolkit.i18nText(RTextAreaActionI18nMappingUtil.getActionName(keyRoot))); + setMnemonic(com.fr.design.i18n.Toolkit.i18nText(RTextAreaActionI18nMappingUtil.getActionMnemonic(keyRoot)).charAt(0)); + setShortDescription(com.fr.design.i18n.Toolkit.i18nText(RTextAreaActionI18nMappingUtil.getActionDesc(keyRoot))); } diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/util/RTextAreaActionI18nMappingUtil.java b/designer-base/src/main/java/com/fr/design/gui/syntax/util/RTextAreaActionI18nMappingUtil.java new file mode 100644 index 0000000000..bdaa13046e --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/util/RTextAreaActionI18nMappingUtil.java @@ -0,0 +1,60 @@ +package com.fr.design.gui.syntax.util; + +import com.fr.stable.StringUtils; + +/** + * @author: Harrison + * @date: 2018/08/29 + * @description: 为 RTextArea 类中的 Action.xxx 准备的国际化匹配文件 + **/ +public enum RTextAreaActionI18nMappingUtil { + + Action_CollapseAllFolds("Action.CollapseAllFolds","Fine-Design_Basic_Action_CollapseAllFolds_Name","Fine-Design_Basic_Action_CollapseAllFolds_Mnemonic","Fine-Design_Basic_Action_CollapseAllFolds_Desc"), + Action_CollapseCommentFolds("Action.CollapseCommentFolds","Fine-Design_Basic_Action_CollapseCommentFolds_Name","Fine-Design_Basic_Action_CollapseCommentFolds_Mnemonic","Fine-Design_Basic_Action_CollapseCommentFolds_Desc"), + Action_Copy("Action.Copy","Fine-Design_Basic_Action_Copy_Name","Fine-Design_Basic_Action_Copy_Mnemonic","Fine-Design_Basic_Action_Copy_Desc"), + Action_Cut("Action.Cut","Fine-Design_Basic_Action_Cut_Name","Fine-Design_Basic_Action_Cut_Mnemonic","Fine-Design_Basic_Action_Cut_Desc"), + Action_Delete("Action.Delete","Fine-Design_Basic_Action_Delete_Name","Fine-Design_Basic_Action_Delete_Mnemonic","Fine-Design_Basic_Action_Delete_Desc"), + Action_ExpandAllFolds("Action.ExpandAllFolds","Fine-Design_Basic_Action_ExpandAllFolds_Name","Fine-Design_Basic_Action_ExpandAllFolds_Mnemonic","Fine-Design_Basic_Action_ExpandAllFolds_Desc"), + Action_Paste("Action.Paste","Fine-Design_Basic_Action_Paste_Name","Fine-Design_Basic_Action_Paste_Mnemonic","Fine-Design_Basic_Action_Paste_Desc"), + Action_Redo("Action.Redo","Fine-Design_Basic_Action_Redo_Name","Fine-Design_Basic_Action_Redo_Mnemonic","Fine-Design_Basic_Action_Redo_Desc"), + Action_SelectAll("Action.SelectAll","Fine-Design_Basic_Action_SelectAll_Name","Fine-Design_Basic_Action_SelectAll_Mnemonic","Fine-Design_Basic_Action_SelectAll_Desc"), + Action_ToggleCurrentFold("Action.ToggleCurrentFold","Fine-Design_Basic_Action_ToggleCurrentFold_Name","Fine-Design_Basic_Action_ToggleCurrentFold_Mnemonic","Fine-Design_Basic_Action_ToggleCurrentFold_Desc"), + Action_Undo("Action.Undo","Fine-Design_Basic_Action_Undo_Name","Fine-Design_Basic_Action_Undo_Mnemonic","Fine-Design_Basic_Action_Undo_Desc"); + + private String actionRawKey; + private String actionName; + private String actionMnemonic; + private String actionDesc; + + RTextAreaActionI18nMappingUtil(String actionRawKey, String actionName, String actionMnemonic, String actionDesc) { + this.actionRawKey = actionRawKey; + this.actionName = actionName; + this.actionMnemonic = actionMnemonic; + this.actionDesc = actionDesc; + } + + public static String getActionName(String actionKey) { + for (RTextAreaActionI18nMappingUtil mapping: RTextAreaActionI18nMappingUtil.values()) { + if (StringUtils.equals(mapping.actionRawKey, actionKey)) { + return mapping.actionName; + } + } + return actionKey; + } + public static String getActionMnemonic(String actionKey) { + for (RTextAreaActionI18nMappingUtil mapping: RTextAreaActionI18nMappingUtil.values()) { + if (StringUtils.equals(mapping.actionRawKey, actionKey)) { + return mapping.actionMnemonic; + } + } + return actionKey; + } + public static String getActionDesc(String actionKey) { + for (RTextAreaActionI18nMappingUtil mapping: RTextAreaActionI18nMappingUtil.values()) { + if (StringUtils.equals(mapping.actionRawKey, actionKey)) { + return mapping.actionDesc; + } + } + return actionKey; + } +}