Search in sources :

Example 6 with VCDocument

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

the class ClientRequestManager method runSimulations.

public void runSimulations(final ClientSimManager clientSimManager, final Simulation[] simulations) {
    DocumentWindowManager documentWindowManager = clientSimManager.getDocumentWindowManager();
    /*	run some quick checks to see if we need to do a SaveAs */
    boolean needSaveAs = false;
    if (documentWindowManager.getVCDocument().getVersion() == null) {
        // never saved
        needSaveAs = true;
    } else if (!documentWindowManager.getVCDocument().getVersion().getOwner().compareEqual(getDocumentManager().getUser())) {
        // not the owner
        // keep the user informed this time
        String choice = PopupGenerator.showWarningDialog(documentWindowManager, getUserPreferences(), UserMessage.warn_SaveNotOwner, null);
        if (choice.equals(UserMessage.OPTION_SAVE_AS_NEW)) {
            needSaveAs = true;
        } else {
            // user canceled, just show existing document
            getMdiManager().showWindow(documentWindowManager.getManagerID());
            throw new UserCancelException("user canceled");
        }
    }
    // Before running the simulation, check if all the sizes of structures are set
    if (simulations != null && simulations.length > 0) {
        VCDocument vcd = documentWindowManager.getVCDocument();
        if (vcd instanceof BioModel) {
            String stochChkMsg = null;
            // we want to check when there is stochastic application if the rate laws set in model can be automatically transformed.
            for (int i = 0; i < simulations.length; i++) {
                if (simulations[i].getMathDescription().isNonSpatialStoch() || simulations[i].getMathDescription().isSpatialStoch() || simulations[i].getMathDescription().isSpatialHybrid()) {
                    if (stochChkMsg == null) {
                        stochChkMsg = ((BioModel) vcd).getModel().isValidForStochApp();
                    }
                    if (!(stochChkMsg.equals(""))) {
                        DialogUtils.showErrorDialog(documentWindowManager.getComponent(), "Problem in simulation: " + simulations[i].getName() + ".\n" + stochChkMsg);
                        throw new RuntimeException("Problem in simulation: " + simulations[i].getName() + "\n" + stochChkMsg);
                    }
                }
            }
        }
    }
    // 
    for (int i = 0; simulations != null && i < simulations.length; i++) {
        if (simulations[i].getSimulationVersion() != null && simulations[i].getSimulationVersion().getParentSimulationReference() != null) {
            simulations[i].clearVersion();
        }
    }
    /* now start the dirty work */
    /* block document window */
    JFrame currentDocumentWindow = getMdiManager().blockWindow(documentWindowManager.getManagerID());
    /* prepare hashtable for tasks */
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    hash.put("mdiManager", getMdiManager());
    hash.put(DocumentManager.IDENT, getDocumentManager());
    hash.put(CommonTask.DOCUMENT_WINDOW_MANAGER.name, documentWindowManager);
    hash.put("currentDocumentWindow", currentDocumentWindow);
    hash.put("clientSimManager", clientSimManager);
    hash.put("simulations", simulations);
    hash.put("jobManager", getClientServerManager().getJobManager());
    hash.put("requestManager", this);
    /* create tasks */
    AsynchClientTask[] tasks = null;
    if (needSaveAs) {
        // check document consistency first
        AsynchClientTask documentValid = new DocumentValidTask();
        AsynchClientTask setMathDescription = new SetMathDescription();
        // get a new name
        AsynchClientTask newName = new NewName();
        // save it
        AsynchClientTask saveDocument = new SaveDocument();
        // clean up
        AsynchClientTask finishSave = new FinishSave();
        // run the simulations
        AsynchClientTask runSims = new RunSims();
        // assemble array
        tasks = new AsynchClientTask[] { documentValid, setMathDescription, newName, saveDocument, finishSave, runSims };
    } else {
        // check document consistency first
        AsynchClientTask documentValid = new DocumentValidTask();
        AsynchClientTask setMathDescription = new SetMathDescription();
        // check if unchanged document
        AsynchClientTask checkUnchanged = new CheckUnchanged(true);
        // save it
        AsynchClientTask saveDocument = new SaveDocument();
        // check for lost results
        AsynchClientTask checkBeforeDelete = new CheckBeforeDelete();
        // delete old document
        AsynchClientTask deleteOldDocument = new DeleteOldDocument();
        // clean up
        AsynchClientTask finishSave = new FinishSave();
        // run the simulations
        AsynchClientTask runSims = new RunSims();
        // assemble array
        tasks = new AsynchClientTask[] { documentValid, setMathDescription, checkUnchanged, saveDocument, checkBeforeDelete, deleteOldDocument, finishSave, runSims };
    }
    /* run the tasks */
    ClientTaskDispatcher.dispatch(currentDocumentWindow, hash, tasks, true);
}
Also used : DocumentValidTask(cbit.vcell.client.task.DocumentValidTask) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCDocument(org.vcell.util.document.VCDocument) FinishSave(cbit.vcell.client.task.FinishSave) DeleteOldDocument(cbit.vcell.client.task.DeleteOldDocument) Hashtable(java.util.Hashtable) UserCancelException(org.vcell.util.UserCancelException) SetMathDescription(cbit.vcell.client.task.SetMathDescription) SaveDocument(cbit.vcell.client.task.SaveDocument) JFrame(javax.swing.JFrame) CheckUnchanged(cbit.vcell.client.task.CheckUnchanged) BioModel(cbit.vcell.biomodel.BioModel) CSGObject(cbit.vcell.geometry.CSGObject) NewName(cbit.vcell.client.task.NewName) RunSims(cbit.vcell.client.task.RunSims) CheckBeforeDelete(cbit.vcell.client.task.CheckBeforeDelete)

