public void setBatch(Batch batch) {
int percentCompleted = 0;
String tracePercent;
BatchLoadSaveMonitor BLSMonitor = new BatchLoadSaveMonitor(
"Loading batch");
BLSMonitor.setLocationRelativeTo(BossaNovaData.getSingleton()
.getApplication().getMainScreen());
BLSMonitor.setVisible(true);
this.batch = batch;
if (batch != null) {
// We force create a flow for each step
List<Step> steps = batch.getSteps();
if (steps != null) {
for (int i = 0; i < steps.size(); i++) {
try {
if (steps.get(i) != null) {
// 29/04/2011 SPJZ : due to Erwin advice (cf
// createFlow)
createFlow(steps.get(i), batch.getBatchDirector(),
true);
// END change SPJZ
if (i * 100 / steps.size() > percentCompleted) {
percentCompleted = i * 100 / steps.size();
tracePercent = percentCompleted + "% Completed";
BLSMonitor.updateBar(percentCompleted);
BLSMonitor.setString(tracePercent);
BLSMonitor.update(BLSMonitor.getGraphics());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
// We select the first step in the Batch
BossaNovaData.getSingleton().getApplication().setSelectedStep(
batch.getStep(0), true);
BLSMonitor.setVisible(false);
}
setChangedAndNotify();
}