Changes
This commit is contained in:
parent
6565b28921
commit
44ed81a5ca
@ -17,6 +17,8 @@ import org.solovyev.android.calculator.model.Var;
|
|||||||
import org.solovyev.android.calculator.text.TextProcessor;
|
import org.solovyev.android.calculator.text.TextProcessor;
|
||||||
import org.solovyev.android.calculator.units.CalculatorNumeralBase;
|
import org.solovyev.android.calculator.units.CalculatorNumeralBase;
|
||||||
import org.solovyev.common.history.HistoryAction;
|
import org.solovyev.common.history.HistoryAction;
|
||||||
|
import org.solovyev.common.msg.ListMessageRegistry;
|
||||||
|
import org.solovyev.common.msg.Message;
|
||||||
import org.solovyev.common.msg.MessageRegistry;
|
import org.solovyev.common.msg.MessageRegistry;
|
||||||
import org.solovyev.common.msg.MessageType;
|
import org.solovyev.common.msg.MessageType;
|
||||||
import org.solovyev.common.text.StringUtils;
|
import org.solovyev.common.text.StringUtils;
|
||||||
@ -175,11 +177,26 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
final Generic result = operation.evaluateGeneric(jsclExpression, CalculatorLocatorImpl.getInstance().getEngine().getMathEngine());
|
final CalculatorMathEngine mathEngine = CalculatorLocatorImpl.getInstance().getEngine().getMathEngine();
|
||||||
|
|
||||||
|
final MessageRegistry messageRegistry = new ListMessageRegistry();
|
||||||
|
CalculatorLocatorImpl.getInstance().getEngine().getMathEngine0().setMessageRegistry(messageRegistry);
|
||||||
|
|
||||||
|
final Generic result = operation.evaluateGeneric(jsclExpression, mathEngine);
|
||||||
|
|
||||||
// NOTE: toString() method must be called here as ArithmeticOperationException may occur in it (just to avoid later check!)
|
// NOTE: toString() method must be called here as ArithmeticOperationException may occur in it (just to avoid later check!)
|
||||||
result.toString();
|
result.toString();
|
||||||
|
|
||||||
|
final CalculatorLogger logger = CalculatorLocatorImpl.getInstance().getLogger();
|
||||||
|
try {
|
||||||
|
while (messageRegistry.hasMessage()) {
|
||||||
|
handleJsclMessage(messageRegistry.getMessage());
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
// todo serso: not good be we need proper synchronization
|
||||||
|
logger.error("Calculator", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
final CalculatorOutput data = CalculatorOutputImpl.newOutput(operation.getFromProcessor().process(result), operation, result);
|
final CalculatorOutput data = CalculatorOutputImpl.newOutput(operation.getFromProcessor().process(result), operation, result);
|
||||||
fireCalculatorEvent(newCalculationEventData(operation, expression, sequenceId), CalculatorEventType.calculation_result, data);
|
fireCalculatorEvent(newCalculationEventData(operation, expression, sequenceId), CalculatorEventType.calculation_result, data);
|
||||||
|
|
||||||
@ -204,6 +221,11 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleJsclMessage(@NotNull Message message) {
|
||||||
|
final CalculatorNotifier notifier = CalculatorLocatorImpl.getInstance().getNotifier();
|
||||||
|
notifier.showMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public PreparedExpression prepareExpression(@NotNull String expression) throws CalculatorParseException {
|
public PreparedExpression prepareExpression(@NotNull String expression) throws CalculatorParseException {
|
||||||
|
Loading…
Reference in New Issue
Block a user