Tri-State CheckBox in a TreeTable

After some frustration, I finally was able to get the CheckBoxes in my TreeTable working as I expected them to. Now I want to take it a step further and use a Tri-State CheckBox in the TreeTable.

I’m attempting to combine two things:

  1. Regular old TreeTable with CheckBoxes in the hierarchical column, as I
    posted about earlier
    .
  2. CheckBoxes with a third state, commonly known as “indeterminate”, as seen in the

    Vaadin 7 Cookbook

    .

The idea is to have a branch’s checkbox display the “indeterminate” state when only
some
of its leaves are checked. You may have even seen this behavior in other TreeTables with CheckBoxes out there in the world. Obviously, of course, if
all
of the leaves are checked, then so is the branch. And if
none
of the leaves are checked, then neither should the branch. The branch will not show the indeterminate state in these two cases, nor will the leaves ever show the indeterminate state. Also, the indeterminate state is really just for show—to indicate to the user that only some of the leaves in the branch are checked; the
real
state of that branch’s checkbox is un-checked, or false.

Now, the Tri-State checkbox as implemented in the
Vaadin 7 Cookbook
(and subsequently
modified slightly, as shown by @JarnoRantala, for use with the Valo theme
) works fine as a standalone component in the layout. However, when I attempt to integrate it into my TreeTable in place of the regular CheckBoxes, I only see the checkbox itself without a caption. The indeterminate state is also not shown, despite an attempt to explicitly set them as such to test it. My educated guess is that the TreeTable is having difficulty with this custom widget, not knowing how to properly display it, its caption, and its indeterminate state. So how can I make the TreeTable understand this custom widget and display it properly?