Search in sources :

Example 1 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class ReactionRuleKineticsPropertiesPanel method changeFreeTextAnnotation.

private void changeFreeTextAnnotation() {
    try {
        if (reactionRule == null) {
            return;
        }
        // set text from annotationTextField in free text annotation for species in vcMetaData (from model)
        if (bioModel.getModel() != null && bioModel.getModel().getVcMetaData() != null) {
            VCMetaData vcMetaData = bioModel.getModel().getVcMetaData();
            String textAreaStr = (annotationTextArea.getText() == null || annotationTextArea.getText().length() == 0 ? null : annotationTextArea.getText());
            if (!Compare.isEqualOrNull(vcMetaData.getFreeTextAnnotation(reactionRule), textAreaStr)) {
                vcMetaData.setFreeTextAnnotation(reactionRule, textAreaStr);
            }
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
        PopupGenerator.showErrorDialog(this, "Edit Reaction Rule Error\n" + e.getMessage(), e);
    }
}
Also used : VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) PropertyVetoException(java.beans.PropertyVetoException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException)

Example 2 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class ReactionRuleKineticsPropertiesPanel method refreshInterface.

protected void refreshInterface() {
    boolean bNonNullRule = reactionRule != null && bioModel != null;
    annotationTextArea.setEditable(bNonNullRule);
    if (bNonNullRule) {
        VCMetaData vcMetaData = bioModel.getModel().getVcMetaData();
        annotationTextArea.setText(vcMetaData.getFreeTextAnnotation(reactionRule));
        nameTextField.setEditable(true);
        nameTextField.setText(reactionRule.getName());
        isReversibleCheckBox.setSelected(reactionRule.isReversible());
    } else {
        annotationTextArea.setText(null);
        nameTextField.setEditable(false);
        nameTextField.setText(null);
        isReversibleCheckBox.setSelected(false);
    }
    listLinkedPathwayObjects();
}
Also used : VCMetaData(cbit.vcell.biomodel.meta.VCMetaData)

Example 3 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class ClientRequestManager method openAfterChecking.

