private void createImpButtons(Composite container) {
    Composite buttonContainer =
        SWTFactory.createComposite(container, 1, 1, GridData.FILL_VERTICAL, 0, 0);

    fAddButton = SWTFactory.createPushButton(buttonContainer, PDEUIMessages.SourceBlock_add, null);
    fAddButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleAdd();
          }
        });

    fRemoveButton =
        SWTFactory.createPushButton(buttonContainer, PDEUIMessages.SourceBlock_remove, null);
    fRemoveButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleRemove();
          }
        });

    fRemoveAllButton =
        SWTFactory.createPushButton(
            buttonContainer, PDEUIMessages.TargetImplicitPluginsTab_removeAll3, null);
    fRemoveAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleRemoveAll();
          }
        });

    updateImpButtons();
  }
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.makeColumnsEqualWidth = false;
    layout.horizontalSpacing = 5;
    layout.verticalSpacing = 10;
    container.setLayout(layout);

    createScrollArea(container);
    createAvailableList(container).setLayoutData(new GridData(GridData.FILL_BOTH));
    createButtonArea(container);
    createImportList(container).setLayoutData(new GridData(GridData.FILL_BOTH));
    updateCount();

    // create container for buttons
    Composite optionComp =
        SWTFactory.createComposite(container, 1, 3, GridData.FILL_HORIZONTAL, 5, 0);
    createComputationsOption(optionComp);
    createFilterOptions(optionComp);

    addViewerListeners();
    initialize();
    addFilters();
    setControl(container);
    Dialog.applyDialogFont(container);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(container, IHelpContextIds.PLUGIN_IMPORT_SECOND_PAGE);
  }
  private void createFilterOptions(Composite container) {
    fFilterOldVersionButton =
        SWTFactory.createCheckButton(
            container, PDEUIMessages.ImportWizard_DetailedPage_filterDesc, null, true, 1);

    if (getDialogSettings().get(SETTINGS_SHOW_LATEST) != null)
      fFilterOldVersionButton.setSelection(getDialogSettings().getBoolean(SETTINGS_SHOW_LATEST));
    else fFilterOldVersionButton.setSelection(true);

    fFilterOldVersionButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (fFilterOldVersionButton.getSelection()) {
              fAvailableListViewer.addFilter(fVersionFilter);
            } else {
              fAvailableListViewer.removeFilter(fVersionFilter);
            }
            updateCount();
          }
        });
  }
  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;
  }
  private void createJREGroup(Composite container) {
    Group group =
        SWTFactory.createGroup(
            container, PDEUIMessages.EnvironmentBlock_jreTitle, 2, 1, GridData.FILL_HORIZONTAL);

    initializeJREValues();

    SWTFactory.createWrapLabel(group, PDEUIMessages.JRESection_description, 2);

    fDefaultJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_defaultJRE, 2);
    fDefaultJREButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            updateJREWidgets();
            getTargetDefinition().setJREContainer(JavaRuntime.newDefaultJREContainerPath());
          }
        });

    fNamedJREButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_JREName);
    fNamedJREButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            updateJREWidgets();
            getTargetDefinition()
                .setJREContainer(
                    JavaRuntime.newJREContainerPath(
                        VMUtil.getVMInstall(fNamedJREsCombo.getText())));
          }
        });

    fNamedJREsCombo =
        SWTFactory.createCombo(
            group, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY, 1, VMUtil.getVMInstallNames());
    fNamedJREsCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition()
                .setJREContainer(
                    JavaRuntime.newJREContainerPath(
                        VMUtil.getVMInstall(fNamedJREsCombo.getText())));
          }
        });

    fExecEnvButton = SWTFactory.createRadioButton(group, PDEUIMessages.JRESection_ExecutionEnv);
    fExecEnvButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            updateJREWidgets();
            getTargetDefinition()
                .setJREContainer(
                    JavaRuntime.newJREContainerPath(
                        VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
          }
        });

    fExecEnvsCombo =
        SWTFactory.createCombo(
            group,
            SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY,
            1,
            fExecEnvChoices.toArray(new String[fExecEnvChoices.size()]));
    fExecEnvsCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition()
                .setJREContainer(
                    JavaRuntime.newJREContainerPath(
                        VMUtil.getExecutionEnvironment(fExecEnvsCombo.getText())));
          }
        });
  }
  private void createTargetEnvironmentGroup(Composite container) {
    Group group =
        SWTFactory.createGroup(
            container, PDEUIMessages.EnvironmentBlock_targetEnv, 2, 1, GridData.FILL_HORIZONTAL);

    initializeChoices();

    SWTFactory.createWrapLabel(group, PDEUIMessages.EnvironmentSection_description, 2);

    SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_os, 1);

    fOSCombo =
        SWTFactory.createCombo(
            group, SWT.SINGLE | SWT.BORDER, 1, fOSChoices.toArray(new String[fOSChoices.size()]));
    fOSCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setOS(getModelValue(fOSCombo.getText()));
          }
        });

    SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_ws, 1);

    fWSCombo =
        SWTFactory.createCombo(
            group, SWT.SINGLE | SWT.BORDER, 1, fWSChoices.toArray(new String[fWSChoices.size()]));
    fWSCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setWS(getModelValue(fWSCombo.getText()));
          }
        });

    SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_arch, 1);

    fArchCombo =
        SWTFactory.createCombo(
            group,
            SWT.SINGLE | SWT.BORDER,
            1,
            fArchChoices.toArray(new String[fArchChoices.size()]));
    fArchCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            getTargetDefinition().setArch(getModelValue(fArchCombo.getText()));
          }
        });

    SWTFactory.createLabel(group, PDEUIMessages.Preferences_TargetEnvironmentPage_nl, 1);

    fNLCombo =
        SWTFactory.createCombo(
            group, SWT.SINGLE | SWT.BORDER, 1, fNLChoices.toArray(new String[fNLChoices.size()]));
    fNLCombo.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            String value = fNLCombo.getText();
            int index = value.indexOf("-"); // $NON-NLS-1$
            if (index > 0) value = value.substring(0, index);
            getTargetDefinition().setNL(getModelValue(value));
          }
        });
  }
  /* (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);
  }