use of cbit.vcell.clientdb.DocumentManager in project vcell by virtualcell.
the class TestingFrmwkTreeModel method setDocumentManager.
/**
* Sets the documentManager property (cbit.vcell.clientdb.DocumentManager) value.
* @param documentManager The new value for the property.
* @see #getDocumentManager
*/
public void setDocumentManager(cbit.vcell.clientdb.DocumentManager documentManager) {
cbit.vcell.clientdb.DocumentManager oldValue = fieldDocumentManager;
fieldDocumentManager = documentManager;
firePropertyChange(CommonTask.DOCUMENT_MANAGER.name, oldValue, documentManager);
}
use of cbit.vcell.clientdb.DocumentManager in project vcell by virtualcell.
the class CheckBeforeDelete 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 Exception {
DocumentWindowManager documentWindowManager = (DocumentWindowManager) hashTable.get(CommonTask.DOCUMENT_WINDOW_MANAGER.name);
// JFrame currentDocumentWindow = (JFrame)hashTable.get("currentDocumentWindow");
VCDocument currentDocument = documentWindowManager.getVCDocument();
if (!hashTable.containsKey(SaveDocument.DOC_KEY)) {
throw new RuntimeException("CheckBeforeDelete task called although SaveDocument task did not complete - should have aborted!!");
}
// Don't delete ARCHIVE or PUBLISH documents
if (!currentDocument.getVersion().getFlag().compareEqual(VersionFlag.Current)) {
hashTable.put("conditionalSkip", new String[] { DeleteOldDocument.class.getName() });
return;
}
DocumentManager documentManager = (DocumentManager) hashTable.get(CommonTask.DOCUMENT_MANAGER.name);
Simulation[] simulations = (Simulation[]) hashTable.get("simulations");
VCDocument savedDocument = (VCDocument) hashTable.get(SaveDocument.DOC_KEY);
// just to make sure, verify that we actually did save a new edition
Version oldVersion = currentDocument.getVersion();
Version newVersion = savedDocument.getVersion();
if (newVersion.getVersionKey().compareEqual(oldVersion.getVersionKey())) {
// throw new DataAccessException("CheckBeforeDelete task called but saved document has same version with current document");
hashTable.put("conditionalSkip", new String[] { DeleteOldDocument.class.getName() });
return;
}
// we saved a new one, now check for lost simulation data and warn the user
Simulation[] simulationsWithLostResults = null;
switch(currentDocument.getDocumentType()) {
case BIOMODEL_DOC:
{
simulationsWithLostResults = checkLostResults((BioModel) currentDocument, (BioModel) savedDocument, documentManager, simulations);
break;
}
case MATHMODEL_DOC:
{
simulationsWithLostResults = checkLostResults((MathModel) currentDocument, (MathModel) savedDocument, documentManager, simulations);
break;
}
case GEOMETRY_DOC:
default:
// nothing to check for in this case
return;
}
boolean bLost = simulationsWithLostResults != null && simulationsWithLostResults.length > 0;
if (bLost) {
String choice = PopupGenerator.showWarningDialog(documentWindowManager, documentWindowManager.getUserPreferences(), UserMessage.question_LostResults, null);
if (choice.equals(UserMessage.OPTION_SAVE_AS_NEW_EDITION)) {
// user canceled deletion
throw UserCancelException.CANCEL_DELETE_OLD;
}
if (choice.equals(UserMessage.OPTION_CANCEL)) {
throw UserCancelException.CANCEL_GENERIC;
}
}
}
use of cbit.vcell.clientdb.DocumentManager 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;
}
}
}
}
use of cbit.vcell.clientdb.DocumentManager in project vcell by virtualcell.
the class DeleteOldDocument 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 dwm = (DocumentWindowManager) fetch(hashTable, DOCUMENT_WINDOW_MANAGER);
VCDocument currentDocument = dwm.getVCDocument();
DocumentManager documentManager = (DocumentManager) fetch(hashTable, DOCUMENT_MANAGER);
switch(currentDocument.getDocumentType()) {
case BIOMODEL_DOC:
{
// make the info
BioModel oldBioModel = (BioModel) currentDocument;
BioModelInfo oldBioModelInfo = documentManager.getBioModelInfo(oldBioModel.getVersion().getVersionKey());
// delete document
documentManager.delete(oldBioModelInfo);
break;
}
case MATHMODEL_DOC:
{
// make the info
MathModel oldMathModel = (MathModel) currentDocument;
MathModelInfo oldMathModelInfo = documentManager.getMathModelInfo(oldMathModel.getVersion().getVersionKey());
// delete document
documentManager.delete(oldMathModelInfo);
break;
}
case GEOMETRY_DOC:
{
// make the info
Geometry oldGeometry = (Geometry) currentDocument;
GeometryInfo oldGeometryInfo = documentManager.getGeometryInfo(oldGeometry.getVersion().getVersionKey());
// delete document
documentManager.delete(oldGeometryInfo);
break;
}
default:
break;
}
}
use of cbit.vcell.clientdb.DocumentManager in project vcell by virtualcell.
the class DocumentToExport 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
*/
@Override
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
TopLevelWindowManager topLevelWindowManager = extractRequired(hashTable, TopLevelWindowManager.class, "topLevelWindowManager");
VCDocument doc = null;
if (topLevelWindowManager instanceof DocumentWindowManager) {
doc = ((DocumentWindowManager) topLevelWindowManager).getVCDocument();
} else if (topLevelWindowManager instanceof DatabaseWindowManager) {
DocumentManager documentManager = extractRequired(hashTable, DocumentManager.class, CommonTask.DOCUMENT_MANAGER.name);
VCDocumentInfo documentInfo = ((DatabaseWindowManager) topLevelWindowManager).getPanelSelection();
if (documentInfo instanceof BioModelInfo) {
BioModelInfo bmi = (BioModelInfo) documentInfo;
doc = documentManager.getBioModel(bmi);
} else if (documentInfo instanceof MathModelInfo) {
MathModelInfo mmi = (MathModelInfo) documentInfo;
doc = documentManager.getMathModel(mmi);
} else if (documentInfo instanceof GeometryInfo) {
GeometryInfo gmi = (GeometryInfo) documentInfo;
doc = documentManager.getGeometry(gmi);
}
if (doc == null) {
throw new IllegalStateException("export called on DatabaseWindowManager with selection " + documentInfo);
}
}
if (doc != null) {
hashTable.put(EXPORT_DOCUMENT, doc);
} else {
throw new UnsupportedOperationException("TopLevelWindowManager subclass " + topLevelWindowManager.getClass().getName() + " does not support exporting to document");
}
}
Aggregations