Commit bdb57f19 authored by Tatiana Chuprina's avatar Tatiana Chuprina
Browse files

Bug in StepBack button is solved.

refs 2991
parent 4641cabb
......@@ -263,12 +263,14 @@ public class SimulationManager extends Observable {
if(currentSimulation == null) {
return;
}
fireSimulationEvent(SIMULATION_ABOUT_TO_STEP_BACK_EVENT);
performingStep = true;
try {
currentSimulation.restoreState();
} catch(ExecutionException ex) {
lastException = ex;
if(simulationThread != null) {
fireSimulationEvent(SIMULATION_ABOUT_TO_STEP_BACK_EVENT);
performingStep = true;
try {
currentSimulation.restoreState();
} catch(ExecutionException ex) {
lastException = ex;
}
}
performingStep = false;
fireSimulationEvent(SIMULATION_STEPPED_BACK_EVENT);
......
......@@ -183,6 +183,9 @@ public class SimulationView extends ViewPart implements IPropertyListener, Event
updateActions();
} else if(propId == SimulationManager.SIMULATION_INITIALIZED_EVENT) {
((StepCounterContributionItem)SimulationView.this.stepCounter).resetCounter();
updateActions();
} else if(propId == SimulationManager.SIMULATION_STEPPED_BACK_EVENT) {
updateActions();
}
}
}
......@@ -267,7 +270,9 @@ public class SimulationView extends ViewPart implements IPropertyListener, Event
} else {
simulationViewActionsInstance.pause.setEnabled(false);
simulationViewActionsInstance.performStep.setEnabled(true);
simulationViewActionsInstance.performStepBack.setEnabled(true);
boolean enableBack =
((StepCounterContributionItem)SimulationView.this.stepCounter).stepCount == 0;
simulationViewActionsInstance.performStepBack.setEnabled(!enableBack);
simulationViewActionsInstance.run.setEnabled(true);
}
simulationViewActionsInstance.initialize.setEnabled(true);
......@@ -313,8 +318,9 @@ public class SimulationView extends ViewPart implements IPropertyListener, Event
performStep = new Action() {
@Override
public void run() {
SimulationManager.INSTANCE.performStep();
((StepCounterContributionItem)SimulationView.this.stepCounter).incCounter();
SimulationManager.INSTANCE.performStep();
SimulationManager.INSTANCE.showLastErrorMessage();
}
};
......@@ -325,8 +331,8 @@ public class SimulationView extends ViewPart implements IPropertyListener, Event
performStepBack = new Action() {
@Override
public void run() {
SimulationManager.INSTANCE.performStepBack();
((StepCounterContributionItem)SimulationView.this.stepCounter).decCounter();
SimulationManager.INSTANCE.performStepBack();
SimulationManager.INSTANCE.showLastErrorMessage();
}
};
......@@ -502,12 +508,9 @@ public class SimulationView extends ViewPart implements IPropertyListener, Event
public void incCounter() {
stepCount++;
if(!stepCounterText.isDisposed()) {
stepCounterText.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if(!stepCounterText.isDisposed()) {
stepCounterText.setText(String.valueOf(stepCount));
}
stepCounterText.getDisplay().syncExec(() -> {
if(!stepCounterText.isDisposed()) {
stepCounterText.setText(String.valueOf(stepCount));
}
});
}
......@@ -518,12 +521,9 @@ public class SimulationView extends ViewPart implements IPropertyListener, Event
if(stepCount != 0) {
stepCount--;
if(!stepCounterText.isDisposed()) {
stepCounterText.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if(!stepCounterText.isDisposed()) {
stepCounterText.setText(String.valueOf(stepCount));
}
stepCounterText.getDisplay().syncExec(() -> {
if(!stepCounterText.isDisposed()) {
stepCounterText.setText(String.valueOf(stepCount));
}
});
}
......
......@@ -592,7 +592,6 @@ public abstract class ExecutableComponent<S extends IModelElementSpecification>
extendedDataHistory.addLast(new HashMap<>(extendedData));
externalStateHistory.addLast(new HashMap<>(externalState));
externallySetHistory.addLast(new HashSet<>(externallySet));
// System.out.println(modelElement.getName() + ": " + externallySet.size() + " backuped.");
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment