use of org.vcell.util.document.Version in project vcell by virtualcell.
the class VersionInfoComparator method compare.
/**
* Compares its two arguments for order. Returns a negative integer,
* zero, or a positive integer as the first argument is less than, equal
* to, or greater than the second.<p>
*
* The implementor must ensure that <tt>sgn(compare(x, y)) ==
* -sgn(compare(y, x))</tt> for all <tt>x</tt> and <tt>y</tt>. (This
* implies that <tt>compare(x, y)</tt> must throw an exception if and only
* if <tt>compare(y, x)</tt> throws an exception.)<p>
*
* The implementor must also ensure that the relation is transitive:
* <tt>((compare(x, y)>0) && (compare(y, z)>0))</tt> implies
* <tt>compare(x, z)>0</tt>.<p>
*
* Finally, the implementer must ensure that <tt>compare(x, y)==0</tt>
* implies that <tt>sgn(compare(x, z))==sgn(compare(y, z))</tt> for all
* <tt>z</tt>.<p>
*
* It is generally the case, but <i>not</i> strictly required that
* <tt>(compare(x, y)==0) == (x.equals(y))</tt>. Generally speaking,
* any comparator that violates this condition should clearly indicate
* this fact. The recommended language is "Note: this comparator
* imposes orderings that are inconsistent with equals."
*
* @return a negative integer, zero, or a positive integer as the
* first argument is less than, equal to, or greater than the
* second.
* @throws ClassCastException if the arguments' types prevent them from
* being compared by this Comparator.
*/
public int compare(VersionInfo v1, VersionInfo v2) {
//
// first, compare by names
//
Version version1 = v1.getVersion();
Version version2 = v2.getVersion();
int result = version1.getName().compareToIgnoreCase(version2.getName());
if (result != 0) {
return result;
}
// second, compare by branchID
result = version1.getBranchID().compareTo(version2.getBranchID());
if (result != 0) {
return result;
}
// third, compare by date
return version1.getDate().compareTo(version2.getDate());
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class TestCriteriaNewBioModel method describe.
@Override
public String describe() {
StringBuilder sb = new StringBuilder();
if (regrBioModelInfo != null) {
Version v = regrBioModelInfo.getVersion();
if (v != null) {
sb.append(v.getName());
sb.append(' ');
} else {
sb.append("unversioned ");
}
} else {
sb.append("no model info");
}
SimulationInfo si = getSimInfo();
if (si != null) {
sb.append(si.getName());
} else {
sb.append("no simulation");
}
return sb.toString();
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class MathModelDbTreePanel 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 MathModelInfo) {
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());
getMathModelPopupMenu().show(getJTree1(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
}
}
} else {
ifNeedsDoubleClickEvent(mouseEvent, MathModelInfo.class);
}
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class VCDocumentDbTreeModel method initFinalTree.
protected static synchronized void initFinalTree(VCDocumentDbTreeModel vcDocumentDbTreeModel, TreeMap<String, BioModelNode> treeMap, User loginUser) {
BioModelNode ownerNode = (BioModelNode) treeMap.remove(loginUser.getName());
vcDocumentDbTreeModel.myModelsNode.setUserObject(loginUser);
vcDocumentDbTreeModel.myModelsNode.removeAllChildren();
for (int c = 0; c < ownerNode.getChildCount(); ) {
BioModelNode childNode = (BioModelNode) ownerNode.getChildAt(c);
vcDocumentDbTreeModel.myModelsNode.add(childNode);
}
vcDocumentDbTreeModel.sharedModelsNode.removeAllChildren();
vcDocumentDbTreeModel.publicModelsNode.removeAllChildren();
boolean bTutorial = vcDocumentDbTreeModel.tutorialModelsNode != null;
boolean bEducation = vcDocumentDbTreeModel.educationModelsNode != null;
if (bTutorial) {
vcDocumentDbTreeModel.tutorialModelsNode.removeAllChildren();
}
if (bEducation) {
vcDocumentDbTreeModel.educationModelsNode.removeAllChildren();
}
for (String username : treeMap.keySet()) {
BioModelNode userNode = treeMap.get(username);
BioModelNode parentNode = vcDocumentDbTreeModel.sharedModelsNode;
boolean bSpecificUser = true;
if ((username.equals(USER_tutorial) || username.equals(USER_tutorial610) || username.equals(USER_tutorial611)) && bTutorial) {
parentNode = vcDocumentDbTreeModel.tutorialModelsNode;
} else if (username.equals(USER_Education) && bEducation) {
parentNode = vcDocumentDbTreeModel.educationModelsNode;
} else {
bSpecificUser = false;
}
for (int c = 0; c < userNode.getChildCount(); ) {
BioModelNode childNode = (BioModelNode) userNode.getChildAt(c);
VCDocumentInfoNode vcdDocumentInfoNode = (VCDocumentInfoNode) childNode.getUserObject();
if (!bSpecificUser) {
parentNode = vcDocumentDbTreeModel.sharedModelsNode;
BigDecimal groupid = GroupAccess.GROUPACCESS_NONE;
Version version = vcdDocumentInfoNode.getVCDocumentInfo().getVersion();
if (version != null && version.getGroupAccess() != null) {
groupid = version.getGroupAccess().getGroupid();
}
if (groupid.equals(GroupAccess.GROUPACCESS_ALL)) {
parentNode = vcDocumentDbTreeModel.publicModelsNode;
}
}
// when added to other node, this childNode was removed from userNode
parentNode.add(childNode);
}
}
}
use of org.vcell.util.document.Version in project vcell by virtualcell.
the class VCellBasicCellRenderer method setComponentProperties.
/**
* Insert the method's description here.
* Creation date: (5/8/01 8:35:45 AM)
* @return javax.swing.Icon
* @param nodeUserObject java.lang.Object
*/
protected void setComponentProperties(JLabel component, MathModelInfo mathModelInfo) {
component.setIcon(fieldMathModelIcon);
Version version = mathModelInfo.getVersion();
component.setToolTipText("MathModel (" + mathModelInfo.getSoftwareVersion().getDescription() + ")");
String access = (version.getGroupAccess().getDescription());
component.setText(access + " " + version.getDate().toString());
}
Aggregations