Search in sources :

Example 26 with User

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

the class MathModelMetaDataCellRenderer 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);
    // 
    if (!leaf && expanded) {
        setIcon(fieldFolderOpenIcon);
    } else if (!leaf && !expanded) {
        setIcon(fieldFolderClosedIcon);
    }
    try {
        if (value instanceof BioModelNode) {
            BioModelNode node = (BioModelNode) value;
            boolean bLoaded = false;
            // 
            if (node.getUserObject() instanceof String && "Geometry".equals(node.getRenderHint("type"))) {
                String label = (String) node.getUserObject();
                component.setToolTipText("Geometry");
                component.setText(label);
                setIcon(fieldGeometryIcon);
            } else if (node.getUserObject() instanceof String && "SimulationContext".equals(node.getRenderHint("type"))) {
                String label = (String) node.getUserObject();
                component.setToolTipText("Application");
                component.setText(label);
                setIcon(fieldSimulationContextIcon);
            } else if (node.getUserObject() instanceof String && "Simulation".equals(node.getRenderHint("type"))) {
                String label = (String) node.getUserObject();
                component.setToolTipText("Simulation");
                component.setText(label);
                setIcon(fieldSimulationIcon);
            } else if (node.getUserObject() instanceof String && "AppType".equals(node.getRenderHint("type"))) {
                String label = (String) node.getUserObject();
                component.setToolTipText("Model Type");
                component.setText(label);
                setIcon(fieldAppTypeIcon);
            } else if (node.getUserObject() instanceof String && "Provenance".equals(node.getRenderHint("type"))) {
                String label = (String) node.getUserObject();
                component.setToolTipText("Provenance");
                component.setText("<html><b>" + label + "</b></html>");
                setIcon(fieldTextIcon);
            } else if (node.getUserObject() instanceof Annotation) {
                String label = ((Annotation) node.getUserObject()).toString();
                component.setToolTipText("Version Annotation");
                component.setText(label);
                setIcon(null);
            // ------------------------------------------------------
            } else if (node.getUserObject() instanceof String && "PublicationsInfo".equals(node.getRenderHint("type"))) {
                String label = (String) node.getUserObject();
                component.setToolTipText("Publications Info");
                component.setText("<html><b>" + label + "</b></html>");
                setIcon(fieldTextIcon);
            } else if (node.getUserObject() instanceof PublicationInfo && "PublicationInfoTitle".equals(node.getRenderHint("type"))) {
                PublicationInfo info = (PublicationInfo) node.getUserObject();
                component.setToolTipText("Title");
                String text = "<b>" + info.getTitle() + "</b>";
                component.setText("<html>" + text + "</html>");
                setIcon(fieldTextIcon);
            } else if (node.getUserObject() instanceof PublicationInfo && "PublicationInfoAuthors".equals(node.getRenderHint("type"))) {
                PublicationInfo info = (PublicationInfo) node.getUserObject();
                component.setToolTipText("Authors");
                String text = "";
                int count = 0;
                for (String author : info.getAuthors()) {
                    if (count > 0) {
                        text += "; ";
                    }
                    text += author;
                    count++;
                }
                component.setText("<html>" + text + "</html>");
                setIcon(null);
            } else if (node.getUserObject() instanceof PublicationInfo && "PublicationInfoCitation".equals(node.getRenderHint("type"))) {
                PublicationInfo info = (PublicationInfo) node.getUserObject();
                component.setToolTipText("Citation");
                String text = "";
                text += info.getCitation();
                component.setText("<html>" + text + "</html>");
                setIcon(null);
            } else if (node.getUserObject() instanceof PublicationInfo && "PublicationInfoDoi".equals(node.getRenderHint("type"))) {
                PublicationInfo info = (PublicationInfo) node.getUserObject();
                component.setToolTipText("DOI");
                String text = "<a href=\"" + BeanUtils.getDynamicClientProperties().getProperty(PropertyLoader.DOI_URL) + info.getDoi() + "\">" + "DOI: " + info.getDoi() + "</a>";
                component.setText("<html>" + text + "</html>");
                setIcon(null);
            } else if (node.getUserObject() instanceof PublicationInfo && "PublicationInfoUrl".equals(node.getRenderHint("type"))) {
                PublicationInfo info = (PublicationInfo) node.getUserObject();
                component.setToolTipText("PMID");
                // we know from the tree model that this is not null or empty
                String pmid = info.getUrl();
                if (pmid.contains("list_uids=")) {
                    // ex: http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&dopt=Citation&list_uids=12644446
                    pmid = pmid.substring(pmid.lastIndexOf("list_uids=") + "list_uids=".length());
                } else if (pmid.contains("pubmed/")) {
                    // ex: http://www.ncbi.nlm.nih.gov/pubmed/23093806
                    pmid = pmid.substring(pmid.lastIndexOf("/") + 1);
                } else if (pmid.contains("pubmed.ncbi")) {
                    // ex: https://pubmed.ncbi.nlm.nih.gov/34360784/
                    if (pmid.endsWith("/")) {
                        pmid = pmid.substring(0, pmid.length() - 1);
                    }
                    pmid = pmid.substring(pmid.lastIndexOf("/") + 1);
                } else {
                    // something that we don't know how to parse
                    pmid = "?";
                }
                String text = "<a href=\"" + info.getUrl() + "\">" + "PubMed PMID: " + pmid + "</a>";
                component.setText("<html>" + text + "</html>");
                setIcon(null);
            } else if (node.getUserObject() instanceof String && "GeneralFileInfo".equals(node.getRenderHint("type"))) {
                component.setToolTipText("Database File Info");
                String text = "<b>" + (String) node.getUserObject() + "</b>";
                component.setText("<html>" + text + "</html>");
                setIcon(fieldDatabaseIcon);
            } else if (node.getUserObject() instanceof String && "ModelName".equals(node.getRenderHint("type"))) {
                component.setToolTipText("BioModel Name");
                String text = "<b>" + (String) node.getUserObject() + "</b>";
                component.setText("<html>" + text + "</html>");
            // setIcon(fieldTextIcon);
            } else if (node.getUserObject() instanceof KeyValue && "VCellIdentifier".equals(node.getRenderHint("type"))) {
                component.setToolTipText("Virtual Cell Identifier");
                KeyValue key = (KeyValue) node.getUserObject();
                String text = "mathmodel-" + key;
                component.setText("<html>" + text + "</html>");
                setIcon(fieldDatabaseModelKeyIcon);
            } else if (node.getUserObject() instanceof User && "ModelOwner".equals(node.getRenderHint("type"))) {
                String label = ((User) node.getUserObject()).getName();
                component.setToolTipText("Model Owner");
                component.setText("<html>" + label + "</html>");
                setIcon(fieldUserIcon);
            } else if (node.getUserObject() instanceof Date && "ModelDate".equals(node.getRenderHint("type"))) {
                Date date = (Date) node.getUserObject();
                component.setToolTipText("Last Modified");
                component.setText("<html>" + date + "</html>");
                setIcon(fieldCalendarIcon);
            } else if (node.getUserObject() instanceof String && "Permissions".equals(node.getRenderHint("type"))) {
                component.setToolTipText("Permissions");
                String text = (String) node.getUserObject();
                component.setText("<html>" + text + "</html>");
                setIcon(fieldPermissionsIcon);
            } else if (node.getUserObject() instanceof String && "Annotations".equals(node.getRenderHint("type"))) {
                component.setToolTipText("Text Annotation");
                String text = (String) node.getUserObject();
                component.setText("<html>" + text + "</html>");
                setIcon(VCellIcons.noteIcon);
            } else {
                setComponentProperties(component, node.getUserObject());
            }
            if (selectedFont == null && component.getFont() != null) {
                selectedFont = component.getFont().deriveFont(Font.BOLD);
            }
            if (unselectedFont == null && component.getFont() != null) {
                unselectedFont = component.getFont().deriveFont(Font.PLAIN);
            }
            if (bLoaded) {
                component.setFont(selectedFont);
            } else {
                component.setFont(unselectedFont);
            }
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    // 
    return component;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) PublicationInfo(org.vcell.util.document.PublicationInfo) JLabel(javax.swing.JLabel) Date(java.util.Date)

Example 27 with User

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

the class VCDocumentDbTreeModel method initOwners.

protected static synchronized TreeMap<String, BioModelNode> initOwners(VCDocumentInfo[] vcDocumentInfos, User loginUser, VCDocumentDbTreeModel subTreeParent, Method subTreeMethod) {
    // 
    // get list of users (owners)
    // 
    Vector<User> userList = new Vector<User>();
    userList.addElement(loginUser);
    for (int i = 0; i < vcDocumentInfos.length; i++) {
        VCDocumentInfo vcDocumentInfo = vcDocumentInfos[i];
        if (!userList.contains(vcDocumentInfo.getVersion().getOwner())) {
            userList.addElement(vcDocumentInfo.getVersion().getOwner());
        }
    }
    // 
    // for each user
    // 
    TreeMap<String, BioModelNode> treeMap = new TreeMap<String, BioModelNode>(new Comparator<String>() {

        public int compare(String o1, String o2) {
            return o1.compareToIgnoreCase(o2);
        }
    });
    for (int ownerIndex = 0; ownerIndex < userList.size(); ownerIndex++) {
        User owner = (User) userList.elementAt(ownerIndex);
        BioModelNode ownerNode = null;
        try {
            if (vcDocumentInfos instanceof BioModelInfo[]) {
                ownerNode = (BioModelNode) subTreeMethod.invoke(subTreeParent, new Object[] { owner, (BioModelInfo[]) vcDocumentInfos });
            } else if (vcDocumentInfos instanceof MathModelInfo[]) {
                ownerNode = (BioModelNode) subTreeMethod.invoke(subTreeParent, new Object[] { owner, (MathModelInfo[]) vcDocumentInfos });
            } else if (vcDocumentInfos instanceof GeometryInfo[]) {
                ownerNode = (BioModelNode) subTreeMethod.invoke(subTreeParent, new Object[] { owner, (GeometryInfo[]) vcDocumentInfos });
            } else {
                throw new Exception("Unimplemented VCDocumentInfo type=" + vcDocumentInfos.getClass().getName());
            }
        } catch (Exception e) {
            e.printStackTrace();
            ownerNode = new BioModelNode("Error" + e.getMessage());
        }
        if (owner.equals(loginUser) || ownerNode.getChildCount() > 0) {
            treeMap.put(owner.getName(), ownerNode);
        }
    }
    return treeMap;
}
Also used : User(org.vcell.util.document.User) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) TreeMap(java.util.TreeMap) DataAccessException(org.vcell.util.DataAccessException) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) Vector(java.util.Vector)

