Search in sources :

Example 26 with VCDocument

use of org.vcell.util.document.VCDocument in project vcell by virtualcell.

the class TestingFrameworkWindowPanel method getUserSelectedSimulationInfo.

private TFGenerateReport.VCDocumentAndSimInfo getUserSelectedSimulationInfo() throws Exception {
    final String CANCEL_STRING = "Cancel";
    final String BM_STRING = "BioModel";
    final String MM_STRING = "MathModel";
    String result = PopupGenerator.showWarningDialog(this, "Choose Reference Model Type.", new String[] { BM_STRING, MM_STRING, CANCEL_STRING }, CANCEL_STRING);
    if (result == null || result.equals(CANCEL_STRING)) {
        throw UserCancelException.CANCEL_GENERIC;
    }
    VCDocumentInfo userDefinedRegrRefModel = null;
    VCDocument vcDocument = null;
    if (result.equals(BM_STRING)) {
        userDefinedRegrRefModel = getTestingFrameworkWindowManager().getRequestManager().selectBioModelInfo(getTestingFrameworkWindowManager());
        vcDocument = getTestingFrameworkWindowManager().getRequestManager().getDocumentManager().getBioModel(userDefinedRegrRefModel.getVersion().getVersionKey());
    } else {
        userDefinedRegrRefModel = getTestingFrameworkWindowManager().getRequestManager().selectMathModelInfo(getTestingFrameworkWindowManager());
        vcDocument = getTestingFrameworkWindowManager().getRequestManager().getDocumentManager().getMathModel(userDefinedRegrRefModel.getVersion().getVersionKey());
    }
    SimulationInfo simInfo = getTestingFrameworkWindowManager().getUserSelectedRefSimInfo(getTestingFrameworkWindowManager().getRequestManager(), userDefinedRegrRefModel);
    TFGenerateReport.VCDocumentAndSimInfo vcDocumentAndsimInfo = new TFGenerateReport.VCDocumentAndSimInfo(simInfo, vcDocument);
    return vcDocumentAndsimInfo;
}
Also used : VCDocument(org.vcell.util.document.VCDocument) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) TFGenerateReport(cbit.vcell.client.task.TFGenerateReport) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 27 with VCDocument

use of org.vcell.util.document.VCDocument in project vcell by virtualcell.

the class ClientRequestManager method checkBeforeClosing.

/**
 * Insert the method's description here.
 * Creation date: (5/21/2004 4:20:47 AM)
 * @param windowManager cbit.vcell.client.desktop.DocumentWindowManager
 */
private CloseOption checkBeforeClosing(DocumentWindowManager windowManager) {
    getMdiManager().showWindow(windowManager.getManagerID());
    // we need to check for changes and get user confirmation...
    VCDocument vcDocument = windowManager.getVCDocument();
    if (vcDocument.getVersion() == null && !isDifferentFromBlank(vcDocument.getDocumentType(), vcDocument)) {
        return CloseOption.CLOSE_IN_ANY_CASE;
    }
    boolean isChanged = true;
    try {
        isChanged = getDocumentManager().isChanged(vcDocument);
    } catch (Exception exc) {
        exc.printStackTrace();
        String choice = PopupGenerator.showWarningDialog(windowManager, getUserPreferences(), UserMessage.warn_UnableToCheckForChanges, null);
        if (choice.equals(UserMessage.OPTION_CANCEL)) {
            // user canceled
            return CloseOption.CANCEL_CLOSE;
        }
    }
    // warn if necessary
    if (isChanged) {
        String choice = PopupGenerator.showWarningDialog(windowManager, getUserPreferences(), UserMessage.warn_close, null);
        if (choice.equals(UserMessage.OPTION_CANCEL)) {
            // user canceled
            return CloseOption.CANCEL_CLOSE;
        }
        if (choice.equals(UserMessage.OPTION_YES)) {
            return CloseOption.SAVE_AND_CLOSE;
        }
    }
    // nothing changed, or user confirmed, close it
    return CloseOption.CLOSE_IN_ANY_CASE;
}
Also used : VCDocument(org.vcell.util.document.VCDocument) ProgrammingException(org.vcell.util.ProgrammingException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException)

Example 28 with VCDocument

use of org.vcell.util.document.VCDocument in project vcell by virtualcell.

the class IssueTableModel method getValueAt.

public Object getValueAt(int rowIndex, int columnIndex) {
    VCDocument vcDocument = (issueManager != null) ? (issueManager.getVCDocument()) : null;
    Issue issue = getValueAt(rowIndex);
    switch(columnIndex) {
        case COLUMN_DESCRIPTION:
            return issue;
        case COLUMN_URL:
            {
                String url = issue.getHyperlink();
                if (url == null) {
                    return "";
                }
                return "<html><a href=\"" + url + "\">More</a></html>";
            }
        case COLUMN_SOURCE:
            return getSourceObjectDescription(vcDocument, issue);
        case COLUMN_PATH:
            return getSourceObjectPathDescription(vcDocument, issue);
    }
    return null;
}
Also used : Issue(org.vcell.util.Issue) VCDocument(org.vcell.util.document.VCDocument)

Example 29 with VCDocument

use of org.vcell.util.document.VCDocument 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 30 with VCDocument

use of org.vcell.util.document.VCDocument 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)

Aggregations

VCDocument (org.vcell.util.document.VCDocument)38 BioModel (cbit.vcell.biomodel.BioModel)14 MathModel (cbit.vcell.mathmodel.MathModel)11 UserCancelException (org.vcell.util.UserCancelException)11 Simulation (cbit.vcell.solver.Simulation)10 DataAccessException (org.vcell.util.DataAccessException)10 DocumentWindowManager (cbit.vcell.client.DocumentWindowManager)9 IOException (java.io.IOException)9 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)8 PropertyVetoException (java.beans.PropertyVetoException)7 File (java.io.File)7 DocumentManager (cbit.vcell.clientdb.DocumentManager)6 Geometry (cbit.vcell.geometry.Geometry)6 SimulationContext (cbit.vcell.mapping.SimulationContext)6 UtilCancelException (org.vcell.util.UtilCancelException)6 ImageException (cbit.image.ImageException)5 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 GeometryException (cbit.vcell.geometry.GeometryException)5 ExpressionException (cbit.vcell.parser.ExpressionException)5 Hashtable (java.util.Hashtable)5