private void openAfterChecking(VCDocumentInfo documentInfo, final TopLevelWindowManager requester, final boolean inNewWindow) {
    final String DOCUMENT_INFO = "documentInfo";
    final String SEDML_TASK = "SedMLTask";
    final String SEDML_MODELS = "SedMLModels";
    final String BNG_UNIT_SYSTEM = "bngUnitSystem";
    final String BMDB_DEFAULT_APPLICATION = "Deterministic";
    /* asynchronous and not blocking any window */
    bOpening = true;
    Hashtable<String, Object> hashTable = new Hashtable<String, Object>();
    // may want to insert corrected VCDocumentInfo later if our import debugger
    // corrects it (BNGL Debugger).
    hashTable.put(DOCUMENT_INFO, documentInfo);
    hashTable.put("isBMDB", false);
    hashTable.put("isSEDML", false);
    // start a thread that gets it and updates the GUI by creating a new document
    // desktop
    String taskName = null;
    if (documentInfo instanceof ExternalDocInfo) {
        taskName = "Importing document";
        ExternalDocInfo externalDocInfo = (ExternalDocInfo) documentInfo;
        File file = externalDocInfo.getFile();
        if (file != null && !file.getName().isEmpty() && file.getName().endsWith("bngl")) {
            BngUnitSystem bngUnitSystem = new BngUnitSystem(BngUnitOrigin.DEFAULT);
            String fileText;
            String originalFileText;
            try {
                fileText = BeanUtils.readBytesFromFile(file, null);
                originalFileText = new String(fileText);
            } catch (IOException e1) {
                e1.printStackTrace();
                DialogUtils.showErrorDialog(requester.getComponent(), "<html>Error reading file " + file.getPath() + "</html>");
                return;
            }
            Reader reader = externalDocInfo.getReader();
            boolean bException = true;
            while (bException) {
                try {
                    BioModel bioModel = createDefaultBioModelDocument(bngUnitSystem);
                    boolean bStochastic = true;
                    boolean bRuleBased = true;
                    SimulationContext ruleBasedSimContext = bioModel.addNewSimulationContext("temp NFSim app", SimulationContext.Application.RULE_BASED_STOCHASTIC);
                    List<SimulationContext> appList = new ArrayList<SimulationContext>();
                    appList.add(ruleBasedSimContext);
                    RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
                    RbmUtils.reactionRuleLabelIndex = 0;
                    RbmUtils.reactionRuleNames.clear();
                    ASTModel astModel = RbmUtils.importBnglFile(reader);
                    // for now, hasUnitSystem() always returns false
                    if (astModel.hasUnitSystem()) {
                        bngUnitSystem = astModel.getUnitSystem();
                    }
                    if (astModel.hasCompartments()) {
                        Structure struct = bioModel.getModel().getStructure(0);
                        if (struct != null) {
                            bioModel.getModel().removeStructure(struct);
                        }
                    }
                    BnglObjectConstructionVisitor constructionVisitor = null;
                    if (!astModel.hasMolecularDefinitions()) {
                        System.out.println("Molecular Definition Block missing.");
                        constructionVisitor = new BnglObjectConstructionVisitor(bioModel.getModel(), appList, bngUnitSystem, false);
                    } else {
                        constructionVisitor = new BnglObjectConstructionVisitor(bioModel.getModel(), appList, bngUnitSystem, true);
                    }
                    astModel.jjtAccept(constructionVisitor, rbmModelContainer);
                    bException = false;
                } catch (final Exception e) {
                    e.printStackTrace(System.out);
                    BNGLDebuggerPanel panel = new BNGLDebuggerPanel(fileText, e);
                    int oKCancel = DialogUtils.showComponentOKCancelDialog(requester.getComponent(), panel, "Bngl Debugger: " + file.getName());
                    if (oKCancel == JOptionPane.CANCEL_OPTION || oKCancel == JOptionPane.DEFAULT_OPTION) {
                        throw new UserCancelException("Canceling Import");
                    }
                    // inserting <potentially> corrected DocumentInfo
                    fileText = panel.getText();
                    externalDocInfo = new ExternalDocInfo(panel.getText());
                    reader = externalDocInfo.getReader();
                    hashTable.put(DOCUMENT_INFO, externalDocInfo);
                }
            }
            if (!originalFileText.equals(fileText)) {
                // file has been modified
                String message = "Importing <b>" + file.getName() + "</b> into vCell. <br>Overwrite the file on the disk?<br>";
                message = "<html>" + message + "</html>";
                Object[] options = { "Overwrite and Import", "Import Only", "Cancel" };
                int returnCode = JOptionPane.showOptionDialog(requester.getComponent(), message, "Bngl Debugger", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[2]);
                if (returnCode == JOptionPane.YES_OPTION) {
                    try {
                        FileWriter fw = new FileWriter(file);
                        fw.write(fileText);
                        fw.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } else if (returnCode == JOptionPane.CANCEL_OPTION || returnCode == JOptionPane.CLOSED_OPTION) {
                    return;
                }
            }
            if (!(bngUnitSystem.getOrigin() == BngUnitOrigin.PARSER)) {
                BNGLUnitsPanel panel = new BNGLUnitsPanel(bngUnitSystem);
                int oKCancel = DialogUtils.showComponentOKCancelDialog(requester.getComponent(), panel, " Bngl Units Selector", null, false);
                if (oKCancel == JOptionPane.CANCEL_OPTION || oKCancel == JOptionPane.DEFAULT_OPTION) {
                    // TODO: or do nothing and continue with default values?
                    return;
                } else {
                    bngUnitSystem = panel.getUnits();
                }
            }
            hashTable.put(BNG_UNIT_SYSTEM, bngUnitSystem);
        } else if (file != null && !file.getName().isEmpty() && file.getName().toLowerCase().endsWith(".sedml")) {
            try {
                XMLSource xmlSource = externalDocInfo.createXMLSource();
                File sedmlFile = xmlSource.getXmlFile();
                SedML sedml = Libsedml.readDocument(sedmlFile).getSedMLModel();
                if (sedml == null || sedml.getModels().isEmpty()) {
                    return;
                }
                // AbstractTask chosenTask = SEDMLChooserPanel.chooseTask(sedml, requester.getComponent(),
                // file.getName());
                List<SedML> sedmls = new ArrayList<>();
                sedmls.add(sedml);
                hashTable.put(SEDML_MODELS, sedmls);
            // hashTable.put(SEDML_TASK, chosenTask);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("failed to read document: " + e.getMessage(), e);
            }
        } else if (file != null && !file.getName().isEmpty() && (file.getName().toLowerCase().endsWith(".sedx") || file.getName().toLowerCase().endsWith(".omex"))) {
            try {
                ArchiveComponents ac = null;
                ac = Libsedml.readSEDMLArchive(new FileInputStream(file));
                List<SEDMLDocument> docs = ac.getSedmlDocuments();
                List<SedML> sedmls = new ArrayList<>();
                for (SEDMLDocument doc : docs) {
                    SedML sedml = doc.getSedMLModel();
                    if (sedml == null) {
                        throw new RuntimeException("Failed importing " + file.getName());
                    }
                    if (sedml.getModels().isEmpty()) {
                        throw new RuntimeException("Unable to find any model in " + file.getName());
                    }
                    sedmls.add(sedml);
                }
                // AbstractTask chosenTask = SEDMLChooserPanel.chooseTask(sedml, requester.getComponent(),
                // file.getName());
                hashTable.put(SEDML_MODELS, sedmls);
            // hashTable.put(SEDML_TASK, chosenTask);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException("failed to read archive: " + e.getMessage(), e);
            }
        }
    } else {
        taskName = "Loading document '" + documentInfo.getVersion().getName() + "' from database";
    }
    AsynchClientTask task0 = new AsynchClientTask(taskName, AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        public void run(Hashtable<String, Object> hashTable) throws Exception {
            if (!inNewWindow) {
                // request was to replace the document in an existing window
                getMdiManager().blockWindow(requester.getManagerID());
            }
        }
    };
    AsynchClientTask task1 = new AsynchClientTask(taskName, AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            VCDocument doc = null;
            List<VCDocument> docs = new ArrayList<>();
            boolean isBMDB = false;
            boolean isSEDML = false;
            VCDocumentInfo documentInfo = (VCDocumentInfo) hashTable.get(DOCUMENT_INFO);
            if (documentInfo instanceof BioModelInfo) {
                BioModelInfo bmi = (BioModelInfo) documentInfo;
                doc = getDocumentManager().getBioModel(bmi);
            } else if (documentInfo instanceof MathModelInfo) {
                MathModelInfo mmi = (MathModelInfo) documentInfo;
                doc = getDocumentManager().getMathModel(mmi);
            } else if (documentInfo instanceof GeometryInfo) {
                GeometryInfo gmi = (GeometryInfo) documentInfo;
                doc = getDocumentManager().getGeometry(gmi);
            } else if (documentInfo instanceof ExternalDocInfo) {
                ExternalDocInfo externalDocInfo = (ExternalDocInfo) documentInfo;
                File file = externalDocInfo.getFile();
                if (file != null && !file.getName().isEmpty() && (file.getName().toLowerCase().endsWith(".sedx") || file.getName().toLowerCase().endsWith(".omex"))) {
                    TranslationLogger transLogger = new TranslationLogger(requester);
                    // iterate through one or more SEDML objects
                    List<SedML> sedmls = (List<SedML>) hashTable.get(SEDML_MODELS);
                    for (SedML sedml : sedmls) {
                        // default to import all tasks
                        List<VCDocument> vcdocs = XmlHelper.sedmlToBioModel(transLogger, externalDocInfo, sedml, null, null, false);
                        for (VCDocument vcdoc : vcdocs) {
                            docs.add(vcdoc);
                        }
                    }
                    // treat the same since OMEX is just and archive with SED-ML file(s)
                    isSEDML = true;
                } else if (!externalDocInfo.isXML()) {
                    if (hashTable.containsKey(BNG_UNIT_SYSTEM)) {
                        // not XML, look for BNGL etc.
                        // we use the BngUnitSystem already created during the 1st pass
                        BngUnitSystem bngUnitSystem = (BngUnitSystem) hashTable.get(BNG_UNIT_SYSTEM);
                        BioModel bioModel = createDefaultBioModelDocument(bngUnitSystem);
                        SimulationContext ruleBasedSimContext = bioModel.addNewSimulationContext("NFSim app", SimulationContext.Application.RULE_BASED_STOCHASTIC);
                        SimulationContext odeSimContext = bioModel.addNewSimulationContext("BioNetGen app", SimulationContext.Application.NETWORK_DETERMINISTIC);
                        List<SimulationContext> appList = new ArrayList<SimulationContext>();
                        appList.add(ruleBasedSimContext);
                        appList.add(odeSimContext);
                        // set convention for initial conditions in generated application for seed
                        // species (concentration or count)
                        ruleBasedSimContext.setUsingConcentration(bngUnitSystem.isConcentration());
                        odeSimContext.setUsingConcentration(bngUnitSystem.isConcentration());
                        RbmModelContainer rbmModelContainer = bioModel.getModel().getRbmModelContainer();
                        RbmUtils.reactionRuleLabelIndex = 0;
                        RbmUtils.reactionRuleNames.clear();
                        Reader reader = externalDocInfo.getReader();
                        ASTModel astModel = RbmUtils.importBnglFile(reader);
                        if (bioModel.getModel() != null && bioModel.getModel().getVcMetaData() != null) {
                            VCMetaData vcMetaData = bioModel.getModel().getVcMetaData();
                            vcMetaData.setFreeTextAnnotation(bioModel, astModel.getProlog());
                        }
                        if (astModel.hasCompartments()) {
                            Structure struct = bioModel.getModel().getStructure(0);
                            if (struct != null) {
                                bioModel.getModel().removeStructure(struct);
                            }
                        }
                        BnglObjectConstructionVisitor constructionVisitor = null;
                        if (!astModel.hasMolecularDefinitions()) {
                            System.out.println("Molecular Definition Block missing. Extracting it from Species, Reactions, Obserbables.");
                            constructionVisitor = new BnglObjectConstructionVisitor(bioModel.getModel(), appList, bngUnitSystem, false);
                        } else {
                            constructionVisitor = new BnglObjectConstructionVisitor(bioModel.getModel(), appList, bngUnitSystem, true);
                        }
                        // we'll convert the kinetic parameters to BngUnitSystem inside the
                        // visit(ASTKineticsParameter...)
                        astModel.jjtAccept(constructionVisitor, rbmModelContainer);
                        // set the volume in the newly created application to
                        // BngUnitSystem.bnglModelVolume
                        // TODO: set the right values if we import compartments from the bngl file!
                        // if(!bngUnitSystem.isConcentration()) {
                        Expression sizeExpression = new Expression(bngUnitSystem.getVolume());
                        ruleBasedSimContext.getGeometryContext().getStructureMapping(0).getSizeParameter().setExpression(sizeExpression);
                        odeSimContext.getGeometryContext().getStructureMapping(0).getSizeParameter().setExpression(sizeExpression);
                        // }
                        // we remove the NFSim application if any seed species is clamped because NFSim
                        // doesn't know what to do with it
                        boolean bClamped = false;
                        for (SpeciesContextSpec scs : ruleBasedSimContext.getReactionContext().getSpeciesContextSpecs()) {
                            if (scs.isConstant()) {
                                bClamped = true;
                                break;
                            }
                        }
                        if (bClamped) {
                            bioModel.removeSimulationContext(ruleBasedSimContext);
                        }
                        // // TODO: DON'T delete this code
                        // // the code below is needed if we also want to create simulations, example for 1 rule based simulation
                        // // it is rule-based so it wont have to flatten, should be fast.
                        // MathMappingCallback callback = new MathMappingCallbackTaskAdapter(getClientTaskStatusSupport());
                        // NetworkGenerationRequirements networkGenerationRequirements = null; // network generation should not be executed.
                        // ruleBasedSimContext.refreshMathDescription(callback,networkGenerationRequirements);
                        // Simulation sim = ruleBasedSimContext.addNewSimulation(SimulationOwner.DEFAULT_SIM_NAME_PREFIX,callback,networkGenerationRequirements);
                        doc = bioModel;
                    }
                } else {
                    // is XML
                    try (TranslationLogger transLogger = new TranslationLogger(requester)) {
                        XMLSource xmlSource = externalDocInfo.createXMLSource();
                        org.jdom.Element rootElement = xmlSource.getXmlDoc().getRootElement();
                        String xmlType = rootElement.getName();
                        String modelXmlType = null;
                        if (xmlType.equals(XMLTags.VcmlRootNodeTag)) {
                            // For now, assuming that <vcml> element has only one child (biomodel, mathmodel
                            // or geometry).
                            // Will deal with multiple children of <vcml> Element when we get to model
                            // composition.
                            @SuppressWarnings("unchecked") List<Element> childElementList = rootElement.getChildren();
                            // assuming first child is the biomodel,
                            Element modelElement = childElementList.get(0);
                            // mathmodel or geometry.
                            modelXmlType = modelElement.getName();
                        }
                        if (xmlType.equals(XMLTags.BioModelTag) || (xmlType.equals(XMLTags.VcmlRootNodeTag) && modelXmlType.equals(XMLTags.BioModelTag))) {
                            doc = XmlHelper.XMLToBioModel(xmlSource);
                        } else if (xmlType.equals(XMLTags.MathModelTag) || (xmlType.equals(XMLTags.VcmlRootNodeTag) && modelXmlType.equals(XMLTags.MathModelTag))) {
                            doc = XmlHelper.XMLToMathModel(xmlSource);
                        } else if (xmlType.equals(XMLTags.GeometryTag) || (xmlType.equals(XMLTags.VcmlRootNodeTag) && modelXmlType.equals(XMLTags.GeometryTag))) {
                            doc = XmlHelper.XMLToGeometry(xmlSource);
                        } else if (xmlType.equals(XMLTags.SbmlRootNodeTag)) {
                            Namespace namespace = rootElement.getNamespace(XMLTags.SBML_SPATIAL_NS_PREFIX);
                            isBMDB = externalDocInfo.isBioModelsNet();
                            boolean bIsSpatial = (namespace == null) ? false : true;
                            doc = XmlHelper.importSBML(transLogger, xmlSource, bIsSpatial);
                        } else if (xmlType.equals(XMLTags.CellmlRootNodeTag)) {
                            if (requester instanceof BioModelWindowManager) {
                                doc = XmlHelper.importBioCellML(transLogger, xmlSource);
                            } else {
                                doc = XmlHelper.importMathCellML(transLogger, xmlSource);
                            }
                        } else if (xmlType.equals(MicroscopyXMLTags.FRAPStudyTag)) {
                            doc = VFrapXmlHelper.VFRAPToBioModel(hashTable, xmlSource, getDocumentManager(), requester);
                        } else if (xmlType.equals(XMLTags.SedMLTypeTag)) {
                            // we know it is a single SedML since it is an actual XML source
                            List<SedML> sedmls = (List<SedML>) hashTable.get(SEDML_MODELS);
                            SedML sedml = sedmls.get(0);
                            // default to import all tasks
                            docs = XmlHelper.sedmlToBioModel(transLogger, externalDocInfo, sedml, null, externalDocInfo.getFile().getAbsolutePath(), false);
                            isSEDML = true;
                        } else {
                            // unknown XML format
                            throw new RuntimeException("unsupported XML format, first element tag is <" + rootElement.getName() + ">");
                        }
                        if (externalDocInfo.getDefaultName() != null) {
                            doc.setName(externalDocInfo.getDefaultName());
                        }
                    }
                }
                if (doc == null && docs == null) {
                    File f = externalDocInfo.getFile();
                    if (f != null) {
                        throw new RuntimeException("Unable to determine type of file " + f.getCanonicalPath());
                    }
                    throw new ProgrammingException();
                }
            }
            // create biopax objects using annotation
            if (doc instanceof BioModel) {
                BioModel bioModel = (BioModel) doc;
                try {
                    bioModel.getVCMetaData().createBioPaxObjects(bioModel);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            requester.prepareDocumentToLoad(doc, inNewWindow);
            hashTable.put("isBMDB", isBMDB);
            hashTable.put("isSEDML", isSEDML);
            if (!isSEDML) {
                hashTable.put("doc", doc);
            } else {
                hashTable.put("docs", docs);
            }
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("Showing document", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            try {
                Throwable exc = (Throwable) hashTable.get(ClientTaskDispatcher.TASK_ABORTED_BY_ERROR);
                if (exc == null) {
                    boolean isSEDML = (boolean) hashTable.get("isSEDML");
                    if (isSEDML) {
                        List<VCDocument> docs = (List<VCDocument>) hashTable.get("docs");
                        List<DocumentWindowManager> windowManagers = new ArrayList<DocumentWindowManager>();
                        for (VCDocument doc : docs) {
                            DocumentWindowManager windowManager = createDocumentWindowManager(doc);
                            getMdiManager().createNewDocumentWindow(windowManager);
                            windowManagers.add(windowManager);
                        }
                        hashTable.put("managers", windowManagers);
                        hashTable.put("docs", docs);
                    } else {
                        VCDocument doc = (VCDocument) hashTable.get("doc");
                        DocumentWindowManager windowManager = null;
                        if (inNewWindow) {
                            windowManager = createDocumentWindowManager(doc);
                            // request was to create a new top-level window with this doc
                            getMdiManager().createNewDocumentWindow(windowManager);
                        } else {
                            // request was to replace the document in an existing window
                            windowManager = (DocumentWindowManager) requester;
                            getMdiManager().setCanonicalTitle(requester.getManagerID());
                            windowManager.resetDocument(doc);
                        }
                        hashTable.put(WIN_MGR_KEY, windowManager);
                        hashTable.put("doc", doc);
                    }
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            // TODO: check why getMdiManager().createNewDocumentWindow(windowManager) fails sometimes
            } finally {
                if (!inNewWindow) {
                    getMdiManager().unBlockWindow(requester.getManagerID());
                }
                bOpening = false;
            }
        }
    };
    AsynchClientTask task3 = new AsynchClientTask("Special Layout", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            if (documentInfo instanceof ExternalDocInfo) {
                ExternalDocInfo externalDocInfo = (ExternalDocInfo) documentInfo;
                boolean isSEDML = (boolean) hashTable.get("isSEDML");
                if (externalDocInfo.isBioModelsNet() || externalDocInfo.isFromXmlFile() || !isSEDML) {
                    DocumentWindowManager windowManager = (DocumentWindowManager) hashTable.get(WIN_MGR_KEY);
                    if (windowManager instanceof BioModelWindowManager) {
                        ((BioModelWindowManager) windowManager).specialLayout();
                    }
                }
                if (isSEDML) {
                    List<DocumentWindowManager> windowManagers = (List<DocumentWindowManager>) hashTable.get("managers");
                    if (windowManagers != null) {
                        for (DocumentWindowManager manager : windowManagers) {
                            ((BioModelWindowManager) manager).specialLayout();
                        }
                    }
                }
            }
        }
    };
    AsynchClientTask task4 = new AsynchClientTaskFunction(ClientRequestManager::setWindowFocus, "Set window focus", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false);
    AsynchClientTask task6 = new AsynchClientTask("Renaming, please wait...", // TASKTYPE_NONSWING_BLOCKING
    AsynchClientTask.TASKTYPE_NONSWING_BLOCKING, // TASKTYPE_NONSWING_BLOCKING
    false, // TASKTYPE_NONSWING_BLOCKING
    false) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            VCDocument doc = (VCDocument) hashTable.get("doc");
            if (!(doc instanceof BioModel)) {
                return;
            }
            boolean isBMDB = (boolean) hashTable.get("isBMDB");
            if (documentInfo instanceof ExternalDocInfo) {
                if (isBMDB) {
                    idToNameConversion(doc);
                }
            }
            if (isBMDB) {
                BioModel bioModel = (BioModel) doc;
                SimulationContext simulationContext = bioModel.getSimulationContext(0);
                simulationContext.setName(BMDB_DEFAULT_APPLICATION);
                MathMappingCallback callback = new MathMappingCallback() {

                    @Override
                    public void setProgressFraction(float fractionDone) {
                    }

                    @Override
                    public void setMessage(String message) {
                    }

                    @Override
                    public boolean isInterrupted() {
                        return false;
                    }
                };
                MathMapping mathMapping = simulationContext.createNewMathMapping(callback, NetworkGenerationRequirements.ComputeFullNoTimeout);
                MathDescription mathDesc = null;
                try {
                    mathDesc = mathMapping.getMathDescription(callback);
                    simulationContext.setMathDescription(mathDesc);
                    Simulation sim = new Simulation(mathDesc);
                    sim.setName(simulationContext.getBioModel().getFreeSimulationName());
                    simulationContext.addSimulation(sim);
                    bioModel.refreshDependencies();
                } catch (MappingException | MathException | MatrixException | ExpressionException | ModelException e1) {
                    e1.printStackTrace();
                }
                hashTable.put("doc", doc);
            }
        }
    };
    ClientTaskDispatcher.dispatch(requester.getComponent(), hashTable, new AsynchClientTask[] { task0, task1, task6, task2, task3, task4 }, false);
}
Also used : SetMathDescription(cbit.vcell.client.task.SetMathDescription) MathDescription(cbit.vcell.math.MathDescription) ArrayList(java.util.ArrayList) UserCancelException(org.vcell.util.UserCancelException) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) ExpressionException(cbit.vcell.parser.ExpressionException) MappingException(cbit.vcell.mapping.MappingException) SedML(org.jlibsedml.SedML) ExternalDocInfo(cbit.vcell.xml.ExternalDocInfo) AsynchClientTaskFunction(cbit.vcell.client.task.AsynchClientTaskFunction) MatrixException(cbit.vcell.matrix.MatrixException) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) BnglObjectConstructionVisitor(org.vcell.model.rbm.RbmUtils.BnglObjectConstructionVisitor) RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) GeometryInfo(cbit.vcell.geometry.GeometryInfo) ArrayList(java.util.ArrayList) List(java.util.List) VCDocument(org.vcell.util.document.VCDocument) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) ModelException(cbit.vcell.model.ModelException) FileInputStream(java.io.FileInputStream) Namespace(org.jdom.Namespace) BngUnitSystem(org.vcell.model.bngl.BngUnitSystem) BNGLDebuggerPanel(org.vcell.model.bngl.gui.BNGLDebuggerPanel) SEDMLDocument(org.jlibsedml.SEDMLDocument) MathMapping(cbit.vcell.mapping.MathMapping) CSGObject(cbit.vcell.geometry.CSGObject) ChooseFile(cbit.vcell.client.task.ChooseFile) File(java.io.File) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) FileWriter(java.io.FileWriter) Element(org.jdom.Element) StlReader(cbit.vcell.geometry.surface.StlReader) FileReader(java.io.FileReader) ImageDatasetReader(org.vcell.vcellij.ImageDatasetReader) Reader(java.io.Reader) BufferedReader(java.io.BufferedReader) ArchiveComponents(org.jlibsedml.ArchiveComponents) ProgrammingException(org.vcell.util.ProgrammingException) Structure(cbit.vcell.model.Structure) Hashtable(java.util.Hashtable) BNGLUnitsPanel(org.vcell.model.bngl.gui.BNGLUnitsPanel) BioModelInfo(org.vcell.util.document.BioModelInfo) IOException(java.io.IOException) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) ProgrammingException(org.vcell.util.ProgrammingException) MatrixException(cbit.vcell.matrix.MatrixException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) ModelException(cbit.vcell.model.ModelException) DataFormatException(java.util.zip.DataFormatException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) UserCancelException(org.vcell.util.UserCancelException) Simulation(cbit.vcell.solver.Simulation) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) Expression(cbit.vcell.parser.Expression) MathException(cbit.vcell.math.MathException) BioModel(cbit.vcell.biomodel.BioModel) XMLSource(cbit.vcell.xml.XMLSource) Element(org.jdom.Element) ASTModel(org.vcell.model.bngl.ASTModel)

