Editor/display changes

This commit is contained in:
Sergey Solovyev 2012-09-24 23:52:21 +04:00
parent 9c20d58678
commit 35102cbcc3

View File

@ -32,7 +32,10 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
private final List<CalculatorHistoryState> savedHistory = new ArrayList<CalculatorHistoryState>();
@NotNull
private volatile CalculatorEventData lastEventDataId = CalculatorUtils.createFirstEventDataId();
private volatile CalculatorEventData lastEventData = CalculatorUtils.createFirstEventDataId();
@NotNull
private final Object lastEventDataLock = new Object();
@Nullable
private volatile CalculatorEditorViewState lastEditorViewState;
@ -182,11 +185,26 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
@Nullable Object data) {
if (calculatorEventType.isOfType(editor_state_changed, display_state_changed, manual_calculation_requested)) {
if (calculatorEventData.isAfter(this.lastEventDataId)) {
final boolean sameSequence = calculatorEventData.isSameSequence(this.lastEventDataId);
boolean sameSequence = false;
boolean afterSequence = false;
if (sameSequence || calculatorEventData.isAfterSequence(this.lastEventDataId)) {
this.lastEventDataId = calculatorEventData;
boolean processEvent = false;
synchronized (this.lastEventDataLock) {
if (calculatorEventData.isAfter(this.lastEventData)) {
sameSequence = calculatorEventData.isSameSequence(this.lastEventData);
if (!sameSequence) {
afterSequence = calculatorEventData.isAfterSequence(this.lastEventData);
processEvent = afterSequence;
} else {
processEvent = true;
}
}
}
if (processEvent) {
this.lastEventData = calculatorEventData;
switch (calculatorEventType) {
case manual_calculation_requested:
@ -212,5 +230,4 @@ public class CalculatorHistoryImpl implements CalculatorHistory {
}
}
}
}
}