private void createImpLabel(Composite container) {
   Label label = new Label(container, SWT.NONE);
   label.setText(PDEUIMessages.TargetImplicitPluginsTab_desc);
   label.setFont(container.getFont());
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalSpan = 2;
   label.setLayoutData(gd);
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
   * .Composite)
   */
  protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    createMessageArea(composite);
    CheckboxTreeViewer treeViewer = createTreeViewer(composite);

    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = convertWidthInCharsToPixels(60);
    data.heightHint = convertHeightInCharsToPixels(18);

    Tree treeWidget = treeViewer.getTree();
    treeWidget.setLayoutData(data);
    treeWidget.setFont(composite.getFont());

    Button button = new Button(composite, SWT.PUSH);
    button.setText(NewWizardMessages.MultipleFolderSelectionDialog_button);
    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent event) {
            newFolderButtonPressed();
          }
        });
    button.setFont(composite.getFont());

    fNewFolderButton = button;

    treeViewer.addSelectionChangedListener(this);
    if (fExisting != null) {
      Object[] existing = fExisting.toArray();
      treeViewer.setGrayedElements(existing);
      setInitialSelections(existing);
    }
    if (fFocusElement != null) {
      treeViewer.setSelection(new StructuredSelection(fFocusElement), true);
    }
    treeViewer.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            forceExistingChecked(event);
          }
        });

    applyDialogFont(composite);
    return composite;
  }
  private Control createImplicitTabContents(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    container.setLayout(layout);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    container.setFont(parent.getFont());

    createImpLabel(container);
    createImpTable(container);
    createImpButtons(container);
    return container;
  }
 private void createImpTable(Composite container) {
   fElementViewer = new TableViewer(container, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
   GridData gd = new GridData(GridData.FILL_BOTH);
   gd.heightHint = 250;
   fElementViewer.getControl().setLayoutData(gd);
   fElementViewer.getControl().setFont(container.getFont());
   fElementViewer.setContentProvider(
       new DefaultTableProvider() {
         public Object[] getElements(Object inputElement) {
           ITargetDefinition target = getTargetDefinition();
           if (target != null) {
             NameVersionDescriptor[] bundles = target.getImplicitDependencies();
             if (bundles != null) {
               return bundles;
             }
           }
           return new NameVersionDescriptor[0];
         }
       });
   fElementViewer.setLabelProvider(new StyledBundleLabelProvider(false, false));
   fElementViewer.setInput(PDEPlugin.getDefault());
   fElementViewer.setComparator(
       new ViewerComparator() {
         public int compare(Viewer viewer, Object e1, Object e2) {
           NameVersionDescriptor bundle1 = (NameVersionDescriptor) e1;
           NameVersionDescriptor bundle2 = (NameVersionDescriptor) e2;
           return super.compare(viewer, bundle1.getId(), bundle2.getId());
         }
       });
   fElementViewer.addSelectionChangedListener(
       new ISelectionChangedListener() {
         public void selectionChanged(SelectionChangedEvent event) {
           updateImpButtons();
         }
       });
   fElementViewer
       .getTable()
       .addKeyListener(
           new KeyAdapter() {
             public void keyPressed(KeyEvent e) {
               if (e.character == SWT.DEL && e.stateMask == 0) {
                 handleRemove();
               }
             }
           });
 }
  /**
   * Creates the contents of this group, using the given toolkit where appropriate so that the
   * controls have the form editor look and feel.
   *
   * @param parent parent composite
   * @param toolkit toolkit to create controls with
   */
  protected void createFormContents(Composite parent, FormToolkit toolkit) {
    fGrouping = GROUP_BY_NONE;

    Composite comp = toolkit.createComposite(parent);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = layout.marginHeight = 0;
    comp.setLayout(layout);
    comp.setLayoutData(new GridData(GridData.FILL_BOTH));
    comp.setFont(parent.getFont());

    createTree(comp, toolkit);
    createButtons(comp, toolkit);

    fCountLabel = toolkit.createLabel(comp, ""); // $NON-NLS-1$
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    fCountLabel.setLayoutData(data);

    updateButtons();
    initializeFilters();
  }
  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.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);
  }
  /**
   * Creates the tree in this group
   *
   * @param parent parent composite
   * @param style toolkit for form style or <code>null</code> for dialog style
   */
  private TreeViewer createTree(Composite parent, FormToolkit toolkit) {
    FilteredCheckboxTree tree = new FilteredCheckboxTree(parent, toolkit);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    tree.getPatternFilter().setIncludeLeadingWildcard(true);
    tree.getFilterControl().setFont(parent.getFont());

    fTree = tree.getCheckboxTreeViewer();
    ((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
    fTree.getControl().setFont(parent.getFont());
    fTree.setUseHashlookup(true);
    fTree.setContentProvider(new TreeContentProvider());
    fTree.setLabelProvider(new StyledBundleLabelProvider(true, false));
    fTree.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            Object first = selection.getFirstElement();
            fTree.setChecked(first, !fTree.getChecked(first));
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });
    fTree.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });
    fTree.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
          }
        });
    fTree.setSorter(
        new ViewerSorter() {
          public int compare(Viewer viewer, Object e1, Object e2) {
            if (fFeaureModeButton.getSelection()) {
              if (e1 == OTHER_CATEGORY) {
                return 1;
              }
              if (e2 == OTHER_CATEGORY) {
                return -1;
              }
            }
            if (e1 instanceof IResolvedBundle && !(e2 instanceof IResolvedBundle)) {
              return -1;
            }
            if (e2 instanceof IResolvedBundle && !(e1 instanceof IResolvedBundle)) {
              return 1;
            }
            if (e1 instanceof IResolvedBundle && e2 instanceof IResolvedBundle) {
              IStatus status1 = ((IResolvedBundle) e1).getStatus();
              IStatus status2 = ((IResolvedBundle) e2).getStatus();
              if (!status1.isOK() && status2.isOK()) {
                return -1;
              }
              if (status1.isOK() && !status2.isOK()) {
                return 1;
              }
            }
            return super.compare(viewer, e1, e2);
          }
        });

    fMenuManager = new MenuManager();
    fMenuManager.add(
        new Action(
            Messages.TargetContentsGroup_collapseAll,
            PlatformUI.getWorkbench()
                .getSharedImages()
                .getImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL)) {
          public void run() {
            fTree.collapseAll();
          }
        });
    Menu contextMenu = fMenuManager.createContextMenu(tree);
    tree.setMenu(contextMenu);

    return fTree;
  }