Example 4 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class ReactionCartoonTool method menuAction.

@Override
protected void menuAction(Shape shape, String menuAction) {
    if (shape == null) {
        return;
    }
    if (menuAction.equals(CartoonToolMiscActions.Properties.MENU_ACTION)) {
        if (shape instanceof FluxReactionShape) {
        // showFluxReactionPropertiesDialog((FluxReactionShape) shape);
        } else if (shape instanceof SimpleReactionShape) {
        // showSimpleReactionPropertiesDialog((SimpleReactionShape) shape);
        } else if (shape instanceof ReactantShape) {
        // Point locationOnScreen = shape.getSpaceManager().getAbsLoc();
        // Point graphPaneLocation = getGraphPane().getLocationOnScreen();
        // locationOnScreen.translate(graphPaneLocation.x,
        // graphPaneLocation.y);
        // showReactantPropertiesDialog((ReactantShape) shape,
        // locationOnScreen);
        } else if (shape instanceof ProductShape) {
        // Point locationOnScreen = shape.getSpaceManager().getAbsLoc();
        // Point graphPaneLocation = getGraphPane().getLocationOnScreen();
        // locationOnScreen.translate(graphPaneLocation.x,
        // graphPaneLocation.y);
        // showProductPropertiesDialog((ProductShape) shape,
        // locationOnScreen);
        } else if (shape instanceof SpeciesContextShape) {
        // showEditSpeciesDialog(getGraphPane(), getReactionCartoon()
        // .getModel(), ((SpeciesContextShape) shape)
        // .getSpeciesContext());
        } else if (shape instanceof ReactionContainerShape) {
        // ReactionContainerShape rcs = (ReactionContainerShape) shape;
        // if (rcs.getStructure() instanceof Feature) {
        // //
        // // showFeaturePropertyDialog is invoked in two modes:
        // //
        // // 1) parent!=null and child==null
        // // upon ok, it adds a new feature to the supplied parent.
        // //
        // // 2) parent==null and child!=null
        // // upon ok, edits the feature name
        // //
        // showFeaturePropertiesDialog(getGraphPane(),
        // (getReactionCartoon().getModel() == null ? null
        // : getReactionCartoon().getModel()), null,
        // (Feature) rcs.getStructure());
        // } else if (rcs.getStructure() instanceof Membrane) {
        // showMembranePropertiesDialog(getGraphPane(), (Membrane) rcs
        // .getStructure());
        // }
        }
    } else if (menuAction.equals(CartoonToolMiscActions.AddSpecies.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape) {
            getGraphModel().deselectShape(shape);
            // showCreateSpeciesContextDialog(getGraphPane(),
            // getReactionCartoon().getModel(),
            // ((ReactionContainerShape) shape).getStructure(), null);
            SpeciesContext speciesContext = getReactionCartoon().getModel().createSpeciesContext(((ReactionContainerShape) shape).getStructure());
            getGraphModel().select(speciesContext);
        }
    } else if (menuAction.equals(CartoonToolEditActions.Copy.MENU_ACTION)) {
        if (shape instanceof SpeciesContextShape || shape instanceof ReactionStepShape || // rule participants whose rule is not selected won't
        shape instanceof RuleParticipantSignatureDiagramShape || // be copied since standalone they are meaningless
        shape instanceof ReactionRuleDiagramShape) {
            SpeciesContext[] spArray = getSelectedSpeciesContextArray();
            ReactionStep[] rsArray = getSelectedReactionStepArray();
            ReactionRule[] rrArray = getSelectedReactionRuleArray();
            MolecularType[] mtArray = getSelectedMolecularTypeArray(rrArray, rsArray, spArray);
            Structure[] structArray = getSelectedStructuresArray(rrArray, rsArray, spArray, mtArray);
            Structure fromStruct = null;
            ReactionContainerShape rcs = null;
            Shape parentShape = shape.getParent();
            if (parentShape instanceof ReactionContainerShape) {
                rcs = (ReactionContainerShape) parentShape;
                fromStruct = rcs.getStructure();
            }
            ReactionSpeciesCopy reactionSpeciesCopy = new ReactionSpeciesCopy(spArray, rsArray, rrArray, mtArray, fromStruct, structArray);
            VCellTransferable.sendToClipboard(reactionSpeciesCopy);
        }
    } else if (/*menuAction.equals(CartoonToolEditActions.Paste.MENU_ACTION)
				|| */
    menuAction.equals(CartoonToolEditActions.PasteNew.MENU_ACTION)) {
        if (shape instanceof ReactionContainerShape) {
            pasteReactionsAndSpecies(getGraphPane().getRootPane(), ((ReactionContainerShape) shape).getStructure());
        }
    } else if (menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
        try {
            if (getGraphModel().getSelectedShape() instanceof ReactionContainerShape && menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
                getModel().removeStructure(((ReactionContainerShape) getGraphModel().getSelectedShape()).getStructure());
                return;
            }
            if (getSelectedReactionStepArray() != null || getSelectedSpeciesContextArray() != null) {
                deleteReactionsAndSpecies(getGraphPane(), getSelectedReactionStepArray(), getSelectedSpeciesContextArray());
            }
            if (getSelectedReactionParticipantArray() != null && menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
                ReactionParticipant[] reactionParticipantArr = getSelectedReactionParticipantArray();
                if (ReactionCartoonTool.checkAllCatalyst(reactionParticipantArr)) {
                    DialogUtils.showWarningDialog(getGraphPane(), "Catalysts are determined automatically from the reaction kinetic expression.");
                    return;
                }
                String response = DialogUtils.showWarningDialog(getGraphPane(), "Delete " + reactionParticipantArr.length + " Reaction Stoichiometries", new String[] { RXSPECIES_DELETE, RXSPECIES_CANCEL }, RXSPECIES_CANCEL);
                if (response != null && response.equals(RXSPECIES_DELETE)) {
                    for (int i = 0; i < reactionParticipantArr.length; i++) {
                        if (reactionParticipantArr[i] instanceof Catalyst) {
                            // Catalysts may only be deleted by editing kynetic / proxy parameters
                            continue;
                        }
                        ReactionStep reactionStep = reactionParticipantArr[i].getReactionStep();
                        reactionStep.removeReactionParticipant(reactionParticipantArr[i]);
                    }
                }
            }
        } catch (UserCancelException uce) {
            return;
        } catch (PropertyVetoException e) {
            DialogUtils.showErrorDialog(getGraphPane(), e.getMessage());
        } catch (Exception e) {
            DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
        }
    } else if (menuAction.equals(CartoonToolMiscActions.SearchReactions.MENU_ACTION)) {
        try {
            if (shape instanceof ReactionContainerShape) {
                showReactionBrowserDialog(((ReactionContainerShape) shape).getStructure(), null);
            }
        } catch (Exception e) {
            DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
        }
    } else if (menuAction.equals(CartoonToolSaveAsImageActions.MenuAction.MENU_ACTION)) {
        try {
            String resType = null;
            if (shape instanceof ReactionContainerShape) {
                showSaveReactionImageDialog();
            }
        } catch (Exception e) {
            e.printStackTrace();
            DialogUtils.showErrorDialog(getGraphPane(), e.getMessage(), e);
        }
    } else if (menuAction.equals(CartoonToolMiscActions.Annotate.MENU_ACTION)) {
        if (shape instanceof ReactionStepShape) {
            // MIRIAMHelper.showMIRIAMAnnotationDialog(((SimpleReactionShape)shape).getReactionStep());
            // System.out.println("Menu action annotate activated...");
            ReactionStep rs = ((ReactionStepShape) shape).getReactionStep();
            VCMetaData vcMetaData = rs.getModel().getVcMetaData();
            try {
                String newAnnotation = DialogUtils.showAnnotationDialog(getGraphPane(), vcMetaData.getFreeTextAnnotation(rs));
                vcMetaData.setFreeTextAnnotation(rs, newAnnotation);
            } catch (UtilCancelException e) {
            // Do Nothing
            } catch (Throwable exc) {
                exc.printStackTrace(System.out);
                DialogUtils.showErrorDialog(getGraphPane(), "Failed to edit annotation!\n" + exc.getMessage(), exc);
            }
        }
    } else {
    // default action is to ignore
    }
}
Also used : ReactionSpeciesCopy(cbit.vcell.model.ReactionSpeciesCopy) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) RubberBandRectShape(cbit.gui.graph.RubberBandRectShape) ProductShape(cbit.vcell.graph.ProductShape) ContainerShape(cbit.gui.graph.ContainerShape) CatalystShape(cbit.vcell.graph.CatalystShape) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactantShape(cbit.vcell.graph.ReactantShape) ElipseShape(cbit.gui.graph.ElipseShape) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Shape(cbit.gui.graph.Shape) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) RubberBandEdgeShape(cbit.gui.graph.RubberBandEdgeShape) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) ProductShape(cbit.vcell.graph.ProductShape) UserCancelException(org.vcell.util.UserCancelException) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) ReactantShape(cbit.vcell.graph.ReactantShape) SpeciesContext(cbit.vcell.model.SpeciesContext) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) Structure(cbit.vcell.model.Structure) UtilCancelException(org.vcell.util.UtilCancelException) ReactionRule(cbit.vcell.model.ReactionRule) SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) Point(java.awt.Point) PropertyVetoException(java.beans.PropertyVetoException) UtilCancelException(org.vcell.util.UtilCancelException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) MolecularType(org.vcell.model.rbm.MolecularType) PropertyVetoException(java.beans.PropertyVetoException) ReactionStep(cbit.vcell.model.ReactionStep) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Catalyst(cbit.vcell.model.Catalyst)

