use of cbit.xml.merge.NodeInfo in project vcell by virtualcell.
the class MyRenderer method getTreeCellRendererComponent.
/**
* This method modifies the way the nodes are represented upon their status and type.
* 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 (value instanceof NodeInfo) {
NodeInfo nodeInfo = (NodeInfo) value;
// Check the kind of node to decide which icon to use
if (nodeInfo.isAttribute()) {
switch(nodeInfo.getStatus()) {
case NodeInfo.STATUS_NORMAL:
component.setIcon(this.fieldAttributeIcon);
setToolTipText(null);
break;
case NodeInfo.STATUS_NEW:
component.setIcon(this.fieldNewAttributeIcon);
component.setForeground(java.awt.Color.blue);
setToolTipText("New " + nodeInfo.getName());
break;
case NodeInfo.STATUS_REMOVED:
component.setIcon(this.fieldRemovedAttributeIcon);
component.setForeground(java.awt.Color.red);
setToolTipText("Removed " + nodeInfo.getName());
break;
case NodeInfo.STATUS_CHANGED:
component.setIcon(this.fieldChangedAttributeIcon);
component.setForeground(java.awt.Color.gray);
setToolTipText("Altered " + nodeInfo.getName());
break;
default:
component.setIcon(this.fieldBadAttributeIcon);
setToolTipText(null);
}
} else {
// is an element
switch(nodeInfo.getStatus()) {
case NodeInfo.STATUS_NORMAL:
component.setIcon(this.fieldFolderIcon);
setToolTipText(null);
break;
case NodeInfo.STATUS_NEW:
component.setIcon(this.fieldNewFolderIcon);
component.setForeground(java.awt.Color.blue);
setToolTipText("New " + nodeInfo.getName());
break;
case NodeInfo.STATUS_REMOVED:
component.setIcon(this.fieldRemovedFolderIcon);
component.setForeground(java.awt.Color.red);
setToolTipText("Removed " + nodeInfo.getName());
break;
case NodeInfo.STATUS_CHANGED:
component.setIcon(this.fieldChangedFolderIcon);
component.setForeground(java.awt.Color.gray);
setToolTipText("Altered " + nodeInfo.getName());
break;
default:
component.setIcon(this.fieldBadFolderIcon);
setToolTipText(null);
}
}
}
return component;
}
use of cbit.xml.merge.NodeInfo in project vcell by virtualcell.
the class TMLPanel method extract.
/**
* This method extracts from the given NodeInfo node, the nodes with the given status.
* Creation date: (9/12/2001 4:40:12 PM)
* @return cbit.xml.merge.NodeInfo
* @param originalNode cbit.xml.merge.NodeInfo
* @param status int
*/
private NodeInfo extract(NodeInfo original, int status) {
NodeInfo newNode = null;
if ((original.getName().equals(XMLTags.VersionTag) || original.getName().equals(XMLTags.KeyValueAttrTag)) && fieldDiffTree.isIgnoringVersionInfo()) {
if (status == NodeInfo.STATUS_REMOVED) {
// i.e. represents the baseline
status = NodeInfo.STATUS_NORMAL;
newNode = new NodeInfo(original.getName(), original.getValue(), status, original.isAttribute());
} else if (status == NodeInfo.STATUS_NEW) {
// i.e. represents the modified
// ignore version info for the modified
newNode = null;
}
} else {
// process himself
if (original.getStatus() == NodeInfo.STATUS_CHANGED) {
// create the copy
if (status == NodeInfo.STATUS_REMOVED) {
newNode = new NodeInfo(original.getName(), original.getValue(), status, original.isAttribute());
} else {
if (status == NodeInfo.STATUS_NEW) {
newNode = new NodeInfo(original.getName(), ((ChangedNodeInfo) original).getModified(), status, original.isAttribute());
} else {
throw new IllegalArgumentException("Invalid option: " + status);
}
}
} else {
if (original.getStatus() == status || original.getStatus() == NodeInfo.STATUS_NORMAL || original.getStatus() == NodeInfo.STATUS_PROBLEM) {
newNode = new NodeInfo(original.getName(), original.getValue(), status, original.isAttribute());
}
}
}
// Now process its children
if (newNode != null) {
Enumeration enum1 = original.children();
// copy children
while (enum1.hasMoreElements()) {
NodeInfo temp = extract((NodeInfo) enum1.nextElement(), status);
if (temp != null) {
newNode.add(temp);
}
}
}
return newNode;
}
use of cbit.xml.merge.NodeInfo in project vcell by virtualcell.
the class TMLPanel method setNodeInfo.
/**
* Sets the nodeInfo property (cbit.xml.merge.NodeInfo) value.
* @param nodeInfo The new value for the property.
* @see #getNodeInfo
*/
private void setNodeInfo(NodeInfo nodeInfo) {
NodeInfo oldValue = fieldNodeInfo;
fieldNodeInfo = nodeInfo;
getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
if (nodeInfo != null) {
getTree().setModel(new DefaultTreeModel(getNodeInfo(), false));
} else {
getTree().setModel(null);
}
firePropertyChange("nodeInfo", oldValue, nodeInfo);
}
use of cbit.xml.merge.NodeInfo in project vcell by virtualcell.
the class TMLPanel method keepModified.
/**
* This method processes the subnodes of the given Node so that it keeps the Modified remaining nodes.
* Creation date: (9/11/2001 4:55:11 PM)
* @param object java.lang.Object
*/
private void keepModified(Object object) {
if (object instanceof NodeInfo) {
NodeInfo currentNode = (NodeInfo) object;
if (currentNode.getStatus() != NodeInfo.STATUS_REMOVED) {
// process himself
currentNode.setStatus(NodeInfo.STATUS_NORMAL);
if (currentNode instanceof ChangedNodeInfo) {
String temp = ((ChangedNodeInfo) currentNode).getValue();
((ChangedNodeInfo) currentNode).setValue(((ChangedNodeInfo) currentNode).getModified());
((ChangedNodeInfo) currentNode).setModified(temp);
}
((javax.swing.tree.DefaultTreeModel) (getTree().getModel())).nodeChanged(currentNode);
// process its subnodes
LinkedList subNodes = new LinkedList();
for (Enumeration enumNodes = currentNode.children(); enumNodes.hasMoreElements(); ) {
subNodes.add(enumNodes.nextElement());
}
Iterator iterator = subNodes.iterator();
while (iterator.hasNext()) {
NodeInfo tempNode = (NodeInfo) iterator.next();
keepModified(tempNode);
}
// update parents of the change
updateParents(currentNode.getParent(), currentNode);
} else {
NodeInfo parentNode = currentNode;
// track the farest parent who has as a status of REMOVED
while ((parentNode.getParent() != null) && (((NodeInfo) parentNode.getParent()).getStatus() == NodeInfo.STATUS_REMOVED)) {
parentNode = (NodeInfo) parentNode.getParent();
}
// update parents of the change
updateParents(parentNode, currentNode);
// eliminate that node and its subtree (remove the node of interest, not the parent one).
((DefaultTreeModel) (getTree().getModel())).removeNodeFromParent(currentNode);
}
} else {
throw new IllegalArgumentException("KeepModified found an unknown type of node:" + object.getClass().getName());
}
}
use of cbit.xml.merge.NodeInfo in project vcell by virtualcell.
the class TMLPanel method processComparisonResult.
// process events for loading the model displayed in the comparison panel
public VCDocument processComparisonResult() throws Exception {
try {
NodeInfo root = (NodeInfo) getTree().getModel().getRoot();
// if (!isNormal(root)) {
// displayMessage(this, "Please resolve all tagged elements/attributes before proceeding.");
// }
String xmlStr = root.toXmlString();
// System.out.println(xmlStr);
Element rootElement = (XmlUtil.stringToXML(xmlStr, null)).getRootElement();
// ?
XmlReader reader = new XmlReader(true);
String rootName = rootElement.getName();
Document doc = rootElement.getDocument();
VCDocument vcDoc = null;
if (rootName.equals(XMLTags.BioModelTag)) {
String docSoftwareVersion = rootElement.getAttributeValue(XMLTags.SoftwareVersionAttrTag);
vcDoc = reader.getBioModel(rootElement, (docSoftwareVersion == null ? null : VCellSoftwareVersion.fromString(docSoftwareVersion)));
} else if (rootName.equals(XMLTags.MathModelTag)) {
vcDoc = reader.getMathModel(rootElement);
} else if (rootName.equals(XMLTags.GeometryTag)) {
vcDoc = reader.getGeometry(rootElement);
} else {
throw new Exception("Invalid root for the tree");
}
return vcDoc;
} catch (java.lang.Exception ivjExc) {
handleException(ivjExc);
throw ivjExc;
}
}
Aggregations