|
|
@ -46,6 +46,7 @@ import com.fr.parser.BlockIntervalLiteral; |
|
|
|
import com.fr.parser.ColumnRowRangeInPage; |
|
|
|
import com.fr.parser.ColumnRowRangeInPage; |
|
|
|
import com.fr.parser.NumberLiteral; |
|
|
|
import com.fr.parser.NumberLiteral; |
|
|
|
import com.fr.parser.SheetIntervalLiteral; |
|
|
|
import com.fr.parser.SheetIntervalLiteral; |
|
|
|
|
|
|
|
import com.fr.record.analyzer.EnableMetrics; |
|
|
|
import com.fr.report.core.namespace.SimpleCellValueNameSpace; |
|
|
|
import com.fr.report.core.namespace.SimpleCellValueNameSpace; |
|
|
|
import com.fr.script.Calculator; |
|
|
|
import com.fr.script.Calculator; |
|
|
|
import com.fr.script.ScriptConstants; |
|
|
|
import com.fr.script.ScriptConstants; |
|
|
@ -54,7 +55,6 @@ import com.fr.stable.EncodeConstants; |
|
|
|
import com.fr.stable.EssentialUtils; |
|
|
|
import com.fr.stable.EssentialUtils; |
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
import com.fr.stable.ParameterProvider; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.UtilEvalError; |
|
|
|
|
|
|
|
import com.fr.stable.script.CRAddress; |
|
|
|
import com.fr.stable.script.CRAddress; |
|
|
|
import com.fr.stable.script.ColumnRowRange; |
|
|
|
import com.fr.stable.script.ColumnRowRange; |
|
|
|
import com.fr.stable.script.Expression; |
|
|
|
import com.fr.stable.script.Expression; |
|
|
@ -122,6 +122,7 @@ import java.util.Set; |
|
|
|
* @editor zhou |
|
|
|
* @editor zhou |
|
|
|
* @since 2012-3-29下午1:50:53 |
|
|
|
* @since 2012-3-29下午1:50:53 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@EnableMetrics |
|
|
|
public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
public static final int DEFUAL_FOMULA_LENGTH = 103; |
|
|
|
public static final int DEFUAL_FOMULA_LENGTH = 103; |
|
|
|
public static final String ELLIPSIS = "..."; |
|
|
|
public static final String ELLIPSIS = "..."; |
|
|
@ -139,6 +140,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
protected static UICheckBox autoCompletionCheck; |
|
|
|
protected static UICheckBox autoCompletionCheck; |
|
|
|
protected static UICheckBox checkBeforeColse; |
|
|
|
protected static UICheckBox checkBeforeColse; |
|
|
|
private JList tipsList; |
|
|
|
private JList tipsList; |
|
|
|
|
|
|
|
private JPopupMenu popupMenu; |
|
|
|
protected DefaultListModel listModel = new DefaultListModel(); |
|
|
|
protected DefaultListModel listModel = new DefaultListModel(); |
|
|
|
private int ifHasBeenWriten = 0; |
|
|
|
private int ifHasBeenWriten = 0; |
|
|
|
private DefaultListModel functionTypeListModel = new DefaultListModel(); |
|
|
|
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)) { |
|
|
|
if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) { |
|
|
|
doubleClickActuator(doublePressContent); |
|
|
|
doubleClickActuator(doublePressContent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (popupMenu != null) { |
|
|
|
|
|
|
|
popupMenu.setVisible(false); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -616,7 +621,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void popTips() { |
|
|
|
private void popTips() { |
|
|
|
JPopupMenu popupMenu = new JPopupMenu(); |
|
|
|
popupMenu = new JPopupMenu(); |
|
|
|
JScrollPane tipsScrollPane = new JScrollPane(tipsList); |
|
|
|
JScrollPane tipsScrollPane = new JScrollPane(tipsList); |
|
|
|
popupMenu.add(tipsScrollPane); |
|
|
|
popupMenu.add(tipsScrollPane); |
|
|
|
tipsScrollPane.setPreferredSize(new Dimension(240, 146)); |
|
|
|
tipsScrollPane.setPreferredSize(new Dimension(240, 146)); |
|
|
@ -792,6 +797,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ActionListener calculateActionListener = new ActionListener() { |
|
|
|
private final ActionListener calculateActionListener = new ActionListener() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String formulaText = formulaTextArea.getText().trim(); |
|
|
|
String formulaText = formulaTextArea.getText().trim(); |
|
|
@ -819,16 +825,20 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); |
|
|
|
BaseFormula baseFormula = BaseFormula.createFormulaBuilder().build(formulaText); |
|
|
|
|
|
|
|
Object calResult; |
|
|
|
try { |
|
|
|
try { |
|
|
|
Object value = calculator.evalValue(baseFormula); |
|
|
|
calResult = calculator.evalValue(baseFormula); |
|
|
|
String objectToString = EssentialUtils.objectToString(value); |
|
|
|
String objectToString = EssentialUtils.objectToString(calResult); |
|
|
|
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? |
|
|
|
String result = objectToString.length() > DEFUAL_FOMULA_LENGTH ? |
|
|
|
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; |
|
|
|
objectToString.substring(0, DEFUAL_FOMULA_LENGTH - ELLIPSIS.length()) + ELLIPSIS : objectToString; |
|
|
|
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; |
|
|
|
messageTips = messageTips + Toolkit.i18nText("Fine-Design_Basic_Formula_Cal_Result") + ":" + result; |
|
|
|
FineLoggerFactory.getLogger().info("value:{}", value); |
|
|
|
} catch (Exception ce) { |
|
|
|
} catch (UtilEvalError utilEvalError) { |
|
|
|
//模拟计算如果出现错误,则抛出错误
|
|
|
|
FineLoggerFactory.getLogger().error(utilEvalError.getMessage(), utilEvalError); |
|
|
|
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 { |
|
|
|
} else { |
|
|
|
messageTips = checkResult.getTips(); |
|
|
|
messageTips = checkResult.getTips(); |
|
|
|
} |
|
|
|
} |
|
|
|