From 0f5518c1b1270a59886f8b01b6d166a217a5d1a3 Mon Sep 17 00:00:00 2001 From: "Joe.Jiang" Date: Tue, 29 Oct 2019 19:23:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-22964=20=E7=B3=BB=E7=BB=9F=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=AF=B4=E6=98=8E=E6=97=A0=E5=AF=B9=E5=BA=94=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E9=94=AE=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/formula/FormulaConstants.java | 50 +++++++++++++++++++ .../com/fr/design/formula/FormulaPane.java | 33 ++++++------ 2 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/formula/FormulaConstants.java diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaConstants.java b/designer-base/src/main/java/com/fr/design/formula/FormulaConstants.java new file mode 100644 index 0000000000..97430ba7ff --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaConstants.java @@ -0,0 +1,50 @@ +package com.fr.design.formula; + +import com.fr.stable.StringUtils; + +public enum FormulaConstants { + + PAGE_NUMBER("$$page_number", "Page_Number"), + TOTAL_PAGE_NUMBER("$$totalPage_number", "Total_Page_Number"), + FINE_USERNAME("$fine_username", "Fine_Username"), + FINE_ROLE("$fine_role", "Fine_Role"), + FINE_POSITION("$fine_position", "Fine_Position"), + NULL("NULL", "Null"), + NOFILTER("NOFILTER", "No_Filter"), + REPORT_NAME("reportName", "Report_Name"), + FORMLET_NAME("formletName", "Formlet_Name"), + SERVLET_URL("servletURL", "Servlet_URL"), + SERVER_SCHEMA("serverSchema", "Server_Schema"), + SERVER_NAME("serverName", "Server_Name"), + SERVER_PORT("serverPort", "Server_Port"), + SERVER_URL("serverURL", "Server_URL"), + CONTEXT_PATH("contextPath", "Context_Path"), + SESSION_ID("sessionID", "SessionID"); + + + private String key; + private String value; + + private FormulaConstants(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public String getValue() { + return value; + } + + public static String getValueByKey(String key) { + for (FormulaConstants formulaConstant : values()) { + if (formulaConstant.getKey().equals(key)) { + return formulaConstant.getValue(); + } + } + return StringUtils.EMPTY; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index 2cf6efa910..87d0a3a985 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -19,6 +19,7 @@ import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.parser.FRLexer; import com.fr.parser.FRParser; @@ -779,31 +780,35 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { private void initVariablesTreeSelectionListener() { variablesTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { - Object selectedValue = ((DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent()).getUserObject(); + DefaultMutableTreeNode selectedTreeNode = (DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent(); + Object selectedValue = selectedTreeNode.getUserObject(); + Object selectedParentValue = ((DefaultMutableTreeNode)selectedTreeNode.getParent()).getUserObject(); + if (selectedValue == null) { return; } - StringBuilder desBuf = new StringBuilder(); - try { - String path; - Locale locale = FRContext.getLocale(); - if (locale.equals(Locale.CHINA)) { - path = "/com/fr/design/insert/formula/variable/cn/"; + + if (selectedValue instanceof TextUserObject) { + //有公式说明的条件:1.属于TextUserObject 2.parent是系统参数 + if (ComparatorUtils.equals(((TextFolderUserObject) selectedParentValue).getText(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Variables"))) { + descriptionTextArea.setText(getVariableDescription((TextUserObject) selectedValue)); } else { - path = "/com/fr/design/insert/formula/variable/en/"; - } - if (selectedValue instanceof TextUserObject) { - desBuf = getText((TextUserObject) selectedValue, path); + descriptionTextArea.setText(""); } - } catch (IOException exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + } else if (selectedValue instanceof TextFolderUserObject) { + descriptionTextArea.setText(""); } - descriptionTextArea.setText(desBuf.toString()); descriptionTextArea.moveCaretPosition(0); } }); } + private String getVariableDescription(TextUserObject selectedValue) { + + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_CurReport_Variable_" + FormulaConstants.getValueByKey(selectedValue.getText())); + } + private void initVariablesTree() { // vairable. variablesTree = new JTree(); From 035f9fd99f28e50966749db787b12f5b0f77e9b8 Mon Sep 17 00:00:00 2001 From: "Joe.Jiang" Date: Wed, 30 Oct 2019 11:11:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-22964=20=E7=B3=BB=E7=BB=9F=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=AF=B4=E6=98=8E=E6=97=A0=E5=AF=B9=E5=BA=94=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E9=94=AE=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/formula/FormulaConstants.java | 11 +++++++++-- .../main/java/com/fr/design/formula/FormulaPane.java | 10 +++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaConstants.java b/designer-base/src/main/java/com/fr/design/formula/FormulaConstants.java index 97430ba7ff..4dfcb4bb47 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaConstants.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaConstants.java @@ -2,6 +2,11 @@ package com.fr.design.formula; import com.fr.stable.StringUtils; +/** + * @author Joe + * @version 10.0 + * Created by Joe on 10/30/2019 + */ public enum FormulaConstants { PAGE_NUMBER("$$page_number", "Page_Number"), @@ -21,13 +26,13 @@ public enum FormulaConstants { CONTEXT_PATH("contextPath", "Context_Path"), SESSION_ID("sessionID", "SessionID"); - private String key; private String value; + private static final String KEY_PREFIX = "Fine-Design_CurReport_Variable_"; private FormulaConstants(String key, String value) { this.key = key; - this.value = value; + this.value = KEY_PREFIX + value; } public String getKey() { @@ -47,4 +52,6 @@ public enum FormulaConstants { return StringUtils.EMPTY; } + + } diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index 87d0a3a985..a8c8c34779 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -792,22 +792,18 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { //有公式说明的条件:1.属于TextUserObject 2.parent是系统参数 if (ComparatorUtils.equals(((TextFolderUserObject) selectedParentValue).getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Variables"))) { - descriptionTextArea.setText(getVariableDescription((TextUserObject) selectedValue)); + descriptionTextArea.setText(com.fr.design.i18n.Toolkit.i18nText(FormulaConstants.getValueByKey(((TextUserObject) selectedValue).getText()))); } else { - descriptionTextArea.setText(""); + descriptionTextArea.setText(StringUtils.EMPTY); } } else if (selectedValue instanceof TextFolderUserObject) { - descriptionTextArea.setText(""); + descriptionTextArea.setText(StringUtils.EMPTY); } descriptionTextArea.moveCaretPosition(0); } }); } - private String getVariableDescription(TextUserObject selectedValue) { - - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_CurReport_Variable_" + FormulaConstants.getValueByKey(selectedValue.getText())); - } private void initVariablesTree() { // vairable.