private void createOptionalDependenciesButton(Composite container) {
   if (isEditable()) {
     fIncludeOptionalButton = new Button(container, SWT.CHECK);
     fIncludeOptionalButton.setText(PDEUIMessages.PluginSection_includeOptional);
     // initialize value
     IEditorInput input = getPage().getEditorInput();
     if (input instanceof IFileEditorInput) {
       IFile file = ((IFileEditorInput) input).getFile();
       try {
         fIncludeOptionalButton.setSelection(
             "true".equals(file.getPersistentProperty(OPTIONAL_PROPERTY))); // $NON-NLS-1$
       } catch (CoreException e) {
       }
     }
     // create listener to save value when the checkbox is changed
     fIncludeOptionalButton.addSelectionListener(
         new SelectionAdapter() {
           public void widgetSelected(SelectionEvent e) {
             IEditorInput input = getPage().getEditorInput();
             if (input instanceof IFileEditorInput) {
               IFile file = ((IFileEditorInput) input).getFile();
               try {
                 file.setPersistentProperty(
                     OPTIONAL_PROPERTY,
                     fIncludeOptionalButton.getSelection() ? "true" : null); // $NON-NLS-1$
               } catch (CoreException e1) {
               }
             }
           }
         });
   }
 }
 private Button createButton(Composite parent, FormToolkit toolkit, String label) {
   Button button = toolkit.createButton(parent, label, SWT.CHECK);
   GridData gd = new GridData();
   gd.horizontalSpan = F_NUM_COLUMNS;
   button.setLayoutData(gd);
   return button;
 }
  public void createClient(Section section, FormToolkit toolkit) {

    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    section.setLayoutData(data);

    section.setText(PDEUIMessages.IntroSection_sectionText);
    section.setDescription(PDEUIMessages.IntroSection_sectionDescription);

    boolean canCreateNew = TargetPlatformHelper.getTargetVersion() >= NEW_INTRO_SUPPORT_VERSION;

    Composite client = toolkit.createComposite(section);
    client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, canCreateNew ? 3 : 2));
    client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label label = toolkit.createLabel(client, PDEUIMessages.IntroSection_introLabel, SWT.WRAP);
    GridData td = new GridData();
    td.horizontalSpan = canCreateNew ? 3 : 2;
    label.setLayoutData(td);

    Label introLabel = toolkit.createLabel(client, PDEUIMessages.IntroSection_introInput);
    introLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));

    fIntroCombo = new ComboPart();
    fIntroCombo.createControl(client, toolkit, SWT.READ_ONLY);
    td = new GridData(GridData.FILL_HORIZONTAL);
    fIntroCombo.getControl().setLayoutData(td);
    loadManifestAndIntroIds(false);
    if (fAvailableIntroIds != null) fIntroCombo.setItems(fAvailableIntroIds);
    fIntroCombo.add(""); // $NON-NLS-1$
    fIntroCombo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            handleSelection();
          }
        });

    if (canCreateNew) {
      Button button = toolkit.createButton(client, PDEUIMessages.IntroSection_new, SWT.PUSH);
      button.setEnabled(isEditable());
      button.setLayoutData(new GridData(GridData.FILL));
      button.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleNewIntro();
            }
          });
    }

    fIntroCombo.getControl().setEnabled(isEditable());

    toolkit.paintBordersFor(client);
    section.setClient(client);
    // Register to be notified when the model changes
    getModel().addModelChangedListener(this);
  }
  private void createProgressMessageConfig(Composite parent) {
    fAddMessageButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressMessage);
    fAddMessageButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean enable = fAddMessageButton.getSelection();
            getSplashInfo().addProgressMessage(enable, false);
            updateFieldEnablement();
          }
        });
    fAddMessageButton.setEnabled(false);

    Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE);

    fMessageControls[0] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageX);
    fMessageControls[1] = fMessageSpinners[0] = createSpinner(parent, fToolkit);
    fMessageControls[2] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageY);
    fMessageControls[3] = fMessageSpinners[1] = createSpinner(parent, fToolkit);

    fMessageControls[4] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageWidth);
    fMessageControls[5] = fMessageSpinners[2] = createSpinner(parent, fToolkit);
    fMessageControls[6] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageHeight);
    fMessageControls[7] = fMessageSpinners[3] = createSpinner(parent, fToolkit);

    fMessageControls[8] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_messageColor);
    fColorSelector = new ColorSelector(parent);
    fColorSelector.addListener(
        new IPropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent event) {
            if (!event.getNewValue().equals(event.getOldValue())) applyColor();
          }
        });
    fToolkit.adapt(fColorSelector.getButton(), true, true);
    fMessageControls[9] = fColorSelector.getButton();
    // Add tooltips to coordinate controls
    addOffsetTooltips(fMessageControls);

    for (Spinner spinner : fMessageSpinners) {
      spinner.setEnabled(isEditable());
      spinner.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              applySpinners(false);
            }
          });
    }
  }
  private void createProgressBarConfig(Composite parent) {
    fAddBarButton = createButton(parent, fToolkit, PDEUIMessages.SplashSection_progressBar);
    fAddBarButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean enable = fAddBarButton.getSelection();
            getSplashInfo().addProgressBar(enable, false);
            updateFieldEnablement();
          }
        });
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.verticalIndent = 5;
    data.horizontalSpan = F_NUM_COLUMNS;
    fAddBarButton.setLayoutData(data);
    fAddBarButton.setEnabled(isEditable());

    Color foreground = fToolkit.getColors().getColor(IFormColors.TITLE);

    fBarControls[0] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressX);
    fBarControls[1] = fBarSpinners[0] = createSpinner(parent, fToolkit);
    fBarControls[2] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressY);
    fBarControls[3] = fBarSpinners[1] = createSpinner(parent, fToolkit);
    fBarControls[4] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressWidth);
    fBarControls[5] = fBarSpinners[2] = createSpinner(parent, fToolkit);
    fBarControls[6] =
        createLabel(parent, fToolkit, foreground, PDEUIMessages.SplashSection_progressHeight);
    fBarControls[7] = fBarSpinners[3] = createSpinner(parent, fToolkit);
    // Add tooltips to coordinate controls
    addOffsetTooltips(fBarControls);

    for (Spinner spinner : fBarSpinners) {
      spinner.setEnabled(isEditable());
      spinner.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              applySpinners(true);
            }
          });
    }

    Composite filler = fToolkit.createComposite(parent);
    filler.setLayout(new GridLayout());
    GridData gd = new GridData();
    gd.horizontalSpan = 2;
    filler.setLayoutData(gd);
  }
  @Override
  public void refresh() {
    ISplashInfo info = getSplashInfo();
    fBlockNotification = true;

    fColorSelector.setColorValue(hexToRGB(info.getForegroundColor()));

    int[] pgeo = info.getProgressGeometry();
    boolean addProgress = pgeo != null;
    info.addProgressBar(addProgress, fBlockNotification);
    if (addProgress) {
      for (int i = 0; i < pgeo.length; i++) {
        fBarSpinners[i].setSelection(pgeo[i]);
      }
    } else {
      resetProgressBarGeometry();
    }

    fAddBarButton.setSelection(addProgress);

    int[] mgeo = info.getMessageGeometry();
    boolean addMessage = mgeo != null;
    info.addProgressMessage(addMessage, fBlockNotification);
    if (addMessage) {
      for (int i = 0; i < mgeo.length; i++) {
        fMessageSpinners[i].setSelection(mgeo[i]);
      }
    } else {
      resetProgressMessageGeometry();
    }
    fColorSelector.setColorValue(
        addMessage ? hexToRGB(info.getForegroundColor()) : new RGB(0, 0, 0));

    fAddMessageButton.setSelection(addMessage);

    // Update the UI
    updateUIFieldTemplateCombo();
    fBlockNotification = false;
    super.refresh();
    // Update this sections enablement
    updateFieldEnablement();
  }
 private void updateFieldProgressEnablement() {
   // Get the splash info if any
   ISplashInfo info = getSplashInfo();
   // Enable section under the following conditions:
   // (1) Product ID is defined
   // (2) Progress geometry is defined
   // (3) Splash handler type is NOT defined
   if ((PDETextHelper.isDefined(getProduct().getProductId()) == false)
       || ((info.isDefinedGeometry() == false) && (info.isDefinedSplashHandlerType() == true))) {
     fAddBarButton.setEnabled(false);
     fAddMessageButton.setEnabled(false);
     updateFieldProgressBarEnablement(false);
     updateFieldProgressMessageEnablement(false);
   } else {
     fAddBarButton.setEnabled(isEditable());
     fAddMessageButton.setEnabled(isEditable());
     updateFieldProgressBarEnablement(isEditable());
     updateFieldProgressMessageEnablement(isEditable());
   }
 }
 /* (non-Javadoc)
  * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#buttonSelected(int)
  */
 protected void buttonSelected(int index) {
   switch (index) {
     case 0:
       handleAdd();
       break;
     case 1:
       handleAddWorkingSet();
       break;
     case 2:
       handleAddRequired(getProduct().getPlugins(), fIncludeOptionalButton.getSelection());
       break;
     case 3:
       handleDelete();
       break;
     case 4:
       handleRemoveAll();
       break;
     case 5:
       handleProperties();
       break;
   }
 }
 private void updateFieldProgressMessageEnablement(boolean buttonEnabled) {
   boolean enable = (fAddMessageButton.getSelection() && buttonEnabled);
   for (Control messageControl : fMessageControls) {
     messageControl.setEnabled(enable);
   }
 }
 private void updateFieldProgressBarEnablement(boolean buttonEnabled) {
   boolean enable = (fAddBarButton.getSelection() && buttonEnabled);
   for (Control barControl : fBarControls) {
     barControl.setEnabled(enable);
   }
 }
 public boolean includeOptionalDependencies() {
   return fIncludeOptionalButton.getSelection();
 }