From 0c77e8cdf3f2f8c0c9a84e7ad6ef2f409919e91c Mon Sep 17 00:00:00 2001 From: Hoky <303455184@qq.com> Date: Wed, 24 Nov 2021 17:41:04 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-63196=20&&=20REPORT-63186=201.=E5=9C=A8?= =?UTF-8?q?=E5=8F=8C=E5=87=BB=E4=B9=8B=E5=90=8E=E4=BD=BF=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=A1=86=E6=B6=88=E5=A4=B1=EF=BC=9B=202.=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=9C=A8=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=8F=90=E7=A4=BA=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/formula/FormulaPane.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 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 b11644e684..dc1e03027c 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 @@ -46,6 +46,7 @@ import com.fr.parser.BlockIntervalLiteral; import com.fr.parser.ColumnRowRangeInPage; import com.fr.parser.NumberLiteral; import com.fr.parser.SheetIntervalLiteral; +import com.fr.record.analyzer.EnableMetrics; import com.fr.report.core.namespace.SimpleCellValueNameSpace; import com.fr.script.Calculator; import com.fr.script.ScriptConstants; @@ -54,7 +55,6 @@ import com.fr.stable.EncodeConstants; import com.fr.stable.EssentialUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; -import com.fr.stable.UtilEvalError; import com.fr.stable.script.CRAddress; import com.fr.stable.script.ColumnRowRange; import com.fr.stable.script.Expression; @@ -122,6 +122,7 @@ import java.util.Set; * @editor zhou * @since 2012-3-29下午1:50:53 */ +@EnableMetrics public class FormulaPane extends BasicPane implements KeyListener, UIFormula { public static final int DEFUAL_FOMULA_LENGTH = 103; public static final String ELLIPSIS = "..."; @@ -139,6 +140,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { protected static UICheckBox autoCompletionCheck; protected static UICheckBox checkBeforeColse; private JList tipsList; + private JPopupMenu popupMenu; protected DefaultListModel listModel = new DefaultListModel(); private int ifHasBeenWriten = 0; private DefaultListModel functionTypeListModel = new DefaultListModel(); @@ -457,6 +459,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) { doubleClickActuator(doublePressContent); } + if (popupMenu != null) { + popupMenu.setVisible(false); + } } } } @@ -616,7 +621,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } private void popTips() { - JPopupMenu popupMenu = new JPopupMenu(); + popupMenu = new JPopupMenu(); JScrollPane tipsScrollPane = new JScrollPane(tipsList); popupMenu.add(tipsScrollPane); tipsScrollPane.setPreferredSize(new Dimension(240, 146)); @@ -792,6 +797,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { private final ActionListener calculateActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { String formulaText = formulaTextArea.getText().trim(); @@ -819,16 +825,20 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); + Object calResult; try { - Object value = calculator.evalValue(baseFormula); - String objectToString = EssentialUtils.objectToString(value); + calResult = calculator.evalValue(baseFormula); + String objectToString = EssentialUtils.objectToString(calResult); String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; - FineLoggerFactory.getLogger().info("value:{}", value); - } catch (UtilEvalError utilEvalError) { - FineLoggerFactory.getLogger().error(utilEvalError.getMessage(), utilEvalError); + } catch (Exception ce) { + //模拟计算如果出现错误,则抛出错误 + calResult = ce.getMessage(); + FineLoggerFactory.getLogger().error(ce.getMessage(), ce); + messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Error") + ":" + calResult; } + FineLoggerFactory.getLogger().info("value:{}", calResult); } else { messageTips = checkResult.getTips(); }