Bean class holding a role tree item.
67686970717273747576
*/ private static DefaultTreeModel buildTreeModel(String prefsRoot) { Preferences prefs = Preferences.userRoot().node(prefsRoot.substring(0, prefsRoot.length() - 1)); DefaultMutableTreeNode root = new DefaultMutableTreeNode(new RoleTreeItem(prefs.absolutePath(), prefs.name())); processPreferences(prefs, root); return new DefaultTreeModel(root); }
8990919293949596979899
{ String[] names = prefs.childrenNames(); for (int i = 0; i < names.length; i++) { Preferences childPrefs = prefs.node(names[i]); DefaultMutableTreeNode child = new DefaultMutableTreeNode(new RoleTreeItem(childPrefs.absolutePath(), names[i])); System.out.println("++++++ Rebuilding tree - Adding to tree: " + childPrefs.absolutePath()); parent.insert(child); processPreferences(childPrefs, child); } }
140141142143144145146147148149150151
{ DefaultMutableTreeNode nodeAtDepth = null; while (children.hasNext()) { DefaultMutableTreeNode currNode = (DefaultMutableTreeNode) children.next(); RoleTreeItem currItem = (RoleTreeItem) currNode.getUserObject(); if (currItem.getFullPath().equals(nodePath)) { nodeAtDepth = currNode; break; } }