Search in sources :

Example 11 with BioModelNode

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

the class NumericsTestCellRenderer method getTreeCellRendererComponent.

/**
 * Insert the method's description here.
 * Creation date: (7/27/2000 6:41:57 PM)
 * @return java.awt.Component
 */
public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    // 
    try {
        if (value instanceof BioModelNode) {
            BioModelNode node = (BioModelNode) value;
            if (node.getUserObject() instanceof TestSuiteInfoNew) {
                TestSuiteInfoNew tsn = (TestSuiteInfoNew) node.getUserObject();
            // component.setText(tsn.getTSID()+" "+tsn.getTSVCellBuild()+" "+tsn.getTSNumericsBuild());
            } else if (node.getUserObject() instanceof TestCaseNew) {
                TestCaseNew testCase = (TestCaseNew) node.getUserObject();
                boolean hasUnknown = false;
                boolean isSimRunning = false;
                boolean isSimFailed = false;
                boolean isSimNotRunFialOrDone = false;
                boolean hasReportErrors = false;
                // boolean hasResult = false;
                boolean hasNoRefRegr = false;
                boolean hasFailures = false;
                // AT LEAST ONE SIMULATION HAS NO DATA ...
                boolean hasNoData = false;
                boolean needsReport = false;
                // }
                if (testCase.getTestCriterias() != null) {
                    for (int i = 0; i < testCase.getTestCriterias().length; i += 1) {
                        TestCriteriaNew tcrit = testCase.getTestCriterias()[i];
                        if (tcrit.getReportStatus() != null) {
                            if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_NEEDSREPORT)) {
                                needsReport = true;
                            }
                            if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_RPERROR)) {
                                hasReportErrors = true;
                            }
                            if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_NOREFREGR)) {
                                hasNoRefRegr = true;
                            }
                            if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_FAILEDVARS)) {
                                hasFailures = true;
                            }
                            if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_NODATA)) {
                                hasNoData = true;
                            }
                            if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_SIMRUNNING)) {
                                isSimRunning = true;
                            }
                            if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_SIMFAILED)) {
                                isSimFailed = true;
                            }
                            if (tcrit.getReportStatus().equals(cbit.vcell.numericstest.TestCriteriaNew.TCRIT_STATUS_SIMNOTRUNFAILDONE)) {
                                isSimNotRunFialOrDone = true;
                            }
                        }
                    }
                }
                // if(node.getRenderHint(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.SIMULATIONS_NO_REPORT) instanceof Boolean){
                // Boolean tc_NR = (Boolean)node.getRenderHint(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.SIMULATIONS_NO_REPORT);
                // if(tc_NR.booleanValue()){
                // hasResult = false;
                // }
                // }
                setComponentProperties(component, (TestCaseNew) node.getUserObject(), /*hasResult,*/
                hasFailures, hasNoData, hasNoRefRegr, hasReportErrors, isSimRunning, isSimFailed, needsReport, isSimNotRunFialOrDone);
            } else if (node.getUserObject() instanceof TestCriteriaNew) {
                TestCriteriaNew testCriteria = (TestCriteriaNew) node.getUserObject();
                String extraText = null;
                if (!testCriteria.getReportStatus().equals(TestCriteriaNew.TCRIT_STATUS_PASSED)) {
                    extraText = testCriteria.getReportStatus() + " " + (testCriteria.getReportStatusMessage() != null ? " " + testCriteria.getReportStatusMessage().substring(0, Math.min(100, testCriteria.getReportStatusMessage().length())) : "");
                }
                component.setText("[" + testCriteria.getSimInfo().getVersion().getVersionKey() + "] " + testCriteria.getSimInfo().getVersion().getName() + (extraText != null ? " (" + extraText + ")" : ""));
                component.setToolTipText(" Test Criteria info");
                if (extraText != null) {
                    component.setForeground(java.awt.Color.magenta);
                }
                if (testCriteria.getReportStatus().equals(TestCriteriaNew.TCRIT_STATUS_FAILEDVARS)) {
                    component.setForeground(java.awt.Color.red);
                }
            // //TestCaseNew tcn = null;
            // //javax.swing.tree.DefaultMutableTreeNode prevNode = (javax.swing.tree.DefaultMutableTreeNode)node.getParent();
            // //if(prevNode != null && prevNode.getUserObject() instanceof cbit.vcell.numericstest.TestCaseNew){
            // //tcn = (TestCaseNew)prevNode.getUserObject();
            // //}
            // boolean hasResult = false;
            // TestCriteriaNew testCriteria = (TestCriteriaNew)node.getUserObject();
            // if(testCriteria.getVarComparisonSummaries() != null && testCriteria.getVarComparisonSummaries().length != 0){
            // hasResult = true;
            // }
            // //boolean hasNoRefRegr = false;
            // //if(tcn != null){
            // //if(tcn.getType().equals(cbit.vcell.numericstest.TestCaseNew.REGRESSION) &&
            // //testCriteria.getRegressionSimInfo() == null){
            // //hasNoRefRegr = true;
            // //}
            // //}
            // if(!hasResult /*|| hasNoRefRegr*/){
            // component.setForeground(java.awt.Color.magenta);
            // }
            // component.setText(testCriteria.getSimInfo().getVersion().getName()+
            // (testCriteria.getReportStatus() != null &&
            // testCriteria.getReportStatus().startsWith(TestCriteriaNew.TCRIT_STATUS_SIMRUNNING)?"(SimRunning)":"")+
            // (testCriteria.getReportStatus() != null &&
            // testCriteria.getReportStatus().startsWith(TestCriteriaNew.TCRIT_STATUS_SIMFAILED)?"(SimFailed)":"")
            // /*+(hasNoRefRegr?" (No Ref Regr)":"")*/);
            // component.setToolTipText(" Test Criteria info");
            } else if (node.getRenderHint(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.FAILED_VARIABLE_MAE_MRE) instanceof Boolean) {
                Boolean fv_MAE_MRE = (Boolean) node.getRenderHint(cbit.vcell.client.desktop.testingframework.TestingFrmwkTreeModel.FAILED_VARIABLE_MAE_MRE);
                if (fv_MAE_MRE.booleanValue()) {
                    component.setForeground(java.awt.Color.red);
                } else {
                    component.setForeground(java.awt.Color.black);
                }
            }
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    // 
    return component;
}
Also used : JLabel(javax.swing.JLabel) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) BioModelNode(cbit.vcell.desktop.BioModelNode) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew)

