use of com.ramussoft.eval.UnknownValuesException in project ramus by Vitaliy-Yakovchuk.
the class SetFormulaDialog method onOk.
@Override
protected void onOk() {
if (editor.getText().equals("")) {
info.setFormula(null);
((Journaled) engine).startUserTransaction();
engine.setCalculateInfo(info);
((Journaled) engine).commitUserTransaction();
super.onOk();
return;
}
Util utils = Util.getUtils(engine);
try {
try {
info.setFormula(utils.compile(editor.getText(), engine.getElement(info.getElementId()), engine.getAttribute(info.getAttributeId())));
} catch (UnknownValuesException e) {
StringBuffer sb = new StringBuffer();
sb.append("<html><body>");
for (String value : e.getValues()) {
sb.append(MessageFormat.format(GlobalResourcesManager.getString("Eval.UnknowValue"), value));
sb.append("<br>");
}
sb.append("</body></html>");
JOptionPane.showMessageDialog(null, sb.toString());
}
Eval eval = new Eval(info.getFormula());
List<String> rec = new ArrayList<String>();
for (String function : eval.getFunctions()) if (!utils.isFunctionExists(function)) {
JOptionPane.showMessageDialog(null, MessageFormat.format(GlobalResourcesManager.getString("Eval.UnknowFunction"), function));
return;
}
rec.add(utils.toValue(info.getElementId(), info.getAttributeId()));
if (recCheck(rec, eval, utils)) {
JOptionPane.showMessageDialog(null, GlobalResourcesManager.getString("Recursive.Link"));
} else {
((Journaled) engine).startUserTransaction();
engine.setCalculateInfo(info);
((Journaled) engine).commitUserTransaction();
super.onOk();
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, MessageFormat.format(GlobalResourcesManager.getString("Eval.Error"), editor.getText()));
return;
}
}
Aggregations