Example 5 with VCMetaData

use of cbit.vcell.biomodel.meta.VCMetaData in project vcell by virtualcell.

the class BioModelEditor method setRightBottomPanelOnSelection.

@Override
protected void setRightBottomPanelOnSelection(Object[] selections) {
    if (selections == null) {
        return;
    }
    // TODO: here
    JComponent bottomComponent = rightBottomEmptyPanel;
    JComponent annotationComponent = rightBottomEmptyAnnotationsPanel;
    // properties panel
    int destComponentIndex = DocumentEditorTabID.object_properties.ordinal();
    // annotations panel
    int annComponentIndex = DocumentEditorTabID.annotations.ordinal();
    boolean bShowInDatabaseProperties = false;
    boolean bShowPathway = false;
    if (selections.length == 1) {
        annotationComponent = getAnnotationsPanel();
        Object singleSelection = selections[0];
        if (singleSelection instanceof ReactionStep) {
            bottomComponent = getReactionPropertiesPanel();
        } else if (singleSelection instanceof ReactionRule) {
            bottomComponent = getReactionRulePropertiesPanel();
        } else if (singleSelection instanceof SpeciesContext) {
            bottomComponent = getSpeciesPropertiesPanel();
        } else if (singleSelection instanceof MolecularType) {
            bottomComponent = getMolecularTypePropertiesPanel();
        } else if (singleSelection instanceof RbmObservable) {
            bottomComponent = getObservablePropertiesPanel();
        } else if (singleSelection instanceof Structure) {
            bottomComponent = getStructurePropertiesPanel();
            getStructurePropertiesPanel().setModel(bioModel.getModel());
        } else if (singleSelection instanceof Parameter) {
            bottomComponent = getParameterPropertiesPanel();
        } else if (singleSelection instanceof SimulationContext) {
            bottomComponent = getApplicationPropertiesPanel();
        } else if (singleSelection instanceof ParameterEstimationTask) {
            bottomComponent = parameterEstimationTaskPropertiesPanel;
        } else if (singleSelection instanceof Product || singleSelection instanceof Reactant) {
            bottomComponent = getReactionParticipantPropertiesPanel();
        } else if (singleSelection instanceof BioModelNode.PublicationInfoNode) {
            bShowInDatabaseProperties = true;
            bottomComponent = bioModelMetaDataPanel;
        } else if (singleSelection instanceof BioModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = bioModelMetaDataPanel;
        } else if (singleSelection instanceof MathModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = mathModelMetaDataPanel;
        } else if (singleSelection instanceof GeometryInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = geometryMetaDataPanel;
        } else if (singleSelection instanceof SpeciesContextSpec) {
            bottomComponent = getSpeciesContextSpecPanel();
        } else if (singleSelection instanceof ReactionSpec) {
            bottomComponent = getKineticsTypeTemplatePanel();
        } else if (singleSelection instanceof ReactionRuleSpec) {
            // 
            bottomComponent = getReactionRuleSpecPropertiesPanel();
        } else if (singleSelection instanceof BioModelsNetModelInfo) {
            bShowInDatabaseProperties = true;
            bottomComponent = getBioModelsNetPropertiesPanel();
        } else if (singleSelection instanceof Simulation) {
            bottomComponent = getSimulationSummaryPanel();
        } else if (singleSelection instanceof DataSymbol) {
            bottomComponent = getDataSymbolsSpecPanel();
        } else if (singleSelection instanceof BioEvent) {
            bottomComponent = getEventPanel();
        } else if (singleSelection instanceof SpatialObject) {
            bottomComponent = getSpatialObjectPropertyPanel();
        } else if (singleSelection instanceof SpatialProcess) {
            bottomComponent = getSpatialProcessPropertyPanel();
        } else if (singleSelection instanceof BioPaxObject) {
            bottomComponent = bioPaxObjectPropertiesPanel;
        } else if (singleSelection instanceof BioModel) {
            // only contains Notes, is displayed in the Object Properties Panel
            bottomComponent = bioModelEditorAnnotationPanel;
        } else if (singleSelection instanceof VCMetaData) {
            bottomComponent = bioModelEditorAnnotationPanel;
        } else if (singleSelection instanceof PathwayData) {
            bShowPathway = true;
            bottomComponent = getBioModelEditorPathwayPanel();
        } else if (singleSelection instanceof Model) {
        } else if (singleSelection instanceof RuleParticipantSignature) {
            bottomComponent = getReactionRuleParticipantSignaturePropertiesPanel();
        } else if (singleSelection instanceof CSGObject) {
            bottomComponent = csgObjectPropertiesPanel;
            csgObjectPropertiesPanel.setSimulationContext(getSelectedSimulationContext());
        } else if (singleSelection instanceof DocumentEditorTreeFolderNode) {
            DocumentEditorTreeFolderClass folderClass = ((DocumentEditorTreeFolderNode) singleSelection).getFolderClass();
            if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && !(singleSelection instanceof ReactionRule)) {
                bottomComponent = getReactionPropertiesPanel();
            } else if ((folderClass == DocumentEditorTreeFolderClass.REACTIONS_NODE) && (singleSelection instanceof ReactionRule)) {
                bottomComponent = getReactionRulePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.STRUCTURES_NODE) {
                bottomComponent = getStructurePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.SPECIES_NODE) {
                bottomComponent = getSpeciesPropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.MOLECULAR_TYPES_NODE) {
                bottomComponent = getMolecularTypePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.OBSERVABLES_NODE) {
                bottomComponent = getObservablePropertiesPanel();
            } else if (folderClass == DocumentEditorTreeFolderClass.APPLICATIONS_NODE) {
                bottomComponent = getApplicationsPropertiesPanel();
                getApplicationsPropertiesPanel().setBioModel(bioModel);
            } else if (folderClass == DocumentEditorTreeFolderClass.PARAMETER_ESTIMATION_NODE) {
                bottomComponent = parameterEstimationTaskPropertiesPanel;
            }
        } else if (singleSelection instanceof SelectionManager.AnnotationNavigator) {
            Object entity = ((SelectionManager.AnnotationNavigator) singleSelection).getEntity();
            if (entity instanceof ReactionStep) {
                bottomComponent = getReactionPropertiesPanel();
            } else if (entity instanceof SpeciesContext) {
                bottomComponent = getSpeciesPropertiesPanel();
            } else if (entity instanceof Structure) {
                // Observables. MolecularType, Structures
                bottomComponent = getStructurePropertiesPanel();
            } else if (entity instanceof MolecularType) {
                bottomComponent = getMolecularTypePropertiesPanel();
            } else if (entity instanceof RbmObservable) {
                bottomComponent = getObservablePropertiesPanel();
            } else {
                bottomComponent = bioModelEditorAnnotationPanel;
            }
        }
    }
    if (bShowPathway) {
        int numTabs = rightBottomTabbedPane.getTabCount();
        for (destComponentIndex = 0; destComponentIndex < numTabs; destComponentIndex++) {
            Component current = rightBottomTabbedPane.getComponentAt(destComponentIndex);
            if (current == bottomComponent) {
                break;
            }
        }
        String tabTitle = "Pathway Preview";
        if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
            rightBottomTabbedPane.addTab(tabTitle, new TabCloseIcon(), bottomComponent);
        }
    } else if (bShowInDatabaseProperties) {
        for (destComponentIndex = 0; destComponentIndex < rightBottomTabbedPane.getTabCount(); destComponentIndex++) {
            Component c = rightBottomTabbedPane.getComponentAt(destComponentIndex);
            if (c == bioModelMetaDataPanel || c == mathModelMetaDataPanel || c == geometryMetaDataPanel || c == getBioModelsNetPropertiesPanel()) {
                break;
            }
        }
        if (rightBottomTabbedPane.getTabCount() == destComponentIndex) {
            rightBottomTabbedPane.addTab(DATABASE_PROPERTIES_TAB_TITLE, new TabCloseIcon(), bottomComponent);
        }
    }
    if (rightBottomTabbedPane.getComponentAt(destComponentIndex) != bottomComponent) {
        bottomComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
        annotationComponent.setBorder(GuiConstants.TAB_PANEL_BORDER);
        rightBottomTabbedPane.setComponentAt(destComponentIndex, bottomComponent);
        rightBottomTabbedPane.setComponentAt(annComponentIndex, annotationComponent);
        rightSplitPane.repaint();
    }
    Component selectedComponent = rightBottomTabbedPane.getSelectedComponent();
    if (selections.length == 1 && selections[0] instanceof BioModel && bottomComponent instanceof BioModelEditorAnnotationPanel) {
        // if the biomodel name is selected in the upper left tree, we select the Annotations tab
        rightBottomTabbedPane.setSelectedComponent(annotationComponent);
    } else if (selections.length == 1 && selections[0] instanceof SelectionManager.AnnotationNavigator && selections[0] instanceof SelectionManager.AnnotationNavigator) {
        // we want to navigate to the AnnotationPanel
        rightBottomTabbedPane.setSelectedComponent(annotationComponent);
    // } else if(selections.length == 1 && selections[0] instanceof SelectionManager.AnnotationNavigator && bottomComponent instanceof BioModelEditorAnnotationPanel) {
    // // we want to navigate to the AnnotationPanel (old way)
    // rightBottomTabbedPane.setSelectedComponent(annotationComponent);
    } else if (selectedComponent != bottomComponent) /* && rightBottomTabbedPane.getSelectedComponent() != annotationComponent */
    {
        rightBottomTabbedPane.setSelectedComponent(bottomComponent);
    }
}
Also used : RuleParticipantSignature(cbit.vcell.model.RuleParticipantSignature) BioPaxObject(org.vcell.pathway.BioPaxObject) Product(cbit.vcell.model.Product) PathwayData(cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayData) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) Reactant(cbit.vcell.model.Reactant) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) GeometryInfo(cbit.vcell.geometry.GeometryInfo) Structure(cbit.vcell.model.Structure) CSGObject(cbit.vcell.geometry.CSGObject) Component(java.awt.Component) JComponent(javax.swing.JComponent) PublicationInfoNode(cbit.vcell.desktop.BioModelNode.PublicationInfoNode) ReactionRule(cbit.vcell.model.ReactionRule) ReactionSpec(cbit.vcell.mapping.ReactionSpec) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) RbmObservable(cbit.vcell.model.RbmObservable) JComponent(javax.swing.JComponent) BioModelInfo(org.vcell.util.document.BioModelInfo) DocumentEditorTreeFolderNode(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode) MathModelInfo(org.vcell.util.document.MathModelInfo) SimulationContext(cbit.vcell.mapping.SimulationContext) DocumentEditorTreeFolderClass(cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass) MolecularType(org.vcell.model.rbm.MolecularType) ParameterEstimationTask(cbit.vcell.modelopt.ParameterEstimationTask) DataSymbol(cbit.vcell.data.DataSymbol) Simulation(cbit.vcell.solver.Simulation) ReactionStep(cbit.vcell.model.ReactionStep) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) ListSelectionModel(javax.swing.ListSelectionModel) BioModel(cbit.vcell.biomodel.BioModel) Parameter(cbit.vcell.model.Parameter) BioPaxObject(org.vcell.pathway.BioPaxObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) CSGObject(cbit.vcell.geometry.CSGObject) BioEvent(cbit.vcell.mapping.BioEvent)

Aggregations

VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)21 PropertyVetoException (java.beans.PropertyVetoException)10 BioModel (cbit.vcell.biomodel.BioModel)5 SimulationContext (cbit.vcell.mapping.SimulationContext)4 Structure (cbit.vcell.model.Structure)4 ExpressionException (cbit.vcell.parser.ExpressionException)4 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)3 Model (cbit.vcell.model.Model)3 ReactionStep (cbit.vcell.model.ReactionStep)3 Simulation (cbit.vcell.solver.Simulation)3 IOException (java.io.IOException)3 MolecularType (org.vcell.model.rbm.MolecularType)3 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)2 DocumentEditorTreeFolderClass (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass)2 DocumentEditorTreeFolderNode (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode)2 CSGObject (cbit.vcell.geometry.CSGObject)2 GeometryInfo (cbit.vcell.geometry.GeometryInfo)2 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)2 Catalyst (cbit.vcell.model.Catalyst)2 ReactionParticipant (cbit.vcell.model.ReactionParticipant)2