code: public void setCollapsed(boolean collapsed) {
          if (collapsed) {
              removeAttribute("data-collapsed");
              if (isInstance(getElement())) collapse();
          } else {
              setAttribute("data-collapsed", "false");
              if (isInstance(getElement())) expand();
          }
      }
docs: Programmatically set the collapsed state of this widget.