From a634abddfd7ccda7700ee84a0b1cbbd8ded4947d Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Thu, 9 Jul 2020 14:28:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-31546=20=E5=85=AC=E5=BC=8F=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E7=9A=84=E8=AF=B4=E6=98=8E=E5=88=87=E6=8D=A2=E5=81=B6?= =?UTF-8?q?=E5=B0=94=E4=BC=9A=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/formula/FormulaPane.java | 97 ++++++++++++------- 1 file changed, 62 insertions(+), 35 deletions(-) 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 9259248ac6..305b580d01 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 @@ -246,44 +246,71 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } public class DoubleClick extends MouseAdapter { + String singlePressContent; + + String doublePressContent; + @Override - public void mouseClicked(MouseEvent e) { + public void mousePressed(MouseEvent e) { int index = tipsList.getSelectedIndex(); if (index != -1) { - String currentLineContent = (String) listModel.getElementAt(index); - if (e.getClickCount() == 2) { - if (ifHasBeenWriten == 0) { - formulaTextArea.setForeground(Color.black); - formulaTextArea.setText(""); + if (e.getClickCount() == 1) { + singlePressContent = (String) listModel.getElementAt(index); + } else if (e.getClickCount() == 2) { + doublePressContent = (String) listModel.getElementAt(index); + } + } + } + + @Override + public void mouseReleased(MouseEvent e) { + int index = tipsList.getSelectedIndex(); + if (index != -1) { + if (e.getClickCount() == 1) { + if (ComparatorUtils.equals((String) listModel.getElementAt(index), singlePressContent)) { + singleClickActuator(singlePressContent); } - formulaTextArea.setForeground(Color.black); - currentPosition = formulaTextArea.getCaretPosition(); - String output = currentLineContent + "()"; - String textAll = formulaTextArea.getText(); - String textReplaced; - int position = 0; - if (insertPosition <= currentPosition) { - textReplaced = textAll.substring(0, insertPosition) + output + textAll.substring(currentPosition); - position = insertPosition + output.length() - 1; - } else { - textReplaced = textAll.substring(0, currentPosition) + output + textAll.substring(insertPosition); - position = currentPosition + output.length() - 1; + } else if (e.getClickCount() == 2) { + if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) { + doubleClickActuator(doublePressContent); } - formulaTextArea.setText(textReplaced); - formulaTextArea.requestFocusInWindow(); - formulaTextArea.setCaretPosition(position); - insertPosition = position; - ifHasBeenWriten = 1; - listModel.removeAllElements(); - } else if (e.getClickCount() == 1) { - refreshDescriptionTextArea(currentLineContent); - - formulaTextArea.requestFocusInWindow(); - fixFunctionNameList(); } } } + + private void singleClickActuator(String currentLineContent) { + refreshDescriptionTextArea(currentLineContent); + + formulaTextArea.requestFocusInWindow(); + fixFunctionNameList(); + } + + private void doubleClickActuator(String currentLineContent) { + if (ifHasBeenWriten == 0) { + formulaTextArea.setForeground(Color.black); + formulaTextArea.setText(""); + } + formulaTextArea.setForeground(Color.black); + currentPosition = formulaTextArea.getCaretPosition(); + String output = currentLineContent + "()"; + String textAll = formulaTextArea.getText(); + String textReplaced; + int position = 0; + if (insertPosition <= currentPosition) { + textReplaced = textAll.substring(0, insertPosition) + output + textAll.substring(currentPosition); + position = insertPosition + output.length() - 1; + } else { + textReplaced = textAll.substring(0, currentPosition) + output + textAll.substring(insertPosition); + position = currentPosition + output.length() - 1; + } + formulaTextArea.setText(textReplaced); + formulaTextArea.requestFocusInWindow(); + formulaTextArea.setCaretPosition(position); + insertPosition = position; + ifHasBeenWriten = 1; + listModel.removeAllElements(); + } } @Override @@ -583,10 +610,10 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { FineJOptionPane.showMessageDialog( FormulaPane.this, /* - * alex:仅仅只需要根据expression是否为null作合法性判断 - * 不需要eval - * TODO 但有个问题,有些函数的参数个数是有规定的,何以判别之 - */ + * alex:仅仅只需要根据expression是否为null作合法性判断 + * 不需要eval + * TODO 但有个问题,有些函数的参数个数是有规定的,何以判别之 + */ (expression != null ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula")) + ".", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); @@ -780,13 +807,13 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode selectedTreeNode = (DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent(); Object selectedValue = selectedTreeNode.getUserObject(); - Object selectedParentValue = ((DefaultMutableTreeNode)selectedTreeNode.getParent()).getUserObject(); + Object selectedParentValue = ((DefaultMutableTreeNode) selectedTreeNode.getParent()).getUserObject(); if (selectedValue == null) { return; } - if (selectedValue instanceof TextUserObject) { + 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"))) { From 0cf0846a60f34a60221a6c7de9d22b90fef8068d Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Fri, 17 Jul 2020 10:22:48 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-35259=20=E5=BD=93=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=A0=8F=E5=8F=82=E6=95=B0=E8=BF=87=E5=A4=9A=E6=97=B6=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=9C=89=E4=B8=8B=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-form/src/main/java/com/fr/design/mainframe/JForm.java | 1 + .../java/com/fr/design/parameter/ParameterPropertyPane.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 2fbccb1cd3..7cdd7fd600 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -371,6 +371,7 @@ public class JForm extends JTemplate implements BaseJForm Date: Fri, 17 Jul 2020 10:34:34 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-35259=20=E5=BD=93=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=A0=8F=E5=8F=82=E6=95=B0=E8=BF=87=E5=A4=9A=E6=97=B6=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=9C=89=E4=B8=8B=E6=8B=89=E6=A1=86=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=97=A0=E7=94=A8=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/formula/FormulaPane.java | 89 +++++++------------ 1 file changed, 31 insertions(+), 58 deletions(-) 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 305b580d01..3631fe3dae 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 @@ -246,70 +246,43 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } public class DoubleClick extends MouseAdapter { - String singlePressContent; - - String doublePressContent; - @Override - public void mousePressed(MouseEvent e) { + public void mouseClicked(MouseEvent e) { int index = tipsList.getSelectedIndex(); if (index != -1) { - if (e.getClickCount() == 1) { - singlePressContent = (String) listModel.getElementAt(index); - } else if (e.getClickCount() == 2) { - doublePressContent = (String) listModel.getElementAt(index); - } - } - } - - @Override - public void mouseReleased(MouseEvent e) { - int index = tipsList.getSelectedIndex(); - if (index != -1) { - if (e.getClickCount() == 1) { - if (ComparatorUtils.equals((String) listModel.getElementAt(index), singlePressContent)) { - singleClickActuator(singlePressContent); + String currentLineContent = (String) listModel.getElementAt(index); + if (e.getClickCount() == 2) { + if (ifHasBeenWriten == 0) { + formulaTextArea.setForeground(Color.black); + formulaTextArea.setText(""); } - } else if (e.getClickCount() == 2) { - if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) { - doubleClickActuator(doublePressContent); + formulaTextArea.setForeground(Color.black); + currentPosition = formulaTextArea.getCaretPosition(); + String output = currentLineContent + "()"; + String textAll = formulaTextArea.getText(); + String textReplaced; + int position = 0; + if (insertPosition <= currentPosition) { + textReplaced = textAll.substring(0, insertPosition) + output + textAll.substring(currentPosition); + position = insertPosition + output.length() - 1; + } else { + textReplaced = textAll.substring(0, currentPosition) + output + textAll.substring(insertPosition); + position = currentPosition + output.length() - 1; } - } - } - } - - private void singleClickActuator(String currentLineContent) { - refreshDescriptionTextArea(currentLineContent); - - formulaTextArea.requestFocusInWindow(); - fixFunctionNameList(); - } + formulaTextArea.setText(textReplaced); + formulaTextArea.requestFocusInWindow(); + formulaTextArea.setCaretPosition(position); + insertPosition = position; + ifHasBeenWriten = 1; + listModel.removeAllElements(); + } else if (e.getClickCount() == 1) { + refreshDescriptionTextArea(currentLineContent); - private void doubleClickActuator(String currentLineContent) { - if (ifHasBeenWriten == 0) { - formulaTextArea.setForeground(Color.black); - formulaTextArea.setText(""); - } - formulaTextArea.setForeground(Color.black); - currentPosition = formulaTextArea.getCaretPosition(); - String output = currentLineContent + "()"; - String textAll = formulaTextArea.getText(); - String textReplaced; - int position = 0; - if (insertPosition <= currentPosition) { - textReplaced = textAll.substring(0, insertPosition) + output + textAll.substring(currentPosition); - position = insertPosition + output.length() - 1; - } else { - textReplaced = textAll.substring(0, currentPosition) + output + textAll.substring(insertPosition); - position = currentPosition + output.length() - 1; + formulaTextArea.requestFocusInWindow(); + fixFunctionNameList(); + } } - formulaTextArea.setText(textReplaced); - formulaTextArea.requestFocusInWindow(); - formulaTextArea.setCaretPosition(position); - insertPosition = position; - ifHasBeenWriten = 1; - listModel.removeAllElements(); } } @@ -807,13 +780,13 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode selectedTreeNode = (DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent(); Object selectedValue = selectedTreeNode.getUserObject(); - Object selectedParentValue = ((DefaultMutableTreeNode) selectedTreeNode.getParent()).getUserObject(); + Object selectedParentValue = ((DefaultMutableTreeNode)selectedTreeNode.getParent()).getUserObject(); if (selectedValue == null) { return; } - if (selectedValue instanceof TextUserObject) { + 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"))) { From 4e743d189d7f352c97a31e60d973c81c6598825b Mon Sep 17 00:00:00 2001 From: "Henry.Wang" Date: Fri, 17 Jul 2020 10:37:58 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-35259=20=E5=BD=93=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=A0=8F=E5=8F=82=E6=95=B0=E8=BF=87=E5=A4=9A=E6=97=B6=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=9C=89=E4=B8=8B=E6=8B=89=E6=A1=86=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/formula/FormulaPane.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 3631fe3dae..9259248ac6 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 @@ -583,10 +583,10 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { FineJOptionPane.showMessageDialog( FormulaPane.this, /* - * alex:仅仅只需要根据expression是否为null作合法性判断 - * 不需要eval - * TODO 但有个问题,有些函数的参数个数是有规定的,何以判别之 - */ + * alex:仅仅只需要根据expression是否为null作合法性判断 + * 不需要eval + * TODO 但有个问题,有些函数的参数个数是有规定的,何以判别之 + */ (expression != null ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Valid_Formula") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Invalid_Formula")) + ".", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE);