Search in sources :

Example 61 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class BioModelCellRenderer 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(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 DateNode) {
            DateNode dateNode = (DateNode) value;
            AnnotationQualifier qualifier = dateNode.getDateQualifier();
            String colorString = (sel) ? "white" : "black";
            component.setText("<html>" + qualifier.getDescription() + "&nbsp;<font color=\"" + colorString + "\">" + dateNode.getDate().getDateString() + "</font></html>");
        } else if (value instanceof LinkNode) {
            LinkNode ln = (LinkNode) value;
            String link = ln.getLink();
            String text = ln.getText();
            String qualifier = ln.getMiriamQualifier().getDescription();
            if (link != null) {
                String colorString = (sel) ? "white" : "blue";
                component.setToolTipText("Double-click to open link");
                component.setText("<html>" + qualifier + "&nbsp;<font color=\"" + colorString + "\"><a href=" + link + ">" + text + "</a></font></html>");
            } else {
                String colorString = (sel) ? "white" : "black";
                component.setText("<html>" + qualifier + "&nbsp;<font color=\"" + colorString + "\">" + text + "</font></html>");
            }
        } else if (value instanceof BioModelNode) {
            BioModelNode node = (BioModelNode) value;
            Object userObject = node.getUserObject();
            if (userObject instanceof User) {
                String label = null;
                if (sessionUser != null && sessionUser.compareEqual((User) userObject)) {
                    label = "My BioModels (" + ((User) userObject).getName() + ") (" + node.getChildCount() + ")";
                } else {
                    label = ((User) userObject).getName() + "(abcdefghijklmnopq)(000000)";
                }
                component.setToolTipText(label);
                component.setText(label);
            } else if (userObject instanceof BioModelInfo) {
                BioModelInfo biomodelInfo = (BioModelInfo) userObject;
                if (biomodelInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Archived)) {
                    component.setText("(Archived) " + component.getText());
                } else if (biomodelInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Published)) {
                    component.setText("(Published) " + component.getText());
                }
            } else if (userObject instanceof Geometry) {
                Geometry geo = (Geometry) userObject;
                String label = "";
                // geomety info, when spatial--shows name+1D/2D/3D
                if (geo.getDimension() > 0) {
                    label = geo.getName() + " (" + geo.getDimension() + "D)";
                } else {
                    label = BioModelChildSummary.COMPARTMENTAL_GEO_STR;
                }
                component.setToolTipText("Geometry");
                component.setText(label);
                setIcon(fieldGeometryIcon);
            } else if (userObject instanceof String && "AppType".equals(node.getRenderHint("type"))) {
                String label = (String) userObject;
                component.setToolTipText("Application type");
                component.setText(label);
                setIcon(VCellIcons.mathTypeIcon);
            } else if (userObject instanceof VCDocumentInfoNode) {
                VCDocumentInfoNode infonode = (VCDocumentInfoNode) userObject;
                User nodeUser = infonode.getVCDocumentInfo().getVersion().getOwner();
                String modelName = infonode.getVCDocumentInfo().getVersion().getName();
                String username = nodeUser.getName();
                if (nodeUser.compareEqual(sessionUser) || username.equals(VCDocumentDbTreeModel.USER_tutorial) || username.equals(VCDocumentDbTreeModel.USER_Education) || username.equals(VCDocumentDbTreeModel.USER_tutorial610) || username.equals(VCDocumentDbTreeModel.USER_tutorial611)) {
                    component.setText(modelName);
                } else {
                    component.setText("<html><b>" + username + " </b> : " + modelName + "</html>");
                }
            }
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    // 
    if (component.getToolTipText() == null || component.getToolTipText().length() == 0) {
        component.setToolTipText(component.getText());
    }
    return component;
}
Also used : Geometry(cbit.vcell.geometry.Geometry) DateNode(cbit.vcell.xml.gui.MiriamTreeModel.DateNode) AnnotationQualifier(org.vcell.sybil.models.AnnotationQualifier) User(org.vcell.util.document.User) BioModelInfo(org.vcell.util.document.BioModelInfo) JLabel(javax.swing.JLabel) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)

Example 62 with BioModelInfo

use of org.vcell.util.document.BioModelInfo 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 63 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class BioModelDbTreeModel method createBaseTree.

/**
 * 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
 */
