/* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {
    Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);

    Composite nameComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);

    SWTFactory.createLabel(nameComp, PDEUIMessages.TargetDefinitionContentPage_4, 1);

    fNameText = SWTFactory.createSingleText(nameComp, 1);
    fNameText.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String name = fNameText.getText().trim();
            if (name.length() == 0) {
              setErrorMessage(PDEUIMessages.TargetDefinitionContentPage_7);
            } else {
              setErrorMessage(null);
              setMessage(PDEUIMessages.TargetDefinitionContentPage_2);
            }
            getTargetDefinition().setName(name);
            setPageComplete(isPageComplete());
          }
        });

    TabFolder tabs = new TabFolder(comp, SWT.NONE);
    tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
    tabs.setFont(comp.getFont());

    fLocationTab = new TabItem(tabs, SWT.NONE);
    fLocationTab.setText(PDEUIMessages.LocationSection_0);

    Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
    SWTFactory.createWrapLabel(
        pluginTabContainer, PDEUIMessages.TargetDefinitionContentPage_LocationDescription, 2, 400);
    fLocationTree = TargetLocationsGroup.createInDialog(pluginTabContainer);
    fLocationTab.setControl(pluginTabContainer);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(pluginTabContainer, IHelpContextIds.EDIT_TARGET_WIZARD_LOCATIONS_TAB);

    TabItem contentTab = new TabItem(tabs, SWT.NONE);
    contentTab.setText(PDEUIMessages.TargetDefinitionContentPage_6);
    Composite contentTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
    SWTFactory.createWrapLabel(contentTabContainer, PDEUIMessages.ContentSection_1, 2, 400);
    fContentTree = TargetContentsGroup.createInDialog(contentTabContainer);
    contentTab.setControl(contentTabContainer);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(contentTabContainer, IHelpContextIds.EDIT_TARGET_WIZARD_CONTENT_TAB);

    TabItem envTab = new TabItem(tabs, SWT.NONE);
    envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
    Composite envTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
    createTargetEnvironmentGroup(envTabContainer);
    createJREGroup(envTabContainer);
    envTab.setControl(envTabContainer);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(envTabContainer, IHelpContextIds.EDIT_TARGET_WIZARD_ENVIRONMENT_TAB);

    TabItem argsTab = new TabItem(tabs, SWT.NONE);
    argsTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_4);
    argsTab.setControl(createArgumentsGroup(tabs));
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(argsTab.getControl(), IHelpContextIds.EDIT_TARGET_WIZARD_ARGUMENT_TAB);

    TabItem depTab = new TabItem(tabs, SWT.NONE);
    depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
    depTab.setControl(createImplicitTabContents(tabs));
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(depTab.getControl(), IHelpContextIds.EDIT_TARGET_WIZARD_IMPLICIT_TAB);

    PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.EDIT_TARGET_WIZARD);
    initializeListeners();
    targetChanged(getTargetDefinition());
    setControl(comp);
  }
  protected Control createPageArea(Composite parent) {
    int numPages = fDescriptors.size();
    fScopeParts = new ScopePart[numPages];

    if (numPages == 0) {
      Label label = new Label(parent, SWT.CENTER | SWT.WRAP);
      label.setText(SearchMessages.SearchDialog_noSearchExtension);
      return label;
    }

    fCurrentIndex = getPreferredPageIndex();

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setFont(parent.getFont());

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    TabFolder folder = new TabFolder(composite, SWT.NONE);
    folder.setLayout(new TabFolderLayout());
    folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    folder.setFont(composite.getFont());

    for (int i = 0; i < numPages; i++) {
      SearchPageDescriptor descriptor = getDescriptorAt(i);
      if (WorkbenchActivityHelper.filterItem(descriptor)) continue;

      final TabItem item = new TabItem(folder, SWT.NONE);
      item.setData("descriptor", descriptor); // $NON-NLS-1$
      item.setText(descriptor.getLabel());
      item.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
              item.setData("descriptor", null); // $NON-NLS-1$
              if (item.getImage() != null) item.getImage().dispose();
            }
          });
      ImageDescriptor imageDesc = descriptor.getImage();
      if (imageDesc != null) item.setImage(imageDesc.createImage());

      if (i == fCurrentIndex) {
        Control pageControl = createPageControl(folder, descriptor);
        pageControl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
        item.setControl(pageControl);
        fCurrentPage = descriptor.getPage();
        fDialogSettings.put(STORE_PREVIOUS_PAGE, descriptor.getId());
      }
    }

    folder.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            turnToPage(event);
          }
        });

    folder.setSelection(fCurrentIndex);

    return composite;
  }