      /**
       * The constants used in this Content Widget.
       */
      public static interface CwConstants extends Constants,
          ContentWidget.CwConstants {
        String cwTreeDescription();

        String cwTreeDynamicLabel();

        String cwTreeItem();

        String cwTreeName();

        String cwTreeStaticLabel();
      }

      /**
       * An instance of the constants.
       */
      private CwConstants constants;

      /**
       * Initialize this example.
       */
      @Override
      public Widget onInitialize() {
        // Create a static tree and a container to hold it
        Tree staticTree = createStaticTree();
        staticTree.setAnimationEnabled(true);
        staticTree.ensureDebugId("cwTree-staticTree");
        ScrollPanel staticTreeWrapper = new ScrollPanel(staticTree);
        staticTreeWrapper.ensureDebugId("cwTree-staticTree-Wrapper");
        staticTreeWrapper.setSize("300px", "300px");

        // Wrap the static tree in a DecoratorPanel
        DecoratorPanel staticDecorator = new DecoratorPanel();
        staticDecorator.setWidget(staticTreeWrapper);

        // Create a dynamically generated tree and a container to hold it
        final Tree dynamicTree = createDynamicTree();
        dynamicTree.ensureDebugId("cwTree-dynamicTree");
        ScrollPanel dynamicTreeWrapper = new ScrollPanel(dynamicTree);
        dynamicTreeWrapper.ensureDebugId("cwTree-dynamicTree-Wrapper");
        dynamicTreeWrapper.setSize("300px", "300px");

        // Wrap the dynamic tree in a DecoratorPanel
        DecoratorPanel dynamicDecorator = new DecoratorPanel();
        dynamicDecorator.setWidget(dynamicTreeWrapper);

        // Combine trees onto the page
        Grid grid = new Grid(2, 3);
        grid.setCellPadding(2);
        grid.getRowFormatter().setVerticalAlign(1, HasVerticalAlignment.ALIGN_TOP);
        grid.setHTML(0, 0, constants.cwTreeStaticLabel());
        grid.setHTML(0, 1, "   ");
        grid.setHTML(0, 2, constants.cwTreeDynamicLabel());
        grid.setWidget(1, 0, staticDecorator);
        grid.setHTML(1, 1, "   ");
        grid.setWidget(1, 2, dynamicDecorator);

        // Wrap the trees in DecoratorPanels
        return grid;
      }

      /**
       * Create a dynamic tree that will add a random number of children to each
       * node as it is clicked.
       *
       * @return the new tree
       */
      private Tree createDynamicTree() {
        // Create a new tree
        Tree dynamicTree = new Tree();

        // Add some default tree items
        for (int i = 0; i < 5; i++) {
          TreeItem item = dynamicTree.addItem(constants.cwTreeItem() + " " + i);

          // Temporarily add an item so we can expand this node
          item.addItem("");
        }

        // Add a listener that automatically generates some children
        dynamicTree.addTreeListener(new TreeListener() {
          public void onTreeItemSelected(TreeItem item) {
          }

          public void onTreeItemStateChanged(TreeItem item) {
            if (item.getState() && item.getChildCount() == 1) {
              // Close the item immediately
              item.setState(false, false);

              // Add a random number of children to the item
              String itemText = item.getText();
              int numChildren = Random.nextInt(5) + 2;
              for (int i = 0; i < numChildren; i++) {
                TreeItem child = item.addItem(itemText + "." + i);
                child.addItem("");
              }

              // Remove the temporary item when we finish loading
              item.getChild(0).remove();

              // Reopen the item
              item.setState(true, false);
            }
          }
        });

        // Return the tree
        return dynamicTree;
      }

      /**
       * Create a static tree with some data in it.
       *
       * @return the new tree
       */
      private Tree createStaticTree() {
        // Create the tree
        Tree staticTree = new Tree();

        // Add some of Beethoven's music
        TreeItem c1 = staticTree.addItem("Beethoven");
        TreeItem c1g1 = c1.addItem("Concertos");
        c1g1.addItem("No. 1 - C");
        c1g1.addItem("No. 2 - B-Flat Major");
        c1g1.addItem("No. 3 - C Minor");
        c1g1.addItem("No. 4 - G Major");
        c1g1.addItem("No. 5 - E-Flat Major");
        TreeItem c1g2 = c1.addItem("Quartets");
        c1g2.addItem("Six String Quartets");
        c1g2.addItem("Three String Quartets");
        c1g2.addItem("Grosse Fugue for String Quartets");
        TreeItem c1g3 = c1.addItem("Sonatas");
        c1g3.addItem("Sonata in A Minor");
        c1g3.addItem("Sonata in F Major");
        TreeItem c1g4 = c1.addItem("Symphonies");
        c1g4.addItem("No. 2 - D Major");
        c1g4.addItem("No. 2 - D Major");
        c1g4.addItem("No. 3 - E-Flat Major");
        c1g4.addItem("No. 4 - B-Flat Major");
        c1g4.addItem("No. 5 - C Minor");
        c1g4.addItem("No. 6 - F Major");
        c1g4.addItem("No. 7 - A Major");
        c1g4.addItem("No. 8 - F Major");
        c1g4.addItem("No. 9 - D Minor");

        // Add some of Brahms's music
        TreeItem c2 = staticTree.addItem("Brahms");
        TreeItem c2g1 = c2.addItem("Concertos");
        c2g1.addItem("Violin Concerto");
        c2g1.addItem("Double Concerto - A Minor");
        c2g1.addItem("Piano Concerto No. 1 - D Minor");
        c2g1.addItem("Piano Concerto No. 2 - B-Flat Major");
        TreeItem c2g2 = c2.addItem("Quartets");
        c2g2.addItem("Piano Quartet No. 1 - G Minor");
        c2g2.addItem("Piano Quartet No. 2 - A Major");
        c2g2.addItem("Piano Quartet No. 3 - C Minor");
        c2g2.addItem("String Quartet No. 3 - B-Flat Minor");
        TreeItem c2g3 = c2.addItem("Sonatas");
        c2g3.addItem("Two Sonatas for Clarinet - F Minor");
        c2g3.addItem("Two Sonatas for Clarinet - E-Flat Major");
        TreeItem c2g4 = c2.addItem("Symphonies");
        c2g4.addItem("No. 1 - C Minor");
        c2g4.addItem("No. 2 - D Minor");
        c2g4.addItem("No. 3 - F Major");
        c2g4.addItem("No. 4 - E Minor");

        // Add some of Mozart's music
        TreeItem c3 = staticTree.addItem("Mozart");
        TreeItem c3g1 = c3.addItem("Concertos");
        c3g1.addItem("Piano Concerto No. 12");
        c3g1.addItem("Piano Concerto No. 17");
        c3g1.addItem("Clarinet Concerto");
        c3g1.addItem("Violin Concerto No. 5");
        c3g1.addItem("Violin Concerto No. 4");

        // Return the tree
        return staticTree;
      }