use of org.vcell.util.document.BioModelInfo 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) {
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.BioModelInfo in project vcell by virtualcell.
the class BioModelDbTreeModel method databaseDelete.
/**
* @param event cbit.vcell.clientdb.DatabaseEvent
*/
public void databaseDelete(DatabaseEvent databaseEvent) {
if (databaseEvent.getOldVersionInfo() instanceof BioModelInfo) {
BioModelInfo removedBioModelInfo = (BioModelInfo) databaseEvent.getOldVersionInfo();
BioModelNode removedNode = ((BioModelNode) getRoot()).findNodeByUserObject(removedBioModelInfo);
if (removedNode != null) {
if (removedNode.getParent() != null && removedNode.getSiblingCount() == 1) {
// just this one version
removedNode = (BioModelNode) removedNode.getParent();
}
removeNodeFromParent(removedNode);
}
}
}
use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.
the class BioModelDbTreePanel method documentManager_DatabaseDelete.
/**
* Comment
*/
protected void documentManager_DatabaseDelete(DatabaseEvent event) {
if (event.getOldVersionInfo() instanceof BioModelInfo && getSelectedVersionInfo() instanceof BioModelInfo) {
BioModelInfo selectedBMInfo = (BioModelInfo) getSelectedVersionInfo();
BioModelInfo eventBMInfo = (BioModelInfo) event.getOldVersionInfo();
if (eventBMInfo.getVersion().getVersionKey().equals(selectedBMInfo.getVersion().getVersionKey())) {
setSelectedVersionInfo(null);
getJTree1().getSelectionModel().clearSelection();
}
}
}
use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.
the class BioModelDbTreePanel 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 BioModelInfo) {
Version version = getSelectedVersionInfo().getVersion();
boolean isOwner = version.getOwner().compareEqual(getDocumentManager().getUser());
configureArhivePublishMenuState(version, isOwner);
getJMenuItemPermission().setEnabled(isOwner && !version.getFlag().compareEqual(VersionFlag.Published));
getJMenuItemDelete().setEnabled(isOwner && !version.getFlag().compareEqual(VersionFlag.Archived) && !version.getFlag().compareEqual(VersionFlag.Published));
compareWithMenuItemEnable(getSelectedVersionInfo());
getBioModelPopupMenu().show(getJTree1(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
}
}
} else {
ifNeedsDoubleClickEvent(mouseEvent, BioModelInfo.class);
}
}
use of org.vcell.util.document.BioModelInfo in project vcell by virtualcell.
the class BioModelDbTreePanel method compareWithMenuItemEnable.
/**
* Comment
*/
private void compareWithMenuItemEnable(VersionInfo vInfo) {
boolean bPreviousEditionMenuItem = false;
boolean bLatestEditionMenuItem = false;
boolean bAnotherEditionMenuItem = false;
BioModelInfo thisBioModelInfo = (BioModelInfo) vInfo;
//
try {
BioModelInfo[] bioModelVersionsList = getBioModelVersionDates(thisBioModelInfo);
if (bioModelVersionsList != null && bioModelVersionsList.length > 0) {
bAnotherEditionMenuItem = true;
//
// Obtaining the previous version of the current biomodel.
//
BioModelInfo previousBioModelInfo = bioModelVersionsList[0];
boolean bPrevious = false;
for (int i = 0; i < bioModelVersionsList.length; i++) {
if (bioModelVersionsList[i].getVersion().getDate().before(thisBioModelInfo.getVersion().getDate())) {
bPrevious = true;
previousBioModelInfo = bioModelVersionsList[i];
} else {
break;
}
}
if (previousBioModelInfo.equals(bioModelVersionsList[0]) && !bPrevious) {
bPreviousEditionMenuItem = false;
} else {
bPreviousEditionMenuItem = true;
}
//
// Obtaining the latest version of the current biomodel
//
BioModelInfo latestBioModelInfo = bioModelVersionsList[bioModelVersionsList.length - 1];
for (int i = 0; i < bioModelVersionsList.length; i++) {
if (bioModelVersionsList[i].getVersion().getDate().after(latestBioModelInfo.getVersion().getDate())) {
latestBioModelInfo = bioModelVersionsList[i];
}
}
if (thisBioModelInfo.getVersion().getDate().after(latestBioModelInfo.getVersion().getDate())) {
bLatestEditionMenuItem = false;
} else {
bLatestEditionMenuItem = true;
}
}
} catch (DataAccessException e) {
e.printStackTrace();
}
getJPreviousEditionMenuItem().setEnabled(bPreviousEditionMenuItem);
getLatestEditionMenuItem().setEnabled(bLatestEditionMenuItem);
getAnotherEditionMenuItem().setEnabled(bAnotherEditionMenuItem);
}
Aggregations