Search in sources :

Example 66 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class SpeciesPropertiesTreeModel method createMolecularComponentPatternNode.

private BioModelNode createMolecularComponentPatternNode(MolecularComponentPattern molecularComponentPattern) {
    MolecularComponent mc = molecularComponentPattern.getMolecularComponent();
    BioModelNode node = new BioModelNode(molecularComponentPattern, true);
    // }
    return node;
}
Also used : MolecularComponent(org.vcell.model.rbm.MolecularComponent) BioModelNode(cbit.vcell.desktop.BioModelNode)

Example 67 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class SpeciesPropertiesTreeModel method populateTree.

public void populateTree() {
    if (speciesContext == null || bioModel == null) {
        return;
    }
    rootNode.setUserObject(speciesContext);
    rootNode.removeAllChildren();
    int count = 0;
    if (speciesContext.getSpeciesPattern() == null) {
        nodeStructureChanged(rootNode);
        return;
    }
    SpeciesPattern sp = speciesContext.getSpeciesPattern();
    // BioModelNode spNode = new BioModelNode(new SpeciesPatternLocal(sp, ++count));
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        BioModelNode node = createMolecularTypePatternNode(mtp);
        rootNode.add(node);
    // spNode.add(node);
    }
    // rootNode.add(spNode);
    nodeStructureChanged(rootNode);
    GuiUtils.treeExpandAllRows(ownerTree);
    // we fire a "dummy" event because the species properties panel and the bio model editor species table model
    // will repaint the shape and respectively the table row for any speciesContext property change event
    speciesContext.firePropertyChange("entityChange", null, "bbb");
}
Also used : BioModelNode(cbit.vcell.desktop.BioModelNode) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 68 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class MolecularTypePropertiesPanel method addNewFromTree.

public void addNewFromTree() {
    Object obj = molecularTypeTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object selectedUserObject = selectedNode.getUserObject();
    if (selectedUserObject == molecularType) {
        MolecularComponent molecularComponent = molecularType.createMolecularComponent();
        molecularType.addMolecularComponent(molecularComponent);
        bioModel.getModel().getRbmModelContainer().adjustSpeciesContextPatterns(molecularType, molecularComponent);
        bioModel.getModel().getRbmModelContainer().adjustObservablesPatterns(molecularType, molecularComponent);
        bioModel.getModel().getRbmModelContainer().adjustRulesPatterns(molecularType, molecularComponent);
        molecularTypeTree.startEditingAtPath(molecularTypeTreeModel.findObjectPath(null, molecularComponent));
    } else if (selectedUserObject instanceof MolecularComponent) {
        MolecularComponent molecularComponent = (MolecularComponent) selectedUserObject;
        ComponentStateDefinition componentStateDefinition = molecularComponent.createComponentStateDefinition();
        molecularComponent.addComponentStateDefinition(componentStateDefinition);
        bioModel.getModel().getRbmModelContainer().adjustObservablesPatterns(molecularType, molecularComponent, componentStateDefinition);
        molecularTypeTree.startEditingAtPath(molecularTypeTreeModel.findObjectPath(null, componentStateDefinition));
    }
}
Also used : MolecularComponent(org.vcell.model.rbm.MolecularComponent) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) BioModelNode(cbit.vcell.desktop.BioModelNode) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition)

Example 69 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class MolecularTypePropertiesPanel method deleteFromTree.

