Search in sources :

Example 21 with BioModelNode

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

the class RbmSpeciesContextTreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    setBorder(null);
    if (value instanceof BioModelNode) {
        BioModelNode node = (BioModelNode) value;
        Object userObject = node.getUserObject();
        obj = userObject;
        String text = null;
        Icon icon = null;
        String toolTip = null;
        if (userObject instanceof SpeciesContext) {
            SpeciesContext sc = (SpeciesContext) userObject;
            text = toHtml(sc);
            toolTip = toHtml(sc);
            if (sc.hasSpeciesPattern()) {
                icon = VCellIcons.rbmSpeciesBlueIcon;
            } else {
                icon = VCellIcons.rbmSpeciesGreenIcon;
            }
        } else if (userObject instanceof MolecularTypePattern) {
            MolecularTypePattern molecularTypePattern = (MolecularTypePattern) userObject;
            text = toHtml(molecularTypePattern, true);
            toolTip = toHtml(molecularTypePattern, true);
            if (owner == null) {
                icon = VCellIcons.rbmMolecularTypeSimpleIcon;
                ;
            } else {
                Graphics gc = owner.getGraphics();
                icon = new MolecularTypeSmallShape(1, 5, molecularTypePattern.getMolecularType(), null, gc, molecularTypePattern.getMolecularType(), null, issueManager);
            }
        } else if (userObject instanceof MolecularComponentPattern) {
            MolecularComponentPattern mcp = (MolecularComponentPattern) userObject;
            text = toHtml(mcp, true);
            toolTip = toHtmlWithTip(mcp, true);
            icon = VCellIcons.rbmComponentGreenIcon;
            if (mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                icon = VCellIcons.rbmComponentGreenStateIcon;
            }
        } else if (userObject instanceof StateLocal) {
            // this code is still here but we don't show the states or the bonds in the tree anymore
            StateLocal sl = (StateLocal) userObject;
            text = toHtml(sl, true);
            toolTip = toHtmlWithTip(sl, true);
            icon = VCellIcons.rbmComponentStateIcon;
        } else if (userObject instanceof BondLocal) {
            BondLocal bl = (BondLocal) userObject;
            text = toHtml(bl, sel);
            toolTip = toHtmlWithTip(bl, true);
            icon = VCellIcons.rbmBondIcon;
        } else {
            if (userObject != null) {
                System.out.println(userObject.toString());
                text = userObject.toString();
            } else {
                text = "null user object";
            }
        }
        setText(text);
        setIcon(icon);
        setToolTipText(toolTip == null ? text : toolTip);
    }
    return this;
}
Also used : Graphics(java.awt.Graphics) MolecularTypeSmallShape(cbit.vcell.graph.MolecularTypeSmallShape) BondLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.BondLocal) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) StateLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal) BioModelNode(cbit.vcell.desktop.BioModelNode) Icon(javax.swing.Icon) SpeciesContext(cbit.vcell.model.SpeciesContext) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 22 with BioModelNode

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

the class ReactionRulePropertiesTreeModel method findObjectPath.

public TreePath findObjectPath(BioModelNode startNode, Object object) {
    if (startNode == null) {
        startNode = rootNode;
    }
    Object userObject = startNode.getUserObject();
    if (userObject == object || userObject instanceof ReactionRuleParticipant && ((ReactionRuleParticipant) userObject).getSpeciesPattern() == object) {
        return new TreePath(startNode.getPath());
    }
    for (int i = 0; i < startNode.getChildCount(); i++) {
        BioModelNode childNode = (BioModelNode) startNode.getChildAt(i);
        TreePath path = findObjectPath(childNode, object);
        if (path != null) {
            return path;
        }
    }
    return null;
}
Also used : TreePath(javax.swing.tree.TreePath) ReactionRuleParticipant(cbit.vcell.model.ReactionRuleParticipant) BioModelNode(cbit.vcell.desktop.BioModelNode)

Example 23 with BioModelNode

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

the class ReactionRulePropertiesTreeModel method createMolecularComponentPatternNode.

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

Example 24 with BioModelNode

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

the class TestingFrameworkPanel method loadTestTreeAction.

