Search in sources :

Example 6 with VCDocumentInfoNode

use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.

the class VCDocumentDbTreeModel method findNode.

private BioModelNode findNode(BioModelNode node, VCDocumentInfo vcDocumentInfo) {
    Object userObject = node.getUserObject();
    if (userObject instanceof VCDocumentInfoNode && ((VCDocumentInfoNode) userObject).getVCDocumentInfo() == vcDocumentInfo) {
        if (ownerTree.isPathSelected(new TreePath(node.getPath()))) {
            return node;
        }
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        BioModelNode child = (BioModelNode) node.getChildAt(i);
        BioModelNode matchNode = findNode(child, vcDocumentInfo);
        if (matchNode != null) {
            break;
        }
    }
    return null;
}
Also used : TreePath(javax.swing.tree.TreePath) VCDocumentInfoNode(cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode)

Example 7 with VCDocumentInfoNode

use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.

the class BioModelDbTreeModel method databaseInsert.

/**
 * @param event cbit.vcell.clientdb.DatabaseEvent
 */
public void databaseInsert(DatabaseEvent databaseEvent) {
    if (databaseEvent.getNewVersionInfo() instanceof BioModelInfo) {
        try {
            BioModelInfo insertedBioModelInfo = (BioModelInfo) databaseEvent.getNewVersionInfo();
            // 
            // get parent of updated version
            // 
            // model1                           (VCDocumentInfoNode)
            // Fri Sept 2, 2001 12:00:00     (BioModelInfo)
            // Fri Sept 1, 2001 10:00:00     (BioModelInfo)
            // 
            // 
            BioModelNode newVersionNode = createVersionSubTree(insertedBioModelInfo);
            // 
            // find owner node (if it is displayed)
            // 
            User owner = insertedBioModelInfo.getVersion().getOwner();
            BioModelNode ownerRoot = ((BioModelNode) getRoot()).findNodeByUserObject(owner);
            BioModelNode parentNode = null;
            if (ownerRoot != null) {
                parentNode = ownerRoot.findNodeByUserObject(new VCDocumentInfoNode(insertedBioModelInfo));
            }
            if (parentNode == null) {
                // 
                // fresh insert
                // Have to create parent node, for all versions of this biomodel,
                // and stick it in the correct order in the tree.
                // 
                parentNode = new BioModelNode(new VCDocumentInfoNode(insertedBioModelInfo), true);
                parentNode.insert(newVersionNode, 0);
                // 
                if (ownerRoot != null) {
                    // !!!!!!!!!!!!!! new insert on top (index=0) .... should do insertion sort !!!!
                    ownerRoot.insert(parentNode, 0);
                    insertNodeInto(parentNode, ownerRoot, 0);
                }
            } else {
                // 
                // already versions there (just add child in the correct position within parent)
                // 
                // !!!!!!!!!! right now ignore order !!!!!!!!!!
                parentNode.insert(newVersionNode, 0);
                insertNodeInto(newVersionNode, parentNode, 0);
            }
        } catch (DataAccessException e) {
            e.printStackTrace(System.out);
            System.out.println("exception responding to databaseInsert(), refreshing whole tree");
            refreshTree();
        }
    }
}
Also used : User(org.vcell.util.document.User) BioModelInfo(org.vcell.util.document.BioModelInfo) VCDocumentInfoNode(cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode) DataAccessException(org.vcell.util.DataAccessException)

Example 8 with VCDocumentInfoNode

use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.

the class BioModelDbTreeModel method createUserSubTree.

/**
 * Insert the method's description here.
 * Creation date: (11/28/00 1:06:51 PM)
 * @return cbit.vcell.desktop.BioModelNode
 * @param docManager cbit.vcell.clientdb.DocumentManager
 */
public BioModelNode createUserSubTree(User user, BioModelInfo[] bioModelInfos) throws DataAccessException {
    // 
    // for each user
    // 
    BioModelNode rootNode = new BioModelNode(user, true);
    for (int i = 0; i < bioModelInfos.length; i++) {
        BioModelInfo bioModelInfo = bioModelInfos[i];
        if (bioModelInfo.getVersion().getOwner().equals(user)) {
            if (!meetSearchCriteria(bioModelInfo)) {
                continue;
            }
            BioModelNode bioModelNode = new BioModelNode(new VCDocumentInfoNode(bioModelInfo), true);
            rootNode.add(bioModelNode);
            // 
            // get list of bioModels with the same branch
            // 
            Vector<BioModelInfo> bioModelBranchList = new Vector<BioModelInfo>();
            bioModelBranchList.addElement(bioModelInfo);
            for (i = i + 1; i < bioModelInfos.length; i++) {
                if (bioModelInfos[i].getVersion().getBranchID().equals(bioModelInfo.getVersion().getBranchID())) {
                    if (!meetSearchCriteria(bioModelInfos[i])) {
                        continue;
                    }
                    bioModelBranchList.add(0, bioModelInfos[i]);
                } else {
                    i--;
                    break;
                }
            }
            BioModelInfo[] bioModelInfosInBranch = null;
            if (getLatestOnly()) {
                bioModelInfosInBranch = new BioModelInfo[1];
                bioModelInfosInBranch[0] = (BioModelInfo) bioModelBranchList.elementAt(0);
            } else {
                bioModelInfosInBranch = new BioModelInfo[bioModelBranchList.size()];
                bioModelBranchList.copyInto(bioModelInfosInBranch);
            }
            for (int versionCount = 0; versionCount < bioModelInfosInBranch.length; versionCount++) {
                bioModelNode.add(createVersionSubTree(bioModelInfosInBranch[versionCount]));
            }
        }
    }
    return rootNode;
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo) VCDocumentInfoNode(cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode) Vector(java.util.Vector)

