use of cbit.vcell.client.MathModelWindowManager in project vcell by virtualcell.
the class NewName method run.
/**
* Insert the method's description here.
* Creation date: (5/31/2004 6:04:14 PM)
* @param hashTable java.util.Hashtable
* @param clientWorker cbit.vcell.desktop.controls.ClientWorker
*/
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
DocumentWindowManager documentWindowManager = (DocumentWindowManager) hashTable.get(CommonTask.DOCUMENT_WINDOW_MANAGER.name);
VCDocument document = documentWindowManager.getVCDocument();
if (document.getDocumentType() == VCDocumentType.MATHMODEL_DOC) {
if (((MathModelWindowManager) documentWindowManager).hasUnappliedChanges()) {
String msg = "Changes have been made in VCML Editor, please click \"Apply Changes\" or \"Cancel\" to proceed.";
PopupGenerator.showErrorDialog(documentWindowManager, msg);
throw UserCancelException.CANCEL_UNAPPLIED_CHANGES;
}
}
MDIManager mdiManager = (MDIManager) hashTable.get("mdiManager");
String oldName = document.getName();
User user = mdiManager.getFocusedWindowManager().getRequestManager().getDocumentManager().getUser();
DocumentManager documentManager = mdiManager.getFocusedWindowManager().getRequestManager().getDocumentManager();
VCDocumentInfo[] vcDocumentInfos = new VCDocumentInfo[0];
String documentTypeDescription = "unknown";
if (document.getDocumentType() == VCDocumentType.MATHMODEL_DOC) {
documentTypeDescription = "MathModel";
vcDocumentInfos = documentManager.getMathModelInfos();
} else if (document.getDocumentType() == VCDocumentType.BIOMODEL_DOC) {
documentTypeDescription = "BioModel";
vcDocumentInfos = documentManager.getBioModelInfos();
} else if (document.getDocumentType() == VCDocumentType.GEOMETRY_DOC) {
documentTypeDescription = "Geometry";
vcDocumentInfos = documentManager.getGeometryInfos();
}
String newDocumentName = (oldName == null ? "New" + documentTypeDescription : oldName);
while (true) {
newDocumentName = mdiManager.getDatabaseWindowManager().showSaveDialog(document.getDocumentType(), (Component) hashTable.get("currentDocumentWindow"), newDocumentName);
if (newDocumentName == null || newDocumentName.trim().length() == 0) {
newDocumentName = null;
DialogUtils.showWarningDialog((Component) hashTable.get("currentDocumentWindow"), "New " + documentTypeDescription + " name cannot be empty.");
continue;
}
// Check name conflict
boolean bNameConflict = false;
for (int i = 0; i < vcDocumentInfos.length; i++) {
if (vcDocumentInfos[i].getVersion().getOwner().compareEqual(user)) {
if (vcDocumentInfos[i].getVersion().getName().equals(newDocumentName)) {
bNameConflict = true;
break;
}
}
}
if (bNameConflict) {
DialogUtils.showWarningDialog((Component) hashTable.get("currentDocumentWindow"), "A " + documentTypeDescription + " with name '" + newDocumentName + "' already exists. Choose a different name.");
continue;
} else {
break;
}
}
hashTable.put("newName", newDocumentName);
}
use of cbit.vcell.client.MathModelWindowManager in project vcell by virtualcell.
the class VCellClientDataServiceImpl method getSimsFromOpenModels.
@Override
public List<SimulationDataSetRef> getSimsFromOpenModels() {
ArrayList<SimulationDataSetRef> simulationDataSetRefs = new ArrayList<SimulationDataSetRef>();
for (TopLevelWindowManager windowManager : vcellClient.getMdiManager().getWindowManagers()) {
Simulation[] simulations = null;
VCDocument modelDocument = null;
if (windowManager instanceof BioModelWindowManager) {
BioModelWindowManager selectedBioWindowManager = (BioModelWindowManager) windowManager;
BioModel bioModel = selectedBioWindowManager.getBioModel();
simulations = bioModel.getSimulations();
modelDocument = bioModel;
// simOwnerCount = bioModel.getNumSimulationContexts();
} else if (windowManager instanceof MathModelWindowManager) {
MathModelWindowManager selectedMathWindowManager = (MathModelWindowManager) windowManager;
MathModel mathModel = selectedMathWindowManager.getMathModel();
simulations = mathModel.getSimulations();
modelDocument = mathModel;
// simOwnerCount = 1;
}
if (simulations != null) {
for (Simulation simulation : simulations) {
if (!isVtkSupported(simulation)) {
continue;
}
Origin origin = simulation.getMathDescription().getGeometry().getOrigin();
Extent extent = simulation.getMathDescription().getGeometry().getExtent();
SimulationInfo simInfo = simulation.getSimulationInfo();
SimulationStatus simStatus = vcellClient.getRequestManager().getServerSimulationStatus(simInfo);
for (int jobIndex = 0; jobIndex < simulation.getScanCount(); jobIndex++) {
if (simStatus != null && simStatus.getHasData()) {
SimulationDataSetRef simulationDataSetReference = VCellClientDataServiceImpl.createSimulationDataSetRef(simulation, modelDocument, jobIndex, false);
simulationDataSetRefs.add(simulationDataSetReference);
}
}
}
}
}
File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
String[] simtaskFilenames = localSimDir.list((dir, name) -> (name.endsWith(".simtask.xml")));
for (String simtaskFilename : simtaskFilenames) {
try {
SimulationTask simTask = XmlHelper.XMLToSimTask(org.apache.commons.io.FileUtils.readFileToString(new File(localSimDir, simtaskFilename)));
VCDocument modelDocument = null;
SimulationDataSetRef simulationDataSetReference = VCellClientDataServiceImpl.createSimulationDataSetRef(simTask.getSimulation(), modelDocument, simTask.getSimulationJob().getJobIndex(), true);
simulationDataSetRefs.add(simulationDataSetReference);
} catch (ExpressionException | XmlParseException | IOException e) {
e.printStackTrace();
}
}
return simulationDataSetRefs;
}
use of cbit.vcell.client.MathModelWindowManager in project vcell by virtualcell.
the class CheckUnchanged method run.
/**
* Insert the method's description here.
* Creation date: (5/31/2004 6:04:14 PM)
* @param hashTable java.util.Hashtable
* @param clientWorker cbit.vcell.desktop.controls.ClientWorker
*/
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
DocumentWindowManager documentWindowManager = (DocumentWindowManager) hashTable.get(CommonTask.DOCUMENT_WINDOW_MANAGER.name);
DocumentManager documentManager = (DocumentManager) hashTable.get(CommonTask.DOCUMENT_MANAGER.name);
// JFrame currentDocumentWindow = (JFrame)hashTable.get("currentDocumentWindow");
if (documentWindowManager.getVCDocument().getDocumentType() == VCDocumentType.MATHMODEL_DOC) {
if (((MathModelWindowManager) documentWindowManager).hasUnappliedChanges()) {
String msg = "Changes have been made in VCML Editor, please click \"Apply Changes\" or \"Cancel\" to proceed.";
PopupGenerator.showErrorDialog(documentWindowManager, msg);
throw UserCancelException.CANCEL_UNAPPLIED_CHANGES;
}
}
boolean isChanged = true;
Version v = documentWindowManager.getVCDocument().getVersion();
if (v == null || !v.getOwner().equals(documentManager.getSessionManager().getUser())) {
isChanged = true;
} else {
try {
isChanged = documentManager.isChanged(documentWindowManager.getVCDocument());
} catch (DataAccessException exc) {
String choice = PopupGenerator.showWarningDialog(documentWindowManager, documentWindowManager.getUserPreferences(), UserMessage.warn_UnableToCheckForChanges, null);
if (!choice.equals(UserMessage.OPTION_CONTINUE)) {
throw UserCancelException.WARN_UNABLE_CHECK;
}
}
}
if (!isChanged) {
if (whileSavingForRunningSims) {
// just skip the saves and go ahead
hashTable.put("conditionalSkip", new String[] { SaveDocument.class.getName(), CheckBeforeDelete.class.getName(), DeleteOldDocument.class.getName() });
} else {
String choice = PopupGenerator.showWarningDialog(documentWindowManager, documentWindowManager.getUserPreferences(), UserMessage.warn_UnchangedDocument, null);
if (choice.equals(UserMessage.OPTION_SAVE_AS_NEW)) {
// user chose to Save As
throw UserCancelException.CHOOSE_SAVE_AS;
} else {
// user canceled, just show existing document
throw UserCancelException.WARN_NO_CHANGES;
}
}
}
}
Aggregations