public void widgetDisposed(DisposeEvent e) {
   if (e.widget instanceof TabItem) {
     TabItem item = (TabItem) e.widget;
     IPresentablePart part = getPartForTab(item);
     part.removePropertyListener(childPropertyChangeListener);
   }
 }
  /**
   * Initializes a tab for the given part. Sets the text, icon, tool tip, etc. This will also be
   * called whenever a relevant property changes in the part to reflect those changes in the tab.
   * Subclasses may override to change the appearance of tabs for a particular part.
   *
   * @param tabItem tab for the part
   * @param part the part being displayed
   */
  protected void initTab(TabItem tabItem, IPresentablePart part) {
    tabItem.setText(part.getName());
    tabItem.setToolTipText(part.getTitleToolTip());

    Image tabImage = part.getTitleImage();
    if (tabImage != tabItem.getImage()) {
      tabItem.setImage(tabImage);
    }
  }
 /* (non-Javadoc)
  * @see org.eclipse.ui.presentations.StackPresentation#getTabList(IPresentablePart)
  */
 public Control[] getTabList(IPresentablePart part) {
   ArrayList list = new ArrayList();
   if (getControl() != null) {
     list.add(getControl());
   }
   if (part.getToolBar() != null) {
     list.add(part.getToolBar());
   }
   if (part.getControl() != null) {
     list.add(part.getControl());
   }
   return (Control[]) list.toArray(new Control[list.size()]);
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.skins.StackPresentation#selectPart(org.eclipse.ui.internal.skins.IPresentablePart)
   */
  public void selectPart(IPresentablePart toSelect) {
    if (toSelect == current) {
      return;
    }

    if (current != null) {
      current.setVisible(false);
    }

    current = toSelect;

    if (current != null) {
      tabFolder.setSelection(indexOf(current));
      current.setVisible(true);
      setControlSize();
    }
  }
 private TabItem createPartTab(IPresentablePart part, int tabIndex) {
   TabItem tabItem = new TabItem(tabFolder, SWT.NONE, tabIndex);
   tabItem.setData(TAB_DATA, part);
   part.addPropertyListener(childPropertyChangeListener);
   tabItem.addDisposeListener(tabDisposeListener);
   initTab(tabItem, part);
   return tabItem;
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.internal.skins.StackPresentation#removePart(org.eclipse.ui.internal.skins.IPresentablePart)
   */
  public void removePart(IPresentablePart oldPart) {
    TabItem item = getTab(oldPart);
    if (item == null) {
      return;
    }
    oldPart.setVisible(false);

    item.dispose();
  }
 public void mouseDown(MouseEvent e) {
   //			// PR#1GDEZ25 - If selection will change in mouse up ignore mouse down.
   //			// Else, set focus.
   //			TabItem newItem = tabFolder.getItem(new Point(e.x, e.y));
   //			if (newItem != null) {
   //				TabItem oldItem = tabFolder.getSelection();
   //				if (newItem != oldItem)
   //					return;
   //			}
   if (current != null) {
     current.setFocus();
   }
 }
 /** Set the size of a page in the folder. */
 private void setControlSize() {
   if (current == null || tabFolder == null) {
     return;
   }
   //		Rectangle bounds;
   // @issue as above, the mere presence of a theme should not change the behaviour
   //		if ((mapTabToPart.size() > 1)
   //			|| ((tabThemeDescriptor != null) && (mapTabToPart.size() >= 1)))
   //			bounds = calculatePageBounds(tabFolder);
   //		else
   //			bounds = tabFolder.getBounds();
   current.setBounds(calculatePageBounds(tabFolder));
   // current.moveAbove(tabFolder);
 }
 /* (non-Javadoc)
  * @see org.eclipse.ui.internal.skins.Presentation#setVisible(boolean)
  */
 public void setVisible(boolean isVisible) {
   if (current != null) {
     current.setVisible(isVisible);
   }
   tabFolder.setVisible(isVisible);
 }