Example usage for javax.swing.tree DefaultMutableTreeNode clone

List of usage examples for javax.swing.tree DefaultMutableTreeNode clone

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode clone.

Prototype

public Object clone() 

Source Link

Document

Overridden to make clone public.

Usage

From source file:gov.nij.er.ui.RawDataFilteredTreeModel.java

/**
 * Determine which recordIds are filtered (displayed)
 * @param recordIds the list of ids for the records to display
 *///from w  w  w . j  av a  2 s.com
public void setFilteredRecordIds(Set<String> recordIds) {
    root = new DefaultMutableTreeNode(ROOT_NODE_LABEL);
    List<DefaultMutableTreeNode> nodes = rawDataTreeModel.getNodesForRecordIds(recordIds);
    for (DefaultMutableTreeNode node : nodes) {
        LOG.debug("Adding node " + node);
        root.add((MutableTreeNode) node.clone());

    }
    updateModel();
}

From source file:org.codinjutsu.tools.nosql.redis.view.RedisFragmentedKeyTreeModel.java

private void updateFilteredModel() {
    DefaultMutableTreeNode sourceRoot = (DefaultMutableTreeNode) super.getRoot();
    DefaultMutableTreeNode targetRoot = (DefaultMutableTreeNode) sourceRoot.clone();
    wrapNodes(sourceRoot, separator);/*from   ww  w. j  av a2 s. co m*/
    fragmentedKeyModel = new DefaultTreeModel(targetRoot);
    Object[] listeners = listenerList.getListenerList();
    for (int i = listeners.length - 2; i >= 0; i -= 2) {
        if (listeners[i] == TreeModelListener.class) {
            fragmentedKeyModel.addTreeModelListener((TreeModelListener) listeners[i + 1]);
        }
    }
    fireSeparatorChanged();
}

From source file:org.codinjutsu.tools.nosql.redis.view.RedisFragmentedKeyTreeModel.java

public static DefaultMutableTreeNode wrapNodes(DefaultMutableTreeNode source, String separator) {
    if (isEmpty(separator)) {
        return source;
    }/*  www  . ja v  a2  s.c o  m*/
    DefaultMutableTreeNode targetRootNode = (DefaultMutableTreeNode) source.clone();
    for (int i = 0; i < source.getChildCount(); i++) {
        DefaultMutableTreeNode originalChildNode = (DefaultMutableTreeNode) source.getChildAt(i);
        NoSqlTreeNode clonedChildNode = (NoSqlTreeNode) originalChildNode.clone();
        RedisKeyValueDescriptor descriptor = (RedisKeyValueDescriptor) clonedChildNode.getDescriptor();
        String[] explodedKey = StringUtils.explode(descriptor.getKey(), separator);
        if (explodedKey.length == 1) {
            addChildren(clonedChildNode, originalChildNode);
            targetRootNode.add(clonedChildNode);
        } else {
            updateTree(targetRootNode, originalChildNode, explodedKey, descriptor);
        }
    }
    return targetRootNode;
}

From source file:org.codinjutsu.tools.nosql.redis.view.RedisFragmentedKeyTreeModel.java

private static void addChildren(DefaultMutableTreeNode parentNode, DefaultMutableTreeNode originalChildNode) {
    Enumeration children = originalChildNode.children();
    while (children.hasMoreElements()) {
        DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement();
        parentNode.add((MutableTreeNode) childNode.clone());
    }//from www  . j av  a  2s. co m
}