private void populateNavigationTree(List<GalleryTreeNode> nodes, HasTreeItems items) { if (nodes == null) return; for (GalleryTreeNode node: nodes) { TreeItem ti = new TreeItem(); ti.setText(node.getName()); ti.setUserObject(node); ti.getElement().getStyle().setCursor(Style.Cursor.POINTER); items.addItem(ti); populateNavigationTree(node.getChildren(), ti); } }
private static HorizontalPanel findFirstHBox(final HasTreeItems tree) { for (final Widget w : iter(tree)) { if (w instanceof HorizontalPanel) { return (HorizontalPanel) w; } } return null; }
private static Iterable<Widget> iter(final HasTreeItems tree) { if (tree instanceof Tree) { return (Tree) tree; } else if (tree instanceof TreeItem) { return new TreeItemIterator((TreeItem) tree); } else { throw new AssertionError("should never happen! tree is neither a" + " TreeItem nor a Iterable: " + tree); } }
private static void deferredAlign(final HasTreeItems tree) { // We need to align the tree outside of the processing of this event, // otherwise the browser won't have actually computed the layout of the // Tree, and the nested widgets will appear to have a size of 0. // It's kind of ugly because it means the browser does the layout once, // then we "fix" it by aligning widgets, so users can see the layout // flicker a bit after we "fix" it, but I don't know of a better way... Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { public void execute() { AlignedTree.align(tree); } }); }
public static void align(final HasTreeItems tree) { align(tree, DEFAULT_SPACING); }