@Override
  protected void extend(ServerConnector target) {
    panel = (VPanel) ((ComponentConnector) target).getWidget();
    panel.addStyleName(CLASSNAME);

    captionToggle.addClassName(CLASSNAME + "-toggle");

    DOM.insertChild(panel.captionNode, captionToggle, 2);

    updateStyleName(panel);

    panel.addDomHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            EventTarget eventTarget = event.getNativeEvent().getEventTarget();

            if (eventTarget.cast() == panel.captionNode
                || eventTarget.cast() == panel.captionNode.getFirstChildElement()
                || eventTarget.cast() == captionToggle.getFirstChildElement()) {
              getState().setOpen(!getState().isOpen());
              refresh();
              rpc.setOpen(getState().isOpen());

              // fire toggle listener
              rpc.toggleClick();
            }
          }
        },
        ClickEvent.getType());
  }
 private void updateStyleName(VPanel panel) {
   if (getState().isOpen()) {
     panel.removeStyleName(STYLENAME_SUFFIX_CLOSED);
     panel.addStyleName(STYLENAME_SUFFIX_OPEN);
   } else {
     panel.removeStyleName(STYLENAME_SUFFIX_OPEN);
     panel.addStyleName(STYLENAME_SUFFIX_CLOSED);
   }
 }