@Override
public void open(Display display, Window owner) {
super.open(display, owner);
Path initialSelectedPath = null;
Path firstComponentPath = null;
Tree.ItemIterator<?> itemIterator = Tree.depthFirstIterator(treeView.getTreeData());
while (itemIterator.hasNext()) {
Object node = itemIterator.next();
if (node instanceof ComponentNode) {
ComponentNode componentNode = (ComponentNode)node;
Path path = itemIterator.getPath();
if (firstComponentPath == null) {
firstComponentPath = path;
}
if (classProperty != null) {
// class property was set; open the corresponding
// component node
if (componentNode.getText().equals(classProperty)) {
splitPane.setSplitRatio(0);
splitPane.setLocked(true);
initialSelectedPath = path;
break;
}
} else {
// class property was *not* set; open the first component
// node we find
initialSelectedPath = path;
break;
}
}
}
// Default the initial selected path to the first component
if (initialSelectedPath == null) {
initialSelectedPath = firstComponentPath;
}
if (initialSelectedPath != null) {
// Select the path
treeView.setSelectedPath(initialSelectedPath);
// Ensure that it's visible to the user
Path branchPath = new Path(initialSelectedPath, initialSelectedPath.getLength() - 1);
while (branchPath.getLength() > 0) {
treeView.expandBranch(branchPath);
branchPath.remove(branchPath.getLength() - 1, 1);
}
final Path path = initialSelectedPath;
ApplicationContext.queueCallback(new Runnable() {
@Override
public void run() {
treeView.scrollAreaToVisible(treeView.getNodeBounds(path));
}