public void deleteFromTree() {
    Object obj = molecularTypeTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    TreeNode parent = selectedNode.getParent();
    if (!(parent instanceof BioModelNode)) {
        return;
    }
    BioModelNode parentNode = (BioModelNode) parent;
    Object selectedUserObject = selectedNode.getUserObject();
    if (selectedUserObject instanceof MolecularComponent) {
        MolecularComponent mc = (MolecularComponent) selectedUserObject;
        Object userObject = parentNode.getUserObject();
        if (userObject instanceof MolecularType) {
            MolecularType mt = (MolecularType) userObject;
            // detailed verifications will be done there, to see if they are being used in reactions, species, observables
            if (!mc.getComponentStateDefinitions().isEmpty()) {
                String[] options = { "OK" };
                String errMsg = mc.getDisplayType() + " '<b>" + mc.getDisplayName() + "</b>' cannot be deleted because it contains explicit States.";
                errMsg += "<br>Please delete each individual State first.";
                errMsg += "<br><br>Detailed usage information will be provided at that time to help you decide.";
                errMsg = "<html>" + errMsg + "</html>";
                JOptionPane.showOptionDialog(this.getParent().getParent(), errMsg, "Delete " + mc.getDisplayType(), JOptionPane.NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
                return;
            }
            // we find and display component usage information to help the user decide
            Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
            bioModel.getModel().getRbmModelContainer().findComponentUsage(mt, mc, usedHere);
            if (!usedHere.isEmpty()) {
                String errMsg = mc.dependenciesToHtml(usedHere);
                errMsg += "<br><br>Delete anyway?";
                errMsg = "<html>" + errMsg + "</html>";
                int dialogButton = JOptionPane.YES_NO_OPTION;
                int returnCode = JOptionPane.showConfirmDialog(this.getParent().getParent(), errMsg, "Delete " + mc.getDisplayType(), dialogButton);
                if (returnCode == JOptionPane.YES_OPTION) {
                    // keep this code in sync with MolecularTypeTableModel.setValueAt
                    if (bioModel.getModel().getRbmModelContainer().delete(mt, mc) == true) {
                        mt.removeMolecularComponent(mc);
                    }
                } else {
                    return;
                }
            } else {
                if (bioModel.getModel().getRbmModelContainer().delete(mt, mc) == true) {
                    mt.removeMolecularComponent(mc);
                }
            }
        }
    } else if (selectedUserObject instanceof ComponentStateDefinition) {
        ComponentStateDefinition csd = (ComponentStateDefinition) selectedUserObject;
        Object userObject = parentNode.getUserObject();
        if (!(userObject instanceof MolecularComponent)) {
            System.out.println("Unexpected parent in tree hierarchy for " + ComponentStateDefinition.typeName + " " + csd.getDisplayName() + "!");
            return;
        }
        MolecularComponent mc = (MolecularComponent) userObject;
        TreeNode grandParent = parentNode.getParent();
        BioModelNode grandParentNode = (BioModelNode) grandParent;
        userObject = grandParentNode.getUserObject();
        if (!(userObject instanceof MolecularType)) {
            System.out.println("Unexpected parent in tree hierarchy for " + mc.getDisplayType() + " " + mc.getDisplayName() + "!");
            return;
        }
        MolecularType mt = (MolecularType) userObject;
        Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
        bioModel.getModel().getRbmModelContainer().findStateUsage(mt, mc, csd, usedHere);
        if (!usedHere.isEmpty()) {
            String errMsg = csd.dependenciesToHtml(usedHere);
            errMsg += "<br><br>Delete anyway?";
            errMsg = "<html>" + errMsg + "</html>";
            int dialogButton = JOptionPane.YES_NO_OPTION;
            int returnCode = JOptionPane.showConfirmDialog(this.getParent().getParent(), errMsg, "Delete " + ComponentStateDefinition.typeName, dialogButton);
            if (returnCode == JOptionPane.YES_OPTION) {
                // keep this code in sync with MolecularTypeTableModel.setValueAt
                if (bioModel.getModel().getRbmModelContainer().delete(mt, mc, csd) == true) {
                    // this stays
                    mc.deleteComponentStateDefinition(csd);
                }
            } else {
                return;
            }
        } else {
            if (bioModel.getModel().getRbmModelContainer().delete(mt, mc, csd) == true) {
                // this stays
                mc.deleteComponentStateDefinition(csd);
            }
        }
    // mc.deleteComponentStateDefinition(csd);
    }
}
Also used : Displayable(org.vcell.util.Displayable) BioModelNode(cbit.vcell.desktop.BioModelNode) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) Point(java.awt.Point) LinkedHashMap(java.util.LinkedHashMap) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition) MolecularType(org.vcell.model.rbm.MolecularType) MolecularComponent(org.vcell.model.rbm.MolecularComponent) TreeNode(javax.swing.tree.TreeNode) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap) Pair(org.vcell.util.Pair)

Example 70 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class MolecularTypeTreeModel method createMolecularComponentNode.

private BioModelNode createMolecularComponentNode(MolecularComponent molecularComponent) {
    BioModelNode node = new BioModelNode(molecularComponent, true);
    for (ComponentStateDefinition componentState : molecularComponent.getComponentStateDefinitions()) {
        BioModelNode n = new BioModelNode(componentState, false);
        node.add(n);
    }
    return node;
}
Also used : BioModelNode(cbit.vcell.desktop.BioModelNode) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition)

Aggregations

BioModelNode (cbit.vcell.desktop.BioModelNode)82 TreePath (javax.swing.tree.TreePath)22 MolecularComponent (org.vcell.model.rbm.MolecularComponent)17 CSGObject (cbit.vcell.geometry.CSGObject)12 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)11 SimulationContext (cbit.vcell.mapping.SimulationContext)10 MolecularType (org.vcell.model.rbm.MolecularType)10 Point (java.awt.Point)9 Icon (javax.swing.Icon)8 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)8 TestSuiteInfoNew (cbit.vcell.numericstest.TestSuiteInfoNew)7 TreeNode (javax.swing.tree.TreeNode)7 DocumentEditorTreeFolderClass (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass)6 DocumentEditorTreeFolderNode (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode)6 TestCaseNew (cbit.vcell.numericstest.TestCaseNew)6 TestCriteriaNew (cbit.vcell.numericstest.TestCriteriaNew)6 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)6 BioPaxObject (org.vcell.pathway.BioPaxObject)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 Component (java.awt.Component)5