private void loadTestTreeAction(TreeExpansionEvent event) {
    BioModelNode expandedNode = (BioModelNode) (event.getPath().getLastPathComponent());
    if (expandedNode == null || !(expandedNode.getUserObject() instanceof String)) {
        return;
    }
    if (((String) expandedNode.getUserObject()).equals(TestingFrmwkTreeModel.LOAD_TEST_SUBTREE_NAME)) {
        // tsRefreshListener.rememberSelectedNode();
        ActionEvent refresh = new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, TestingFrameworkPanel.REFRESH_XML_LOAD_TEST);
        TestingFrameworkPanel.this.refireActionPerformed(refresh);
    }
}
Also used : ActionEvent(java.awt.event.ActionEvent) BioModelNode(cbit.vcell.desktop.BioModelNode)

Example 25 with BioModelNode

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

the class TestingFrameworkPanel method actionsOnMouseClick.

/**
 * Comment
 */
private void actionsOnMouseClick(MouseEvent mouseEvent) {
    if (mouseEvent.isPopupTrigger()) {
        if (getJTree1().getSelectionCount() <= 1) {
            getJTree1().setSelectionPath(getJTree1().getPathForLocation(mouseEvent.getPoint().x, mouseEvent.getPoint().y));
        }
        if (!checkAllSameType()) {
            JPopupMenu jPopupMenu = new JPopupMenu();
            jPopupMenu.add(selectIncompatibleWarning);
            jPopupMenu.show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
            return;
        }
        if (isLoadTestPopup()) {
            getLoadTestMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
        } else if (getTreeSelection() instanceof String) {
            if (((String) getTreeSelection()).equals(TestingFrmwkTreeModel.TEST_SUITE_SUBTREE_NAME)) {
                getMainPopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
            }
        } else if (getTreeSelection() instanceof TestingFrmwkTreeModel.TestCriteriaVarUserObj) {
            getTCritVarPopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
        } else if (getTreeSelection() instanceof TestSuiteInfoNew) {
            getRemoveDiffTestCriteriaJMenuItem().setEnabled(false);
            if (getJTree1().getSelectionCount() == 2) {
                TestSuiteInfoNew testSuiteInfoNew0 = (TestSuiteInfoNew) ((BioModelNode) getSelectedTreePaths()[0].getLastPathComponent()).getUserObject();
                TestSuiteInfoNew testSuiteInfoNew1 = (TestSuiteInfoNew) ((BioModelNode) getSelectedTreePaths()[1].getLastPathComponent()).getUserObject();
                if (testSuiteInfoNew0.getTSDate().compareTo(testSuiteInfoNew1.getTSDate()) < 0) {
                    getRemoveDiffTestCriteriaJMenuItem().setEnabled(!testSuiteInfoNew1.isLocked());
                } else {
                    getRemoveDiffTestCriteriaJMenuItem().setEnabled(!testSuiteInfoNew0.isLocked());
                }
            }
            boolean bMenuValid = getJTree1().getSelectionCount() == 1;
            getRefreshTestSuiteJMenuItem().setEnabled(bMenuValid);
            boolean isLocked = false;
            if (getJTree1().getSelectionCount() == 1) {
                isLocked = ((TestSuiteInfoNew) getTreeSelection()).isLocked();
            }
            // Disable if TestSuite locked
            getDuplicateTSMenuItem().setEnabled(bMenuValid);
            getRunAllMenuItem().setEnabled(bMenuValid && !isLocked);
            getGenTSReportMenuItem().setEnabled(!checkAnyLocked());
            getAddTestCaseMenuItem().setEnabled(bMenuValid && !isLocked);
            getRemoveTSMenuItem().setEnabled(bMenuValid && !isLocked);
            getEditAnnotationTestSuiteMenuItem().setEnabled(bMenuValid && !isLocked);
            getLockTestSuiteMenuItem().setEnabled(bMenuValid && !isLocked);
            getRemoveCompiledSolversJMenuItem().setEnabled(bMenuValid && !isLocked);
            // Set enable based on conditions if not locked
            if (bMenuValid && !isLocked) {
                if (((TreeNode) getJTree1().getSelectionPath().getLastPathComponent()).getChildCount() == 0) {
                    getDuplicateTSMenuItem().setEnabled(false);
                    getRunAllMenuItem().setEnabled(false);
                    getGenTSReportMenuItem().setEnabled(false);
                } else {
                    getDuplicateTSMenuItem().setEnabled(true);
                    getRunAllMenuItem().setEnabled(true);
                    getGenTSReportMenuItem().setEnabled(true);
                }
            }
            getTestSuitePopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
        } else if (getTreeSelection() instanceof TestCaseNew) {
            boolean bMenuValid = getJTree1().getSelectionCount() == 1;
            getRefreshTestCaseJMenuItem().setEnabled(bMenuValid);
            getLoadMenuItem().setEnabled(bMenuValid);
            boolean isLocked = false;
            if (getJTree1().getSelectionCount() == 1) {
                isLocked = ((TestSuiteInfoNew) ((BioModelNode) ((TreeNode) getJTree1().getSelectionPath().getLastPathComponent()).getParent()).getUserObject()).isLocked();
            }
            getRemoveMenuItem().setEnabled(!checkAnyLocked());
            getRunSimsMenuItem().setEnabled(bMenuValid && !isLocked);
            getGenerateTCReportMenuItem().setEnabled(!checkAnyLocked());
            getChangeTypeToSteadyMenuItem().setEnabled(bMenuValid && !isLocked);
            getEditAnnotationTestCaseMenuItem().setEnabled(bMenuValid && !isLocked);
            if (bMenuValid && !isLocked) {
                TestCaseNew tcNew = (TestCaseNew) getTreeSelection();
                if (tcNew.getType().equals(TestCaseNew.EXACT) || tcNew.getType().equals(TestCaseNew.EXACT_STEADY)) {
                    getChangeTypeToSteadyMenuItem().setEnabled(true);
                } else {
                    getChangeTypeToSteadyMenuItem().setEnabled(false);
                }
            }
            getTestCasePopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
        } else if (getTreeSelection() instanceof TestCriteriaNew) {
            boolean bMenuValid = getJTree1().getSelectionCount() == 1;
            getRefreshTestCriteriaJMenuItem().setEnabled(bMenuValid);
            getViewMenuItem().setEnabled(bMenuValid);
            getCompareMenuItem().setEnabled(bMenuValid);
            getCompareUserDefinedMenuItem().setEnabled(bMenuValid);
            getQueryTCritCrossRefMenuItem1().setEnabled(bMenuValid);
            getTestCriteriaCopySimKeyMenuItem().setEnabled(bMenuValid);
            boolean isLocked = false;
            if (getJTree1().getSelectionCount() == 1) {
                isLocked = ((TestSuiteInfoNew) ((BioModelNode) ((TreeNode) getJTree1().getSelectionPath().getLastPathComponent()).getParent().getParent()).getUserObject()).isLocked();
            }
            getRunSimMenuItem().setEnabled(!checkAnyLocked());
            getEditTCrMenuItem().setEnabled(bMenuValid && !isLocked);
            getRemoveTestCritMenuItem().setEnabled(!checkAnyLocked());
            getGenerateTCRitReportMenuItem1().setEnabled(!checkAnyLocked());
            getGenerateTCRitReportUserDefinedReferenceMenuItem1().setEnabled(!checkAnyLocked());
            if (bMenuValid && !isLocked) {
                TestCriteriaNew testCriteria = (TestCriteriaNew) getTreeSelection();
                if (testCriteria.getRegressionSimInfo() == null) {
                    getCompareMenuItem().setEnabled(false);
                } else {
                    getCompareMenuItem().setEnabled(true);
                }
            }
            getSimulationPopupMenu().show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
        }
    } else {
        getMainPopupMenu().setVisible(false);
        getTestSuitePopupMenu().setVisible(false);
        getTestCasePopupMenu().setVisible(false);
        getTCritVarPopupMenu().setVisible(false);
        getSimulationPopupMenu().setVisible(false);
    }
}
Also used : TreeNode(javax.swing.tree.TreeNode) TestCriteriaNew(cbit.vcell.numericstest.TestCriteriaNew) BioModelNode(cbit.vcell.desktop.BioModelNode) TestCaseNew(cbit.vcell.numericstest.TestCaseNew) TestSuiteInfoNew(cbit.vcell.numericstest.TestSuiteInfoNew) JPopupMenu(javax.swing.JPopupMenu)

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