Example 9 with VCDocumentInfoNode

use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.

the class BioModelDbTreePanel method treeSelection.

/**
 * Comment
 */
protected void treeSelection() {
    TreePath treePath = getJTree1().getSelectionPath();
    if (treePath == null) {
        setSelectedVersionInfo(null);
        return;
    }
    BioModelNode bioModelNode = (BioModelNode) treePath.getLastPathComponent();
    Object object = bioModelNode.getUserObject();
    if (object instanceof BioModelInfo) {
        setSelectedVersionInfo((VersionInfo) object);
    } else if (object instanceof VCDocumentInfoNode && bioModelNode.getChildCount() > 0 && ((BioModelNode) bioModelNode.getChildAt(0)).getUserObject() instanceof BioModelInfo) {
        BioModelInfo bioModelInfo = (BioModelInfo) ((BioModelNode) bioModelNode.getChildAt(0)).getUserObject();
        setSelectedVersionInfo(bioModelInfo);
    } else if (object instanceof BioModelMetaData) {
        BioModelInfo bioModelInfo = (BioModelInfo) ((BioModelNode) bioModelNode.getParent()).getUserObject();
        setSelectedVersionInfo(bioModelInfo);
    } else {
        setSelectedVersionInfo(null);
    }
}
Also used : TreePath(javax.swing.tree.TreePath) BioModelInfo(org.vcell.util.document.BioModelInfo) VCDocumentInfoNode(cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode) BioModelMetaData(cbit.vcell.biomodel.BioModelMetaData)

Example 10 with VCDocumentInfoNode

use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.

the class GeometryDbTreeModel method databaseInsert.

/**
 * @param event cbit.vcell.clientdb.DatabaseEvent
 */
public void databaseInsert(DatabaseEvent databaseEvent) {
    if (databaseEvent.getNewVersionInfo() instanceof GeometryInfo) {
        try {
            GeometryInfo insertedGeometryInfo = (GeometryInfo) databaseEvent.getNewVersionInfo();
            // 
            // get parent of updated version
            // 
            // model1                           (VCDocumentInfoNode)
            // Fri Sept 2, 2001 12:00:00     (GeometryInfo)
            // Fri Sept 1, 2001 10:00:00     (GeometryInfo)
            // 
            // 
            BioModelNode newVersionNode = createVersionSubTree(insertedGeometryInfo);
            // 
            // find owner node (if it is displayed)
            // 
            User owner = insertedGeometryInfo.getVersion().getOwner();
            BioModelNode ownerRoot = ((BioModelNode) getRoot()).findNodeByUserObject(owner);
            BioModelNode parentNode = null;
            if (ownerRoot != null) {
                parentNode = ownerRoot.findNodeByUserObject(new VCDocumentInfoNode(insertedGeometryInfo));
            }
            if (parentNode == null) {
                // 
                // fresh insert
                // Have to create parent node, for all versions of this geometry,
                // and stick it in the correct order in the tree.
                // 
                parentNode = new BioModelNode(new VCDocumentInfoNode(insertedGeometryInfo), true);
                parentNode.insert(newVersionNode, 0);
                // 
                if (ownerRoot != null) {
                    // !!!!!!!!!!!!!! new insert on top (index=0) .... should do insertion sort !!!!
                    ownerRoot.insert(parentNode, 0);
                    insertNodeInto(parentNode, ownerRoot, 0);
                }
            } else {
                // 
                // already versions there (just add child in the correct position within parent)
                // 
                // !!!!!!!!!! right now ignore order !!!!!!!!!!
                parentNode.insert(newVersionNode, 0);
                insertNodeInto(newVersionNode, parentNode, 0);
            }
        } catch (DataAccessException e) {
            e.printStackTrace(System.out);
            System.out.println("exception responding to databaseInsert(), refreshing whole tree");
            refreshTree();
        }
    }
}
Also used : User(org.vcell.util.document.User) GeometryInfo(cbit.vcell.geometry.GeometryInfo) VCDocumentInfoNode(cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

VCDocumentInfoNode (cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode)11 TreePath (javax.swing.tree.TreePath)4 GeometryInfo (cbit.vcell.geometry.GeometryInfo)3 Vector (java.util.Vector)3 DataAccessException (org.vcell.util.DataAccessException)3 BioModelInfo (org.vcell.util.document.BioModelInfo)3 MathModelInfo (org.vcell.util.document.MathModelInfo)3 User (org.vcell.util.document.User)3 VersionInfo (org.vcell.util.document.VersionInfo)2 BioModelMetaData (cbit.vcell.biomodel.BioModelMetaData)1 BigDecimal (java.math.BigDecimal)1 Version (org.vcell.util.document.Version)1