Example 7 with VCDocument

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

the class Translator method translate.

public VCDocument translate(Reader reader, boolean validationOn) throws Exception {
    if (validationOn) {
        this.sRoot = (XmlUtil.readXML(reader, schemaLocation, null, schemaLocationPropName)).getRootElement();
        String errorLog = XmlUtil.getErrorLog();
        if (errorLog.length() > 0) {
            System.err.println(errorLog);
            if (vcLogger != null) {
                vcLogger.sendMessage(VCLogger.Priority.LowPriority, VCLogger.ErrorType.SchemaValidation);
            // vcLogger.sendMessage(VCLogger.LOW_PRIORITY, TranslationMessage.SCHEMA_VALIDATION_ERROR,
            // "The source model has invalid elements/attributes:\n" + errorLog)
            }
        }
    } else {
        this.sRoot = (XmlUtil.readXML(reader, null, null, null)).getRootElement();
    }
    VCDocument vcDoc = translate();
    if (vcLogger != null && vcLogger.hasMessages()) {
        vcLogger.sendAllMessages();
    }
    return vcDoc;
}
Also used : VCDocument(org.vcell.util.document.VCDocument)

Example 8 with VCDocument

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

the class ClientSimManager method showSimulationResults0.

private AsynchClientTask[] showSimulationResults0(final boolean isLocal, final ViewerType viewerType) {
    // Create the AsynchClientTasks
    ArrayList<AsynchClientTask> taskList = new ArrayList<AsynchClientTask>();
    taskList.add(new AsynchClientTaskFunction(h -> {
        h.put(H_LOCAL_SIM, isLocal);
        h.put(H_VIEWER_TYPE, viewerType);
    }, "setLocal", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING));
    final DocumentWindowManager documentWindowManager = getDocumentWindowManager();
    AsynchClientTask retrieveResultsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @SuppressWarnings("unchecked")
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            Simulation[] simsToShow = (Simulation[]) hashTable.get("simsArray");
            for (int i = 0; i < simsToShow.length; i++) {
                final Simulation sim = simsToShow[i];
                final VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
                final SimulationWindow simWindow = documentWindowManager.haveSimulationWindow(vcSimulationIdentifier);
                OutputContext outputContext = (OutputContext) hashTable.get("outputContext");
                if (simWindow == null && (viewerType == ViewerType.BothNativeAndPython || viewerType == ViewerType.NativeViewer_only)) {
                    try {
                        // make the manager and wire it up
                        DataViewerController dataViewerController = null;
                        if (!isLocal) {
                            dataViewerController = documentWindowManager.getRequestManager().getDataViewerController(outputContext, sim, 0);
                            // For changes in time or variable
                            documentWindowManager.addDataListener(dataViewerController);
                        } else {
                            // ---- preliminary : construct the localDatasetControllerProvider
                            File primaryDir = ResourceUtil.getLocalRootDir();
                            User usr = sim.getVersion().getOwner();
                            DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
                            ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
                            LocalDataSetControllerProvider localDSCProvider = new LocalDataSetControllerProvider(usr, dataSetControllerImpl, localExportServiceImpl);
                            VCDataManager vcDataManager = new VCDataManager(localDSCProvider);
                            File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
                            LocalVCDataIdentifier vcDataId = new LocalVCSimulationDataIdentifier(vcSimulationIdentifier, 0, localSimDir);
                            DataManager dataManager = null;
                            if (sim.isSpatial()) {
                                dataManager = new PDEDataManager(outputContext, vcDataManager, vcDataId);
                            } else {
                                dataManager = new ODEDataManager(outputContext, vcDataManager, vcDataId);
                            }
                            dataViewerController = new SimResultsViewerController(dataManager, sim);
                            dataSetControllerImpl.addDataJobListener(documentWindowManager);
                        }
                        // make the viewer
                        Hashtable<VCSimulationIdentifier, DataViewerController> dataViewerControllers = (Hashtable<VCSimulationIdentifier, DataViewerController>) hashTable.get(H_DATA_VIEWER_CONTROLLERS);
                        if (dataViewerControllers == null) {
                            dataViewerControllers = new Hashtable<VCSimulationIdentifier, DataViewerController>();
                            hashTable.put(H_DATA_VIEWER_CONTROLLERS, dataViewerControllers);
                        }
                        dataViewerControllers.put(vcSimulationIdentifier, dataViewerController);
                    } catch (Throwable exc) {
                        exc.printStackTrace(System.out);
                        saveFailure(hashTable, sim, exc);
                    }
                }
                try {
                    if (viewerType == ViewerType.PythonViewer_only || viewerType == ViewerType.BothNativeAndPython) {
                        VtkManager vtkManager = null;
                        if (!isLocal) {
                            vtkManager = documentWindowManager.getRequestManager().getVtkManager(outputContext, new VCSimulationDataIdentifier(vcSimulationIdentifier, 0));
                        } else {
                            // ---- preliminary : construct the localDatasetControllerProvider
                            File primaryDir = ResourceUtil.getLocalRootDir();
                            User usr = sim.getVersion().getOwner();
                            DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
                            ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
                            LocalDataSetControllerProvider localDSCProvider = new LocalDataSetControllerProvider(usr, dataSetControllerImpl, localExportServiceImpl);
                            VCDataManager vcDataManager = new VCDataManager(localDSCProvider);
                            File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
                            VCSimulationDataIdentifier simulationDataIdentifier = new LocalVCSimulationDataIdentifier(vcSimulationIdentifier, 0, localSimDir);
                            vtkManager = new VtkManager(outputContext, vcDataManager, simulationDataIdentifier);
                        }
                        // 
                        // test ability to read data
                        // 
                        VtuVarInfo[] vtuVarInfos = vtkManager.getVtuVarInfos();
                        double[] times = vtkManager.getDataSetTimes();
                        // 
                        // create the SimulationDataSetRef
                        // 
                        VCDocument modelDocument = null;
                        if (documentWindowManager instanceof BioModelWindowManager) {
                            modelDocument = ((BioModelWindowManager) documentWindowManager).getBioModel();
                        } else if (documentWindowManager instanceof MathModelWindowManager) {
                            modelDocument = ((MathModelWindowManager) documentWindowManager).getMathModel();
                        }
                        SimulationDataSetRef simulationDataSetRef = VCellClientDataServiceImpl.createSimulationDataSetRef(sim, modelDocument, 0, isLocal);
                        // Hashtable<VCSimulationIdentifier, SimulationDataSetRef> simDataSetRefs = (Hashtable<VCSimulationIdentifier, SimulationDataSetRef>)hashTable.get(H_SIM_DATASET_REFS);
                        // if (simDataSetRefs == null) {
                        // simDataSetRefs = new Hashtable<VCSimulationIdentifier, SimulationDataSetRef>();
                        // hashTable.put(H_SIM_DATASET_REFS, simDataSetRefs);
                        // }
                        // simDataSetRefs.put(vcSimulationIdentifier, simulationDataSetRef);
                        File visitExe = VCellConfiguration.getFileProperty(PropertyLoader.visitExe);
                        if (visitExe != null) {
                            VisitSupport.launchVisTool(visitExe, simulationDataSetRef);
                        }
                    }
                } catch (Throwable exc) {
                    exc.printStackTrace(System.out);
                    saveFailure(hashTable, sim, exc);
                }
            }
        }
    };
    taskList.add(retrieveResultsTask);
    AsynchClientTask displayResultsTask = new AsynchClientTask("Showing results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @SuppressWarnings("unchecked")
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            boolean isLocal = fetch(hashTable, H_LOCAL_SIM, Boolean.class, true);
            SimulationWindow.LocalState localState = isLocal ? LocalState.LOCAL : LocalState.SERVER;
            Hashtable<Simulation, Throwable> failures = (Hashtable<Simulation, Throwable>) hashTable.get(H_FAILURES);
            Simulation[] simsToShow = (Simulation[]) hashTable.get("simsArray");
            for (int i = 0; i < simsToShow.length; i++) {
                final Simulation sim = simsToShow[i];
                if (failures != null && failures.containsKey(sim)) {
                    continue;
                }
                final VCSimulationIdentifier vcSimulationIdentifier = simsToShow[i].getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
                final SimulationWindow simWindow = documentWindowManager.haveSimulationWindow(vcSimulationIdentifier);
                if (simWindow != null) {
                    ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(documentWindowManager.getComponent());
                    ChildWindow childWindow = childWindowManager.getChildWindowFromContext(simWindow);
                    if (childWindow == null) {
                        childWindow = childWindowManager.addChildWindow(simWindow.getDataViewer(), simWindow);
                        childWindow.pack();
                        childWindow.setIsCenteredOnParent();
                        childWindow.show();
                    }
                    setFinalWindow(hashTable, childWindow);
                    simWindow.setLocalState(localState);
                } else {
                    // wire it up the viewer
                    Hashtable<VCSimulationIdentifier, DataViewerController> dataViewerControllers = (Hashtable<VCSimulationIdentifier, DataViewerController>) hashTable.get(H_DATA_VIEWER_CONTROLLERS);
                    DataViewerController viewerController = dataViewerControllers.get(vcSimulationIdentifier);
                    Throwable ex = (failures == null ? null : failures.get(sim));
                    if (viewerController != null && ex == null) {
                        // no failure
                        DataViewer viewer = viewerController.createViewer();
                        getSimWorkspace().getSimulationOwner().getOutputFunctionContext().addPropertyChangeListener(viewerController);
                        documentWindowManager.addExportListener(viewer);
                        // For data related activities such as calculating statistics
                        documentWindowManager.addDataJobListener(viewer);
                        viewer.setSimulationModelInfo(new SimulationWorkspaceModelInfo(getSimWorkspace().getSimulationOwner(), sim.getName()));
                        viewer.setDataViewerManager(documentWindowManager);
                        SimulationWindow newWindow = new SimulationWindow(vcSimulationIdentifier, sim, getSimWorkspace().getSimulationOwner(), viewer);
                        BeanUtils.addCloseWindowKeyboardAction(newWindow.getDataViewer());
                        documentWindowManager.addResultsFrame(newWindow);
                        setFinalWindow(hashTable, viewer);
                        newWindow.setLocalState(localState);
                    }
                }
            }
            StringBuffer failMessage = new StringBuffer();
            if (failures != null) {
                if (!failures.isEmpty()) {
                    failMessage.append("Error, " + failures.size() + " of " + simsToShow.length + " sim results failed to display:\n");
                    Enumeration<Simulation> en = failures.keys();
                    while (en.hasMoreElements()) {
                        Simulation sim = en.nextElement();
                        Throwable exc = (Throwable) failures.get(sim);
                        failMessage.append("'" + sim.getName() + "' - " + exc.getMessage());
                    }
                }
            }
            if (failMessage.length() > 0) {
                PopupGenerator.showErrorDialog(ClientSimManager.this.getDocumentWindowManager(), failMessage.toString());
            }
        }
    };
    if (viewerType == ViewerType.BothNativeAndPython || viewerType == ViewerType.NativeViewer_only) {
        taskList.add(displayResultsTask);
    }
    // Dispatch the tasks using the ClientTaskDispatcher.
    AsynchClientTask[] taskArray = new AsynchClientTask[taskList.size()];
    taskList.toArray(taskArray);
    return taskArray;
}
Also used : User(org.vcell.util.document.User) DataViewerController(cbit.vcell.client.data.DataViewerController) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) Enumeration(java.util.Enumeration) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) SimulationWindow(cbit.vcell.client.desktop.simulation.SimulationWindow) EventObject(java.util.EventObject) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) Vector(java.util.Vector) DataViewer(cbit.vcell.client.data.DataViewer) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) SmoldynSolver(org.vcell.solver.smoldyn.SmoldynSolver) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) SimulationContext(cbit.vcell.mapping.SimulationContext) PrintWriter(java.io.PrintWriter) VisitSupport(cbit.vcell.resource.VisitSupport) Simulation(cbit.vcell.solver.Simulation) NetworkGenerationRequirements(cbit.vcell.mapping.SimulationContext.NetworkGenerationRequirements) VCDataManager(cbit.vcell.simdata.VCDataManager) BeanUtils(org.vcell.util.BeanUtils) Solver(cbit.vcell.solver.server.Solver) Collection(java.util.Collection) SimulationWorkspace(cbit.vcell.client.desktop.simulation.SimulationWorkspace) SolverListener(cbit.vcell.solver.server.SolverListener) VtkManager(cbit.vcell.simdata.VtkManager) SolverEvent(cbit.vcell.solver.server.SolverEvent) AsynchClientTaskFunction(cbit.vcell.client.task.AsynchClientTaskFunction) Dimension(java.awt.Dimension) SimulationJob(cbit.vcell.solver.SimulationJob) ClientTaskDispatcher(cbit.vcell.client.task.ClientTaskDispatcher) VCellConfiguration(cbit.vcell.resource.VCellConfiguration) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) DataProcessingInstructions(cbit.vcell.solver.DataProcessingInstructions) SimulationOwner(cbit.vcell.solver.SimulationOwner) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) SimulationWorkspaceModelInfo(cbit.vcell.client.data.SimulationWorkspaceModelInfo) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) VCellClientDataServiceImpl(cbit.vcell.client.data.VCellClientDataServiceImpl) OutputContext(cbit.vcell.simdata.OutputContext) SimulationTask(cbit.vcell.messaging.server.SimulationTask) VCDocument(org.vcell.util.document.VCDocument) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) TempSimulation(cbit.vcell.solver.TempSimulation) ArrayList(java.util.ArrayList) LocalState(cbit.vcell.client.desktop.simulation.SimulationWindow.LocalState) SolverFactory(cbit.vcell.solver.server.SolverFactory) SolverStatus(cbit.vcell.solver.server.SolverStatus) SimDataConstants(cbit.vcell.simdata.SimDataConstants) SolverException(cbit.vcell.solver.SolverException) Hashtable(java.util.Hashtable) SimulationStatusDetailsPanel(cbit.vcell.client.desktop.simulation.SimulationStatusDetailsPanel) SimulationStatus(cbit.vcell.server.SimulationStatus) SimulationDataSetRef(cbit.vcell.client.pyvcellproxy.SimulationDataSetRef) PDEDataManager(cbit.vcell.simdata.PDEDataManager) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) ResourceUtil(cbit.vcell.resource.ResourceUtil) ODEDataManager(cbit.vcell.simdata.ODEDataManager) SmoldynFileWriter(org.vcell.solver.smoldyn.SmoldynFileWriter) IOException(java.io.IOException) PropertyLoader(cbit.vcell.resource.PropertyLoader) InputStreamReader(java.io.InputStreamReader) File(java.io.File) SolverUtilities(cbit.vcell.solver.SolverUtilities) TokenMangler(org.vcell.util.TokenMangler) SolverDescription(cbit.vcell.solver.SolverDescription) DialogUtils(org.vcell.util.gui.DialogUtils) SimulationStatusDetails(cbit.vcell.client.desktop.simulation.SimulationStatusDetails) ProgressDialogListener(org.vcell.util.ProgressDialogListener) DataManager(cbit.vcell.simdata.DataManager) InputStream(java.io.InputStream) UserCancelException(org.vcell.util.UserCancelException) LocalState(cbit.vcell.client.desktop.simulation.SimulationWindow.LocalState) VtuVarInfo(org.vcell.vis.io.VtuVarInfo) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) User(org.vcell.util.document.User) ArrayList(java.util.ArrayList) SimulationDataSetRef(cbit.vcell.client.pyvcellproxy.SimulationDataSetRef) AsynchClientTaskFunction(cbit.vcell.client.task.AsynchClientTaskFunction) DataViewerController(cbit.vcell.client.data.DataViewerController) DataViewer(cbit.vcell.client.data.DataViewer) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) VCDataManager(cbit.vcell.simdata.VCDataManager) SimulationWorkspaceModelInfo(cbit.vcell.client.data.SimulationWorkspaceModelInfo) VCDocument(org.vcell.util.document.VCDocument) Hashtable(java.util.Hashtable) VCDataManager(cbit.vcell.simdata.VCDataManager) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataManager(cbit.vcell.simdata.DataManager) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) VtkManager(cbit.vcell.simdata.VtkManager) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) OutputContext(cbit.vcell.simdata.OutputContext) Simulation(cbit.vcell.solver.Simulation) TempSimulation(cbit.vcell.solver.TempSimulation) PDEDataManager(cbit.vcell.simdata.PDEDataManager) SimulationWindow(cbit.vcell.client.desktop.simulation.SimulationWindow) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) ODEDataManager(cbit.vcell.simdata.ODEDataManager) File(java.io.File)

