Search in sources :

Example 1 with ChangedNodeInfo

use of cbit.xml.merge.ChangedNodeInfo 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;
}
Also used : Enumeration(java.util.Enumeration) ChangedNodeInfo(cbit.xml.merge.ChangedNodeInfo) NodeInfo(cbit.xml.merge.NodeInfo) ChangedNodeInfo(cbit.xml.merge.ChangedNodeInfo)

Example 2 with ChangedNodeInfo

use of cbit.xml.merge.ChangedNodeInfo 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());
    }
}
Also used : Enumeration(java.util.Enumeration) ChangedNodeInfo(cbit.xml.merge.ChangedNodeInfo) NodeInfo(cbit.xml.merge.NodeInfo) ChangedNodeInfo(cbit.xml.merge.ChangedNodeInfo) Iterator(java.util.Iterator) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) LinkedList(java.util.LinkedList)

Example 3 with ChangedNodeInfo

use of cbit.xml.merge.ChangedNodeInfo in project vcell by virtualcell.

the class TMLPanel method getCurrentModifiedText.

private String getCurrentModifiedText() {
    Object object = getTree().getLastSelectedPathComponent();
    String modifiedText = "";
    if (object instanceof NodeInfo) {
        NodeInfo node = (NodeInfo) object;
        if (node.getStatus() == NodeInfo.STATUS_CHANGED) {
            modifiedText = ((ChangedNodeInfo) node).getModified() != null ? ((ChangedNodeInfo) node).getModified() : "";
        } else {
            if (node.getStatus() == NodeInfo.STATUS_NEW) {
                modifiedText = node.getValue() != null ? node.getValue() : "";
            }
        }
    }
    return modifiedText;
}
Also used : ChangedNodeInfo(cbit.xml.merge.ChangedNodeInfo) NodeInfo(cbit.xml.merge.NodeInfo) ChangedNodeInfo(cbit.xml.merge.ChangedNodeInfo)

Aggregations

ChangedNodeInfo (cbit.xml.merge.ChangedNodeInfo)3 NodeInfo (cbit.xml.merge.NodeInfo)3 Enumeration (java.util.Enumeration)2 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1