use of cbit.vcell.client.desktop.biomodel.MathematicsPanel in project vcell by virtualcell.
the class BioModelWindowManager method actionPerformed.
/**
* Invoked when an action occurs.
*/
public void actionPerformed(java.awt.event.ActionEvent e) {
String actionCommand = e.getActionCommand();
final Object source = e.getSource();
if (source instanceof GeometryViewer && (actionCommand.equals(GuiConstants.ACTIONCMD_CREATE_GEOMETRY) || actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY))) {
final GeometryViewer geometryViewer = (GeometryViewer) source;
AsynchClientTask precomputeAllTask = new AsynchClientTask("precomputeAll geometry", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
if (newGeom != null) {
newGeom.precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
}
};
AsynchClientTask setGeomOnSimContextTask = new AsynchClientTask("Setting geometry on application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
for (SimulationContext simulationContext : getBioModel().getSimulationContexts()) {
if (simulationContext == geometryViewer.getGeometryOwner()) {
if (newGeom.getName() == null) {
newGeom.setName(getBioModel().getName() + "_" + (simulationContext.getName() + "_" + BeanUtils.generateDateTimeString()));
}
simulationContext.setGeometry(newGeom);
return;
}
}
Geometry origGeom = geometryViewer.getGeometryOwner().getGeometry();
throw new IllegalArgumentException("Couldn't find matching application editor for orig geom '" + origGeom.getName() + "' key=" + origGeom.getKey() + " in application hash.");
}
};
Geometry currentGeometry = geometryViewer.getGeometryOwner().getGeometry();
createGeometry(currentGeometry, new AsynchClientTask[] { /*oldEditorTask,*/
precomputeAllTask, setGeomOnSimContextTask }, TopLevelWindowManager.DEFAULT_CREATEGEOM_SELECT_DIALOG_TITLE, TopLevelWindowManager.APPLY_GEOMETRY_BUTTON_TEXT, (actionCommand.equals(GuiConstants.ACTIONCMD_EDITCURRENTSPATIAL_GEOMETRY) ? new DocumentWindowManager.GeometrySelectionInfo() : null));
}
if (source instanceof MathematicsPanel && actionCommand.equals(GuiConstants.ACTIONCMD_CREATE_MATH_MODEL)) {
SimulationContext sc = ((MathematicsPanel) source).getSimulationContext();
getRequestManager().createMathModelFromApplication(this, "Untitled", sc);
}
if (source instanceof GeometryViewer && actionCommand.equals(GuiConstants.ACTIONCMD_CHANGE_GEOMETRY)) {
final GeometryViewer geometryViewer = (GeometryViewer) source;
getRequestManager().changeGeometry(this, (SimulationContext) geometryViewer.getGeometryOwner());
}
}
Aggregations