Example 9 with VCDocument

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

the class PopupGenerator method showErrorDialog.

/**
 * showErrorDialog. If requester is of type DocumentWindowManager, offer to send context information
 * to VCellSupport
 * @param requester
 * @param message to display
 * @param ex may be null
 */
public static void showErrorDialog(TopLevelWindowManager requester, String message, Throwable ex) {
    DialogUtils.ErrorContext errorContext = null;
    if (requester instanceof DocumentWindowManager) {
        DocumentWindowManager dwm = (DocumentWindowManager) requester;
        VCDocument doc = dwm.getVCDocument();
        String contextString = doc.getName();
        Version v = doc.getVersion();
        if (v != null) {
            contextString += " " + v.identificationString();
        }
        errorContext = new DialogUtils.ErrorContext(contextString, requester.getUserPreferences());
    }
    showErrorDialog(requester.getComponent(), message, ex, errorContext);
}
Also used : VCDocument(org.vcell.util.document.VCDocument) Version(org.vcell.util.document.Version) DialogUtils(org.vcell.util.gui.DialogUtils)

Example 10 with VCDocument

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

the class IssueTableModel method getComparator.

@Override
protected Comparator<Issue> getComparator(final int col, final boolean ascending) {
    return new Comparator<Issue>() {

        public int compare(Issue o1, Issue o2) {
            VCDocument vcDocument = (issueManager != null) ? (issueManager.getVCDocument()) : null;
            int scale = ascending ? 1 : -1;
            switch(col) {
                case COLUMN_DESCRIPTION:
                    {
                        Severity s1 = o1.getSeverity();
                        Severity s2 = o2.getSeverity();
                        if (s1 == s2) {
                            return scale * o1.getMessage().compareTo(o2.getMessage());
                        } else {
                            return scale * s1.compareTo(s2);
                        }
                    }
                case COLUMN_URL:
                    {
                        String u1 = o1.getHyperlink();
                        String u2 = o2.getHyperlink();
                        return u1 != null ? u1.compareTo(u2) : -1;
                    }
                case COLUMN_SOURCE:
                    return scale * getSourceObjectDescription(vcDocument, o1).compareTo(getSourceObjectDescription(vcDocument, o2));
                case COLUMN_PATH:
                    return scale * getSourceObjectPathDescription(vcDocument, o1).compareTo(getSourceObjectPathDescription(vcDocument, o2));
            }
            return 0;
        }
    };
}
Also used : Issue(org.vcell.util.Issue) VCDocument(org.vcell.util.document.VCDocument) Severity(org.vcell.util.Issue.Severity) Comparator(java.util.Comparator)

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