@Override
  protected Control createDialogArea(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = layout.marginWidth = 8;
    layout.numColumns = 1;

    layout.makeColumnsEqualWidth = false;
    container.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    container.setLayoutData(gd);
    Label libraryLabel = new Label(container, SWT.NULL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    libraryLabel.setLayoutData(gd);
    libraryLabel.setText(PDEUIMessages.ManifestEditor_RuntimeLibraryDialog_label);

    libraryText = new Text(container, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    libraryText.setLayoutData(gd);
    libraryText.setText(PDEUIMessages.ManifestEditor_RuntimeLibraryDialog_default);
    libraryText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            updateStatus(validator.validate(libraryText.getText()));
          }
        });
    applyDialogFont(container);
    return container;
  }
 @Override
 public void setVisible(boolean visible) {
   super.setVisible(visible);
   if (visible) {
     fFilterText.setFocus();
     setPageComplete(fImportListViewer.getTable().getItemCount() > 0);
   }
 }
 private void handleFilter() {
   boolean changed = false;
   String newFilter;
   if (fFilterText == null || (newFilter = fFilterText.getText().trim()).length() == 0)
     newFilter = "*"; // $NON-NLS-1$
   changed = fAvailableFilter.setPattern(newFilter);
   if (changed) {
     fAvailableListViewer.refresh();
     updateButtonEnablement(false, false);
   }
 }
  private Composite createScrollArea(Composite parent) {
    Group container = new Group(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = layout.marginHeight = 6;
    container.setLayout(layout);

    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    container.setLayoutData(gd);
    container.setText(PDEUIMessages.ImportWizard_DetailedPage_filter);

    Label filterLabel = new Label(container, SWT.NONE);
    filterLabel.setText(PDEUIMessages.ImportWizard_DetailedPage_search);

    fFilterText = new Text(container, SWT.BORDER);
    fFilterText.setText(""); // $NON-NLS-1$
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fFilterText.setLayoutData(gd);

    return container;
  }
  private void addViewerListeners() {
    fAvailableListViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          @Override
          public void doubleClick(DoubleClickEvent event) {
            handleAdd();
          }
        });

    fImportListViewer.addDoubleClickListener(
        new IDoubleClickListener() {
          @Override
          public void doubleClick(DoubleClickEvent event) {
            handleRemove();
          }
        });

    fAvailableListViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            updateSelectionBasedEnablement(event.getSelection(), true);
          }
        });

    fImportListViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            updateSelectionBasedEnablement(event.getSelection(), false);
          }
        });

    fFilterText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            fFilterJob.cancel();
            fFilterJob.schedule(200);
          }
        });
  }
 /* (non-Javadoc)
  * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
  */
 public boolean isPageComplete() {
   if (fNameText.getText().trim().length() == 0) return false;
   return true;
 }
  private Control createArgumentsGroup(Composite parent) {
    Composite container = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);

    SWTFactory.createWrapLabel(container, PDEUIMessages.JavaArgumentsTab_description, 1);

    Group programGroup =
        SWTFactory.createGroup(
            container,
            PDEUIMessages.JavaArgumentsTab_progamArgsGroup,
            1,
            1,
            GridData.FILL_HORIZONTAL);

    fProgramArgs =
        SWTFactory.createText(
            programGroup,
            SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL,
            1,
            200,
            60,
            GridData.FILL_BOTH);
    fProgramArgs.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setProgramArguments(fProgramArgs.getText().trim());
          }
        });

    Composite programButtons =
        SWTFactory.createComposite(programGroup, 1, 1, GridData.HORIZONTAL_ALIGN_END, 0, 0);

    Button programVars =
        SWTFactory.createPushButton(
            programButtons,
            PDEUIMessages.JavaArgumentsTab_programVariables,
            null,
            GridData.HORIZONTAL_ALIGN_END);
    programVars.addSelectionListener(getVariablesListener(fProgramArgs));

    Group vmGroup = new Group(container, SWT.NONE);
    vmGroup.setLayout(new GridLayout(1, false));
    vmGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    vmGroup.setText(PDEUIMessages.JavaArgumentsTab_vmArgsGroup);
    vmGroup.setFont(container.getFont());

    fVMArgs =
        SWTFactory.createText(
            vmGroup,
            SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL,
            1,
            200,
            60,
            GridData.FILL_BOTH);
    fVMArgs.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setVMArguments(fVMArgs.getText().trim());
          }
        });

    Composite buttons =
        SWTFactory.createComposite(vmGroup, 2, 1, GridData.HORIZONTAL_ALIGN_END, 0, 0);

    Button vmArgs =
        SWTFactory.createPushButton(
            buttons, PDEUIMessages.JavaArgumentsTab_addVMArgs, null, GridData.HORIZONTAL_ALIGN_END);
    vmArgs.addSelectionListener(getVMArgsListener(fVMArgs));

    Button vmVars =
        SWTFactory.createPushButton(
            buttons,
            PDEUIMessages.JavaArgumentsTab_vmVariables,
            null,
            GridData.HORIZONTAL_ALIGN_END);
    vmVars.addSelectionListener(getVariablesListener(fVMArgs));
    return container;
  }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
   */
  protected void targetChanged(ITargetDefinition definition) {
    super.targetChanged(definition);
    if (definition != null) {
      // When  If the page isn't open yet, try running a UI job so the dialog has time to finish
      // opening
      new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
        public IStatus runInUIThread(IProgressMonitor monitor) {
          ITargetDefinition definition = getTargetDefinition();
          if (!definition.isResolved()) {
            try {
              getContainer()
                  .run(
                      true,
                      true,
                      new IRunnableWithProgress() {
                        public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                          getTargetDefinition().resolve(new ResolutionProgressMonitor(monitor));
                          if (monitor.isCanceled()) {
                            throw new InterruptedException();
                          }
                        }
                      });
            } catch (InvocationTargetException e) {
              PDECore.log(e);
            } catch (InterruptedException e) {
              fContentTree.setCancelled();
              return Status.CANCEL_STATUS;
            }
          }
          fContentTree.setInput(definition);
          fLocationTree.setInput(definition);
          if (definition.isResolved() && definition.getStatus().getSeverity() == IStatus.ERROR) {
            fLocationTab.setImage(
                PlatformUI.getWorkbench()
                    .getSharedImages()
                    .getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
          } else {
            fLocationTab.setImage(null);
          }
          return Status.OK_STATUS;
        }
      }.schedule();
      String name = definition.getName();
      if (name == null) {
        name = EMPTY_STRING;
      }

      if (name.trim().length() > 0) fNameText.setText(name);
      else setMessage(PDEUIMessages.TargetDefinitionContentPage_8);

      fLocationTree.setInput(definition);
      fContentTree.setInput(definition);

      String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
      fOSCombo.setText(presetValue);
      presetValue = (definition.getWS() == null) ? EMPTY_STRING : definition.getWS();
      fWSCombo.setText(presetValue);
      presetValue = (definition.getArch() == null) ? EMPTY_STRING : definition.getArch();
      fArchCombo.setText(presetValue);
      presetValue =
          (definition.getNL() == null)
              ? EMPTY_STRING
              : LocaleUtil.expandLocaleName(definition.getNL());
      fNLCombo.setText(presetValue);

      IPath jrePath = definition.getJREContainer();
      if (jrePath == null || jrePath.equals(JavaRuntime.newDefaultJREContainerPath())) {
        fDefaultJREButton.setSelection(true);
      } else {
        String ee = JavaRuntime.getExecutionEnvironmentId(jrePath);
        if (ee != null) {
          fExecEnvButton.setSelection(true);
          fExecEnvsCombo.select(fExecEnvsCombo.indexOf(ee));
        } else {
          String vm = JavaRuntime.getVMInstallName(jrePath);
          if (vm != null) {
            fNamedJREButton.setSelection(true);
            fNamedJREsCombo.select(fNamedJREsCombo.indexOf(vm));
          }
        }
      }

      if (fExecEnvsCombo.getSelectionIndex() == -1)
        fExecEnvsCombo.setText(fExecEnvChoices.first().toString());

      if (fNamedJREsCombo.getSelectionIndex() == -1)
        fNamedJREsCombo.setText(VMUtil.getDefaultVMInstallName());

      updateJREWidgets();

      presetValue =
          (definition.getProgramArguments() == null)
              ? EMPTY_STRING
              : definition.getProgramArguments();
      fProgramArgs.setText(presetValue);
      presetValue =
          (definition.getVMArguments() == null) ? EMPTY_STRING : definition.getVMArguments();
      fVMArgs.setText(presetValue);

      fElementViewer.refresh();
    }
  }
  /* (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);
  }
 @Override
 protected void okPressed() {
   libraryName = libraryText.getText();
   super.okPressed();
 }
 @Override
 public int open() {
   libraryText.setText("library.jar"); // $NON-NLS-1$
   libraryText.setSelection(0, libraryText.getText().length() - 4);
   return super.open();
 }