Example 12 with BioModelNode

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

the class MolecularTypePropertiesPanel method showPopupMenu.

private void showPopupMenu(MouseEvent e) {
    if (!e.isPopupTrigger()) {
        return;
    }
    if (popupMenu == null) {
        popupMenu = new JPopupMenu();
    }
    if (popupMenu.isShowing()) {
        return;
    }
    selectClickPath(e);
    TreePath[] selectedPaths = molecularTypeTree.getSelectionPaths();
    boolean bDelete = true;
    boolean bAdd = true;
    if (selectedPaths == null) {
        return;
    }
    for (TreePath tp : selectedPaths) {
        Object obj = tp.getLastPathComponent();
        if (obj == null || !(obj instanceof BioModelNode)) {
            continue;
        }
        BioModelNode selectedNode = (BioModelNode) obj;
        Object userObject = selectedNode.getUserObject();
        if (userObject instanceof MolecularType) {
            getAddFromTreeMenuItem().setText("Add " + MolecularComponent.typeName);
            bAdd = true;
            bDelete = false;
        } else if (userObject instanceof MolecularComponent) {
            getAddFromTreeMenuItem().setText("Add " + ComponentStateDefinition.typeName);
            bAdd = true;
            bDelete = true;
        } else if (userObject instanceof ComponentStateDefinition) {
            bAdd = false;
            bDelete = true;
        }
    }
    popupMenu.removeAll();
    // everything can be renamed
    popupMenu.add(getRenameFromTreeMenuItem());
    if (bDelete) {
        popupMenu.add(getDeleteFromTreeMenuItem());
    }
    popupMenu.add(new JSeparator());
    if (bAdd) {
        popupMenu.add(getAddFromTreeMenuItem());
    }
    Point mousePoint = e.getPoint();
    popupMenu.show(molecularTypeTree, mousePoint.x, mousePoint.y);
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) TreePath(javax.swing.tree.TreePath) MolecularComponent(org.vcell.model.rbm.MolecularComponent) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) BioModelNode(cbit.vcell.desktop.BioModelNode) Point(java.awt.Point) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition)