Example 28 with User

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

the class ImageCellRenderer 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 BioModelNode) {
            BioModelNode node = (BioModelNode) value;
            if (node.getUserObject() instanceof User && node.getChildCount() > 0 && (((BioModelNode) node.getChildAt(0)).getUserObject() instanceof String) && ((BioModelNode) (node.getChildAt(0).getChildAt(0))).getUserObject() instanceof cbit.image.VCImageInfo) {
                // 
                // Check if node is a User, with at least one child which is a string (Image name)
                // and if the child's child is a VCImageInfo node
                // 
                String label = null;
                if (sessionUser != null && sessionUser.compareEqual((User) node.getUserObject())) {
                    label = "My Images (" + ((User) node.getUserObject()).getName() + ")";
                } else {
                    label = ((User) node.getUserObject()).getName() + "                        ";
                }
                component.setToolTipText("User Name");
                component.setText(label);
            }
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    // 
    return component;
}
Also used : User(org.vcell.util.document.User) JLabel(javax.swing.JLabel)

Example 29 with User

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

the class GeometryTreePanel method actionsOnClick.

/**
 * Comment
 */
protected void actionsOnClick(MouseEvent mouseEvent) {
    if (mouseEvent.isPopupTrigger()) {
        if (!getPopupMenuDisabled()) {
            TreePath treePath = ((JTree) mouseEvent.getSource()).getPathForLocation(mouseEvent.getX(), mouseEvent.getY());
            ((JTree) mouseEvent.getSource()).setSelectionPath(treePath);
            if (getSelectedVersionInfo() instanceof GeometryInfo) {
                Version version = getSelectedVersionInfo().getVersion();
                boolean isOwner = version.getOwner().compareEqual(getDocumentManager().getUser());
                getJMenuItemPermission().setEnabled(isOwner);
                getJMenuItemDelete().setEnabled(isOwner);
                getJMenuItemGeomRefs().setEnabled(isOwner);
                getGeometryPopupMenu().show(getJTree1(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
            } else if (treePath != null) {
                BioModelNode bioModelNode = (BioModelNode) treePath.getLastPathComponent();
                Object object = bioModelNode.getUserObject();
                if (object instanceof User) {
                    User selectedUser = (User) object;
                    boolean isOwner = selectedUser.compareEqual(getDocumentManager().getUser());
                    if (isOwner) {
                        JPopupMenu jPopupMenu = new JPopupMenu();
                        jPopupMenu.add(getJMenuItemCreateNewGeometry());
                        jPopupMenu.show(getJTree1(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
                    }
                }
            }
        }
    } else {
        ifNeedsDoubleClickEvent(mouseEvent, GeometryInfo.class);
    }
}
Also used : JTree(javax.swing.JTree) User(org.vcell.util.document.User) TreePath(javax.swing.tree.TreePath) Version(org.vcell.util.document.Version) GeometryInfo(cbit.vcell.geometry.GeometryInfo) JPopupMenu(javax.swing.JPopupMenu)

Example 30 with User

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

the class ImageDbTreeModel 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
 */
private BioModelNode createBaseTree() throws DataAccessException {
    VCImageInfo[] imageInfos = getDocumentManager().getImageInfos();
    BioModelNode rootRootNode = new BioModelNode("Images", true);
    // 
    // get list of users (owners)
    // 
    Vector<User> ownerList = new Vector<User>();
    ownerList.addElement(getDocumentManager().getUser());
    for (int i = 0; i < imageInfos.length; i++) {
        VCImageInfo imageInfo = imageInfos[i];
        if (!ownerList.contains(imageInfo.getVersion().getOwner())) {
            ownerList.addElement(imageInfo.getVersion().getOwner());
        }
    }
    // 
    // for each user
    // 
    TreeMap<String, BioModelNode> treeMap = new TreeMap<String, BioModelNode>();
    for (int ownerIndex = 0; ownerIndex < ownerList.size(); ownerIndex++) {
        User owner = (User) ownerList.elementAt(ownerIndex);
        BioModelNode ownerNode = createOwnerSubTree(owner);
        if (owner.equals(getDocumentManager().getUser()) || ownerNode.getChildCount() > 0) {
            treeMap.put(owner.getName().toLowerCase(), ownerNode);
        }
    }
    // 
    rootRootNode.add((BioModelNode) treeMap.remove(getDocumentManager().getUser().getName().toLowerCase()));
    BioModelNode otherUsersNode = new BioModelNode("Images Neighborhood", true);
    rootRootNode.add(otherUsersNode);
    Object[] bmnArr = treeMap.values().toArray();
    for (int i = 0; i < bmnArr.length; i += 1) {
        otherUsersNode.add((BioModelNode) bmnArr[i]);
    }
    return rootRootNode;
}
Also used : User(org.vcell.util.document.User) TreeMap(java.util.TreeMap) Vector(java.util.Vector) VCImageInfo(cbit.image.VCImageInfo)

Aggregations

User (org.vcell.util.document.User)192 KeyValue (org.vcell.util.document.KeyValue)89 DataAccessException (org.vcell.util.DataAccessException)60 SQLException (java.sql.SQLException)39 VCellApiApplication (org.vcell.rest.VCellApiApplication)34 File (java.io.File)32 ArrayList (java.util.ArrayList)28 BioModel (cbit.vcell.biomodel.BioModel)27 BigString (org.vcell.util.BigString)27 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)26 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)26 ResultSet (java.sql.ResultSet)21 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)20 Simulation (cbit.vcell.solver.Simulation)19 XMLSource (cbit.vcell.xml.XMLSource)18 XmlParseException (cbit.vcell.xml.XmlParseException)18 BioModelInfo (org.vcell.util.document.BioModelInfo)16 SimulationContext (cbit.vcell.mapping.SimulationContext)15 BigDecimal (java.math.BigDecimal)15 Date (java.util.Date)15