Search in sources :

Example 81 with BioModelNode

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

the class TestingFrmwkTreeModel method updateTree.

/**
 * Invoked when an action occurs.
 */
private void updateTree(final TestSuiteGroup tsg, boolean bRemove) throws Exception {
    if (tsg != null) {
        if (tsg.latestTestSuite == null && tsg.latestTestSuiteInfos != null && !bRemove) {
            BioModelNode finalNode = new BioModelNode("VCell Testing Framework");
            BioModelNode testSuiteNode = null;
            try {
                testSuiteNode = createTestSuiteTree(tsg);
            } finally {
                if (testSuiteNode == null) {
                    testSuiteNode = new BioModelNode("Error Creating TestSuite Tree", false);
                }
            }
            BioModelNode loadTestNode = null;
            try {
                loadTestNode = createLoadTestTree();
            } finally {
                if (loadTestNode == null) {
                    loadTestNode = new BioModelNode("Error Creating LoadTest Tree", false);
                }
            }
            finalNode.add(loadTestNode);
            finalNode.add(testSuiteNode);
            setRoot(finalNode);
        } else if (tsg.latestTestSuite != null && !bRemove) {
            BioModelNode finalNode = null;
            BioModelNode rootNode = getTestSuiteRoot(TestingFrmwkTreeModel.this);
            finalNode = createTestSuiteSubTree(tsg.latestTestSuite);
            for (int i = 0; i < rootNode.getChildCount(); i++) {
                BioModelNode childNode = (BioModelNode) rootNode.getChildAt(i);
                TestSuiteInfoNew childtsin = (TestSuiteInfoNew) childNode.getUserObject();
                if (childtsin.getTSKey().equals(tsg.latestTestSuite.getTSInfoNew().getTSKey())) {
                    removeNodeFromParent(childNode);
                    insertNodeInto(finalNode, rootNode, i);
                    firePropertyChange(TS_NODE_REFRESH, childNode, finalNode);
                    return;
                }
            }
            // Must be NEW TeestSuite
            // insert at top
            insertNodeInto(finalNode, rootNode, rootNode.getChildCount());
        } else if (tsg.latestTestSuiteInfos != null && bRemove) {
            // Remove tree nodes that aren't in DB
            BioModelNode rootNode = getTestSuiteRoot(TestingFrmwkTreeModel.this);
            for (int j = 0; j < tsg.latestTestSuiteInfos.length; j++) {
                for (int i = 0; i < rootNode.getChildCount(); i++) {
                    BioModelNode childNode = (BioModelNode) rootNode.getChildAt(i);
                    TestSuiteInfoNew childtsin = (TestSuiteInfoNew) childNode.getUserObject();
                    if (childtsin.getTSKey().equals(tsg.latestTestSuiteInfos[j].getTSKey())) {
                        removeNodeFromParent(childNode);
                        break;
                    }
                }
            }
        }
    }
}
Also used : BioModelNode(cbit.vcell.desktop.BioModelNode) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew)

Example 82 with BioModelNode

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

the class CSGObjectTreeCellEditor method getTreeCellEditorComponent.

@Override
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
    if (!(value instanceof BioModelNode)) {
        return null;
    }
    Object userObject = ((BioModelNode) value).getUserObject();
    CSGObjectTreeCellRenderer.CSGNodeLabel csgNodeLabel = new CSGObjectTreeCellRenderer.CSGNodeLabel();
    CSGObjectTreeCellRenderer.getCSGNodeLabel(userObject, csgNodeLabel);
    renderer.setOpenIcon(csgNodeLabel.icon);
    renderer.setClosedIcon(csgNodeLabel.icon);
    renderer.setLeafIcon(csgNodeLabel.icon);
    Component component = null;
    if (bRenaming) {
        realEditor = defaultCellEditor;
        component = super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
        if (editingComponent instanceof JTextField) {
            String text = null;
            JTextField textField = (JTextField) editingComponent;
            if (userObject instanceof CSGObject) {
                text = ((CSGObject) userObject).getName();
            } else if (userObject instanceof CSGNode) {
                text = ((CSGNode) userObject).getName();
            }
            textField.setText(text);
        }
    } else {
        if (userObject instanceof CSGScale || userObject instanceof CSGTranslation) {
            realEditor = getVect3dCellEditor();
            Vect3d vect3d = null;
            if (userObject instanceof CSGScale) {
                vect3d = ((CSGScale) userObject).getScale();
            } else if (userObject instanceof CSGTranslation) {
                vect3d = ((CSGTranslation) userObject).getTranslation();
            }
            component = super.getTreeCellEditorComponent(tree, vect3d, isSelected, expanded, leaf, row);
        } else if (userObject instanceof CSGRotation) {
            realEditor = getRotationCellEditor();
            component = super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
        }
    }
    return component;
}
Also used : CSGTranslation(cbit.vcell.geometry.CSGTranslation) CSGNode(cbit.vcell.geometry.CSGNode) BioModelNode(cbit.vcell.desktop.BioModelNode) JTextField(javax.swing.JTextField) CSGRotation(cbit.vcell.geometry.CSGRotation) CSGScale(cbit.vcell.geometry.CSGScale) Vect3d(cbit.vcell.render.Vect3d) CSGObject(cbit.vcell.geometry.CSGObject) Component(java.awt.Component) CSGObject(cbit.vcell.geometry.CSGObject)

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