Example 13 with BioModelNode

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

the class MolecularTypePropertiesPanel method selectClickPath.

// private void changeFreeTextAnnotation() {
// try{
// if (molecularType == 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(molecularType),textAreaStr)){
// vcMetaData.setFreeTextAnnotation(molecularType, textAreaStr);
// }
// }
// } catch(Exception e){
// e.printStackTrace(System.out);
// PopupGenerator.showErrorDialog(this,"Edit Molecule Error\n"+e.getMessage(), e);
// }
// }
private void selectClickPath(MouseEvent e) {
    Point mousePoint = e.getPoint();
    TreePath clickPath = molecularTypeTree.getPathForLocation(mousePoint.x, mousePoint.y);
    if (clickPath == null) {
        return;
    }
    Object rightClickNode = clickPath.getLastPathComponent();
    if (rightClickNode == null || !(rightClickNode instanceof BioModelNode)) {
        return;
    }
    TreePath[] selectedPaths = molecularTypeTree.getSelectionPaths();
    if (selectedPaths == null || selectedPaths.length == 0) {
        return;
    }
    boolean bFound = false;
    for (TreePath tp : selectedPaths) {
        if (tp.equals(clickPath)) {
            bFound = true;
            break;
        }
    }
    if (!bFound) {
        molecularTypeTree.setSelectionPath(clickPath);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) RelationshipObject(org.vcell.relationship.RelationshipObject) BioPaxObject(org.vcell.pathway.BioPaxObject) BioModelNode(cbit.vcell.desktop.BioModelNode) Point(java.awt.Point)

Example 14 with BioModelNode

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

the class MolecularTypeTreeModel method populateTree.

public void populateTree() {
    if (molecularType == null) {
        return;
    }
    rootNode.setUserObject(molecularType);
    rootNode.removeAllChildren();
    for (MolecularComponent molecularComponent : molecularType.getComponentList()) {
        BioModelNode node = createMolecularComponentNode(molecularComponent);
        rootNode.add(node);
    }
    nodeStructureChanged(rootNode);
    GuiUtils.treeExpandAllRows(ownerTree);
}
Also used : MolecularComponent(org.vcell.model.rbm.MolecularComponent) BioModelNode(cbit.vcell.desktop.BioModelNode)

Example 15 with BioModelNode

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

the class MolecularTypeTreeModel method valueForPathChanged.

@Override
public void valueForPathChanged(TreePath path, Object newValue) {
    Object obj = path.getLastPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object userObject = selectedNode.getUserObject();
    try {
        if (newValue instanceof String) {
            String inputString = (String) newValue;
            if (inputString == null || inputString.length() == 0) {
                return;
            }
            if (userObject instanceof MolecularType) {
                String mangled = TokenMangler.fixTokenStrict(inputString);
                if (!mangled.equals(inputString)) {
                    String errMsg = ((Displayable) userObject).getDisplayType() + " '" + inputString + "' not legal identifier, try '" + mangled + "'";
                    throw new RuntimeException(errMsg);
                }
                ((MolecularType) userObject).setName(inputString);
            } else if (userObject instanceof MolecularComponent) {
                String mangled = TokenMangler.fixTokenStrict(inputString);
                if (!mangled.equals(inputString)) {
                    String errMsg = ((Displayable) userObject).getDisplayType() + " '" + inputString + "' not legal identifier, try '" + mangled + "'";
                    throw new RuntimeException(errMsg);
                }
                ((MolecularComponent) userObject).setName(inputString);
            } else if (userObject instanceof ComponentStateDefinition) {
                if (inputString.matches("[A-Z_a-z0-9]+")) {
                    ((ComponentStateDefinition) userObject).setName(inputString);
                }
            }
        }
    } catch (Exception ex) {
        DialogUtils.showErrorDialog(ownerTree, ex.getMessage());
    }
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) Displayable(org.vcell.util.Displayable) MolecularComponent(org.vcell.model.rbm.MolecularComponent) 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