S
soup_or_power
I am trying to XML'fy the path info. The XML looks good. But am not
able to recreate the path. Can someone please help?
Enumeration expanded = getExpansionState(treeTable.getTree());
if (expanded != null) {
while (expanded.hasMoreElements()) {
TreePath treePath = (TreePath) expanded.nextElement();
String strarr = treePath.toString();
StringBuffer sb = new StringBuffer();
for (int i=0; i < strarr.length() ; i++)
{
char c=strarr.charAt(i);
if (c != '[' && c != ']') sb.append(c);
}
StringTokenizer st = new StringTokenizer(sb.toString(),
",");
while(st != null && st.hasMoreTokens()) {
ttsDefaults.addPathList(st.nextToken());
//tree.expandPath(treePath);
}
}
public static Enumeration getExpansionState(JTree tree) {
return tree.getExpandedDescendants(new
TreePath(tree.getModel().getRoot()));
}
//MG
Vector pathList = ttsDefaults.getPathList(); //read from XML
for (Enumeration e = pathList.elements(); e.hasMoreElements()
{
TreeDataObject name = ( TreeDataObject )( e.nextElement());
TreeDataObject root =
(TreeDataObject)treeTableModel.getMainTreeNode();
TreePath path = TreeDataObject.getPathFromRoot(root, name);
System.out.println("TreePath:"+path.toString());
//select the path in the tree
treeTable.getTree().expandPath(path);
}
able to recreate the path. Can someone please help?
Enumeration expanded = getExpansionState(treeTable.getTree());
if (expanded != null) {
while (expanded.hasMoreElements()) {
TreePath treePath = (TreePath) expanded.nextElement();
String strarr = treePath.toString();
StringBuffer sb = new StringBuffer();
for (int i=0; i < strarr.length() ; i++)
{
char c=strarr.charAt(i);
if (c != '[' && c != ']') sb.append(c);
}
StringTokenizer st = new StringTokenizer(sb.toString(),
",");
while(st != null && st.hasMoreTokens()) {
ttsDefaults.addPathList(st.nextToken());
//tree.expandPath(treePath);
}
}
public static Enumeration getExpansionState(JTree tree) {
return tree.getExpandedDescendants(new
TreePath(tree.getModel().getRoot()));
}
//MG
Vector pathList = ttsDefaults.getPathList(); //read from XML
for (Enumeration e = pathList.elements(); e.hasMoreElements()
{
TreeDataObject name = ( TreeDataObject )( e.nextElement());
TreeDataObject root =
(TreeDataObject)treeTableModel.getMainTreeNode();
TreePath path = TreeDataObject.getPathFromRoot(root, name);
System.out.println("TreePath:"+path.toString());
//select the path in the tree
treeTable.getTree().expandPath(path);
}