private void changeShowText(boolean showText) {
    ToolItem[] items = psTB.getItems();
    for (int i = 0; i < items.length; i++) {
      MPerspective persp = (MPerspective) items[i].getData();
      if (persp != null)
        if (showText) {
          if (persp.getLabel() != null) items[i].setText(persp.getLocalizedLabel());
          items[i].setToolTipText(persp.getLocalizedTooltip());
        } else {
          Image image = items[i].getImage();
          if (image != null) {
            items[i].setText(""); // $NON-NLS-1$
            items[i].setToolTipText(persp.getLocalizedLabel());
          }
        }
    }

    // update the size
    fixSize();
  }
  private ToolItem addPerspectiveItem(MPerspective persp) {
    int perspIndex = persp.getParent().getChildren().indexOf(persp);

    int index = perspIndex + 2; // HACK !! accounts for the 'open' and the
    // separator
    final ToolItem psItem =
        index < psTB.getItemCount()
            ? new ToolItem(psTB, SWT.RADIO, index)
            : new ToolItem(psTB, SWT.RADIO);
    psItem.setData(persp);
    IPerspectiveDescriptor descriptor = getDescriptorFor(persp.getElementId());
    boolean foundImage = false;
    if (descriptor != null) {
      ImageDescriptor desc = descriptor.getImageDescriptor();
      if (desc != null) {
        final Image image = desc.createImage(false);
        if (image != null) {
          psItem.setImage(image);

          psItem.addListener(
              SWT.Dispose,
              new Listener() {
                public void handleEvent(org.eclipse.swt.widgets.Event event) {
                  image.dispose();
                }
              });
          foundImage = true;
          psItem.setToolTipText(persp.getLocalizedLabel());
        }
      }
    }
    if (!foundImage
        || PrefUtil.getAPIPreferenceStore()
            .getBoolean(IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR)) {
      psItem.setText(persp.getLocalizedLabel());
      psItem.setToolTipText(persp.getLocalizedTooltip());
    }

    psItem.setSelection(persp == persp.getParent().getSelectedElement());

    psItem.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            MPerspective persp = (MPerspective) e.widget.getData();
            persp.getParent().setSelectedElement(persp);
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            MPerspective persp = (MPerspective) e.widget.getData();
            persp.getParent().setSelectedElement(persp);
          }
        });

    psItem.addListener(
        SWT.MenuDetect,
        new Listener() {
          public void handleEvent(org.eclipse.swt.widgets.Event event) {
            MPerspective persp = (MPerspective) event.widget.getData();
            openMenuFor(psItem, persp);
          }
        });

    // update the size
    fixSize();

    return psItem;
  }