use of cbit.vcell.mapping.MathMappingCallbackTaskAdapter in project vcell by virtualcell.
the class ClientRequestManager method updateMath.
public static Collection<AsynchClientTask> updateMath(final Component requester, final SimulationContext simulationContext, final boolean bShowWarning, final NetworkGenerationRequirements networkGenerationRequirements) {
ArrayList<AsynchClientTask> rval = new ArrayList<>();
AsynchClientTask task1 = new AsynchClientTask("generating math", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry geometry = simulationContext.getGeometry();
if (geometry.getDimension() > 0 && geometry.getGeometrySurfaceDescription().getGeometricRegions() == null) {
geometry.getGeometrySurfaceDescription().updateAll();
}
// Use differnt mathmapping for different applications (stoch or non-stoch)
simulationContext.checkValidity();
MathMappingCallback callback = new MathMappingCallbackTaskAdapter(getClientTaskStatusSupport());
MathMapping mathMapping = simulationContext.createNewMathMapping(callback, networkGenerationRequirements);
MathDescription mathDesc = mathMapping.getMathDescription(callback);
callback.setProgressFraction(1.0f / 3.0f * 2.0f);
hashTable.put("mathMapping", mathMapping);
hashTable.put("mathDesc", mathDesc);
}
};
rval.add(task1);
AsynchClientTask task2 = new AsynchClientTask("formating math", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
MathDescription mathDesc = (MathDescription) hashTable.get("mathDesc");
if (mathDesc != null) {
simulationContext.setMathDescription(mathDesc);
}
}
};
rval.add(task2);
if (bShowWarning) {
AsynchClientTask task3 = new AsynchClientTask("showing issues", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
MathMapping mathMapping = (MathMapping) hashTable.get("mathMapping");
MathDescription mathDesc = (MathDescription) hashTable.get("mathDesc");
if (mathDesc != null) {
//
// inform user if any issues
//
Issue[] issues = mathMapping.getIssues();
if (issues != null && issues.length > 0) {
StringBuffer messageBuffer = new StringBuffer("Issues encountered during Math Generation:\n");
int issueCount = 0;
for (int i = 0; i < issues.length; i++) {
if (issues[i].getSeverity() == Issue.SEVERITY_ERROR || issues[i].getSeverity() == Issue.SEVERITY_WARNING) {
messageBuffer.append(issues[i].getCategory() + " " + issues[i].getSeverityName() + " : " + issues[i].getMessage() + "\n");
issueCount++;
}
}
if (issueCount > 0) {
PopupGenerator.showWarningDialog(requester, messageBuffer.toString(), new String[] { "OK" }, "OK");
}
}
}
}
};
rval.add(task3);
}
return rval;
}
Aggregations