Search in sources :

Example 21 with DocumentManager

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);
}
Also used : DocumentManager(cbit.vcell.clientdb.DocumentManager)

Example 22 with 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;
        }
    }
}
Also used : VCDocument(org.vcell.util.document.VCDocument) Simulation(cbit.vcell.solver.Simulation) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) Version(org.vcell.util.document.Version) DocumentManager(cbit.vcell.clientdb.DocumentManager)

Example 23 with DocumentManager

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;
            }
        }
    }
}
Also used : DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) Version(org.vcell.util.document.Version) DocumentManager(cbit.vcell.clientdb.DocumentManager) MathModelWindowManager(cbit.vcell.client.MathModelWindowManager) DataAccessException(org.vcell.util.DataAccessException)

Example 24 with DocumentManager

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;
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) MathModel(cbit.vcell.mathmodel.MathModel) VCDocument(org.vcell.util.document.VCDocument) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) BioModel(cbit.vcell.biomodel.BioModel) DocumentManager(cbit.vcell.clientdb.DocumentManager) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo)

Example 25 with DocumentManager

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");
    }
}
Also used : VCDocument(org.vcell.util.document.VCDocument) TopLevelWindowManager(cbit.vcell.client.TopLevelWindowManager) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) DocumentManager(cbit.vcell.clientdb.DocumentManager) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) DatabaseWindowManager(cbit.vcell.client.DatabaseWindowManager)

Aggregations

DocumentManager (cbit.vcell.clientdb.DocumentManager)30 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)10 Hashtable (java.util.Hashtable)10 DocumentWindowManager (cbit.vcell.client.DocumentWindowManager)6 VCDocument (org.vcell.util.document.VCDocument)6 UserCancelException (org.vcell.util.UserCancelException)5 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)5 BioModel (cbit.vcell.biomodel.BioModel)4 Component (java.awt.Component)4 File (java.io.File)4 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)3 DatabaseWindowManager (cbit.vcell.client.DatabaseWindowManager)3 DocumentWindow (cbit.vcell.client.desktop.DocumentWindow)3 FieldDataFileOperationSpec (cbit.vcell.field.io.FieldDataFileOperationSpec)3 GeometryInfo (cbit.vcell.geometry.GeometryInfo)3 RegionImage (cbit.vcell.geometry.RegionImage)3 DataAccessException (org.vcell.util.DataAccessException)3 VCImageUncompressed (cbit.image.VCImageUncompressed)2 AnnotatedImageDataset (cbit.vcell.VirtualMicroscopy.importer.AnnotatedImageDataset)2 MicroscopyXmlReader (cbit.vcell.VirtualMicroscopy.importer.MicroscopyXmlReader)2