if (actionCommand.equals("Expand")) {
if (tree.getLastSelectedPathComponent() != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
if (node.getUserObject() instanceof ObjectInfo) {
ObjectInfo oj = (ObjectInfo)node.getUserObject();
if ( (oj.flag.equals("object")) || (oj.flag.equals("favorites")) || (oj.flag.equals("book")) || (oj.flag.equals("bookSettings")) )
tree.expandPath(tree.getSelectionPath());
else if (oj.flag.equals("layout")) {
tree.expandPath(tree.getSelectionPath().getParentPath());
}
}
}
} else if (actionCommand.equals("Collapse")) {
if (tree.getLastSelectedPathComponent() != null) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
if (node.getUserObject() instanceof ObjectInfo) {
ObjectInfo oj = (ObjectInfo)node.getUserObject();
if ( (oj.flag.equals("object")) || (oj.flag.equals("favorites")) || (oj.flag.equals("book")) || (oj.flag.equals("bookSettings")) )
tree.collapsePath(tree.getSelectionPath());
else if (oj.flag.equals("layout"))
tree.collapsePath(tree.getSelectionPath().getParentPath());
}