protected void createBaseTree() throws DataAccessException {
    VCDocumentDbTreeModel.initBaseTree(rootNode, new BioModelNode[] { myModelsNode, sharedModelsNode, publicModelsNode, tutorialModelsNode, educationModelsNode }, "Biological Models", sharedModelsNode, SHARED_BIO_MODELS);
    BioModelInfo[] bioModelInfos = getDocumentManager().getBioModelInfos();
    User loginUser = getDocumentManager().getUser();
    TreeMap<String, BioModelNode> treeMap = null;
    try {
        treeMap = VCDocumentDbTreeModel.initOwners(bioModelInfos, loginUser, this, this.getClass().getMethod("createUserSubTree", new Class[] { User.class, BioModelInfo[].class }));
    } catch (Exception e) {
        e.printStackTrace();
        treeMap = new TreeMap<String, BioModelNode>();
        treeMap.put(loginUser.getName(), new BioModelNode("Error:" + e.getMessage()));
    }
    initFinalTree(this, treeMap, loginUser);
}
Also used : User(org.vcell.util.document.User) BioModelInfo(org.vcell.util.document.BioModelInfo) TreeMap(java.util.TreeMap) DataAccessException(org.vcell.util.DataAccessException)

Example 64 with BioModelInfo

use of org.vcell.util.document.BioModelInfo 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 65 with BioModelInfo

use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.

the class BioModelDbTreePanel method getBioModelVersionDates.

/**
 * Insert the method's description here.
 * Creation date: (10/3/2002 10:34:00 AM)
 */
private BioModelInfo[] getBioModelVersionDates(BioModelInfo thisBioModelInfo) throws DataAccessException {
    // 
    if (thisBioModelInfo == null) {
        return new BioModelInfo[0];
    }
    BioModelInfo[] bioModelInfos = getDocumentManager().getBioModelInfos();
    // 
    // From the list of biomodels in the workspace, get list of biomodels with the same branch ID.
    // This is the list of different versions of the same biomodel.
    // 
    Vector<BioModelInfo> bioModelBranchList = new Vector<BioModelInfo>();
    for (int i = 0; i < bioModelInfos.length; i++) {
        BioModelInfo bioModelInfo = bioModelInfos[i];
        if (bioModelInfo.getVersion().getBranchID().equals(thisBioModelInfo.getVersion().getBranchID())) {
            bioModelBranchList.add(bioModelInfo);
        }
    }
    if (bioModelBranchList.size() == 0) {
        JOptionPane.showMessageDialog(this, "No Versions in biomodel", "Error comparing BioModels", JOptionPane.ERROR_MESSAGE);
        throw new NullPointerException("No Versions in biomodel!");
    }
    BioModelInfo[] bioModelInfosInBranch = new BioModelInfo[bioModelBranchList.size()];
    bioModelBranchList.copyInto(bioModelInfosInBranch);
    // 
    // From the versions list, remove the currently selected version and return the remaining list of
    // versions for the biomodel
    // 
    BioModelInfo[] revisedBMInfosInBranch = new BioModelInfo[bioModelInfosInBranch.length - 1];
    int j = 0;
    for (int i = 0; i < bioModelInfosInBranch.length; i++) {
        if (!thisBioModelInfo.getVersion().getDate().equals(bioModelInfosInBranch[i].getVersion().getDate())) {
            revisedBMInfosInBranch[j] = bioModelInfosInBranch[i];
            j++;
        }
    }
    return revisedBMInfosInBranch;
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo) Vector(java.util.Vector)

Aggregations

BioModelInfo (org.vcell.util.document.BioModelInfo)79 DataAccessException (org.vcell.util.DataAccessException)38 MathModelInfo (org.vcell.util.document.MathModelInfo)37 BioModel (cbit.vcell.biomodel.BioModel)25 GeometryInfo (cbit.vcell.geometry.GeometryInfo)22 KeyValue (org.vcell.util.document.KeyValue)18 SimulationContext (cbit.vcell.mapping.SimulationContext)17 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)15 BigString (org.vcell.util.BigString)14 User (org.vcell.util.document.User)14 Vector (java.util.Vector)13 Simulation (cbit.vcell.solver.Simulation)12 XmlParseException (cbit.vcell.xml.XmlParseException)12 SQLException (java.sql.SQLException)12 XMLSource (cbit.vcell.xml.XMLSource)10 MathModel (cbit.vcell.mathmodel.MathModel)9 Hashtable (java.util.Hashtable)9 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)9 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)8 Geometry (cbit.vcell.geometry.Geometry)7