/**
   * Resize the scrolled composite enclosing the sections, which may result in the addition or
   * removal of scroll bars.
   *
   * @since 3.5
   */
  public void resizeScrolledComposite() {
    Point currentTabSize = new Point(0, 0);
    if (currentTab != null) {
      final Composite sizeReference = (Composite) tabToComposite.get(currentTab);
      if (sizeReference != null) {
        currentTabSize = sizeReference.computeSize(SWT.DEFAULT, SWT.DEFAULT);
      }
    }
    tabbedPropertyComposite.getScrolledComposite().setMinSize(currentTabSize);

    final ScrollBar verticalScrollBar =
        tabbedPropertyComposite.getScrolledComposite().getVerticalBar();
    if (verticalScrollBar != null) {
      final Rectangle clientArea = tabbedPropertyComposite.getScrolledComposite().getClientArea();
      final int increment = clientArea.height - 5;
      verticalScrollBar.setPageIncrement(increment);
    }

    final ScrollBar horizontalScrollBar =
        tabbedPropertyComposite.getScrolledComposite().getHorizontalBar();
    if (horizontalScrollBar != null) {
      final Rectangle clientArea = tabbedPropertyComposite.getScrolledComposite().getClientArea();
      final int increment = clientArea.width - 5;
      horizontalScrollBar.setPageIncrement(increment);
    }
  }
 /**
  * Helper method for creating property tab composites.
  *
  * @return the property tab composite.
  */
 private Composite createTabComposite() {
   final Composite result =
       widgetFactory.createComposite(tabbedPropertyComposite.getTabComposite(), SWT.NO_FOCUS);
   result.setVisible(false);
   result.setLayout(new FillLayout());
   final FormData data = new FormData();
   if (hasTitleBar) {
     data.top = new FormAttachment(tabbedPropertyComposite.getTitle(), 0);
   } else {
     data.top = new FormAttachment(0, 0);
   }
   data.bottom = new FormAttachment(100, 0);
   data.left = new FormAttachment(0, 0);
   data.right = new FormAttachment(100, 0);
   result.setLayoutData(data);
   return result;
 }
  /** @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) */
  @Override
  public void createControl(final Composite parent) {
    widgetFactory = new TabbedPropertySheetWidgetFactory();
    tabbedPropertyComposite = new TabbedPropertyComposite(parent, widgetFactory, hasTitleBar);
    widgetFactory.paintBordersFor(tabbedPropertyComposite);
    tabbedPropertyComposite.setLayout(new FormLayout());
    final FormData formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(100, 0);
    tabbedPropertyComposite.setLayoutData(formData);

    tabbedPropertyViewer = new TabbedPropertyViewer(tabbedPropertyComposite.getList());
    tabbedPropertyViewer.setContentProvider(tabListContentProvider);
    tabbedPropertyViewer.setLabelProvider(new TabbedPropertySheetPageLabelProvider());
    tabbedPropertyViewer.addSelectionChangedListener(new SelectionChangedListener());

    tabbedPropertyComposite
        .getScrolledComposite()
        .addControlListener(
            new ControlAdapter() {

              @Override
              public void controlResized(final ControlEvent e) {
                resizeScrolledComposite();
              }
            });

    /** Add a part activation listener. */
    cachedWorkbenchWindow = getSite().getWorkbenchWindow();
    cachedWorkbenchWindow.getPartService().addPartListener(partActivationListener);

    /** Add a label provider change listener. */
    if (hasTitleBar) {
      registry.getLabelProvider().addListener(this);
    }
  }
 /** Update the title bar of the contributor has a label provider. */
 protected void refreshTitleBar() {
   if (hasTitleBar) {
     final TabbedPropertyTitle title = tabbedPropertyComposite.getTitle();
     if (currentTab == null) {
       /**
        * No tabs are shown so hide the title bar, otherwise you see "No properties available" and
        * a title bar for the selection.
        */
       title.setTitle(null, null);
     } else {
       final String text = registry.getLabelProvider().getText(currentSelection);
       final Image image = registry.getLabelProvider().getImage(currentSelection);
       title.setTitle(text, image);
     }
   }
 }