Esempio n. 1
0
  /**
   * The constructor for an empty tabbed panel.
   *
   * <p>
   *
   * @param tabbedPanelStyle the pre-defined height of the tabbar, can be "small" or "standard"
   */
  public CmsTabbedPanel(CmsTabbedPanelStyle tabbedPanelStyle) {

    m_tabPanel = new TabLayoutPanel(tabbedPanelStyle.getBarHeight(), Unit.PX);
    m_panelStyle = tabbedPanelStyle;

    // All composites must call initWidget() in their constructors.
    initWidget(m_tabPanel);

    Element tabRootEl = m_tabPanel.getElement();
    // set an additional css class for the parent element of the .gwt-TabLayoutPanelTabs element
    List<Element> tabBarDivs =
        CmsDomUtil.getElementsByClass(
            I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().cmsTabLayoutPanelTabs(),
            CmsDomUtil.Tag.div,
            tabRootEl);
    if (tabBarDivs.size() == 1) {
      tabBarDivs
          .get(0)
          .getParentElement()
          .setClassName(
              I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().cmsTabLayoutPanelTabBar()
                  + " "
                  + I_CmsLayoutBundle.INSTANCE.generalCss().cornerAll());
      if (m_panelStyle.getTabColorClass() != null) {
        tabBarDivs.get(0).getParentElement().addClassName(m_panelStyle.getTabColorClass());
      }
    }

    m_tabPanel.setStyleName(m_panelStyle.getStyleClass());
    m_tabPanel.addStyleName(I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().cmsTabLayoutPanel());
    m_tabPanel.addStyleName(
        I_CmsLayoutBundle.INSTANCE.generalCss().cornerAll()
            + " "
            + I_CmsLayoutBundle.INSTANCE.generalCss().textMedium());

    m_tabPanel.addAttachHandler(
        new AttachEvent.Handler() {

          /**
           * @see
           *     com.google.gwt.event.logical.shared.AttachEvent.Handler#onAttachOrDetach(com.google.gwt.event.logical.shared.AttachEvent)
           */
          public void onAttachOrDetach(AttachEvent event) {

            setOverflowVisibleToContent();
          }
        });
  }