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;
}
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;
}
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;
}
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);
}
}
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;
}
Aggregations