private void handleNewIntro() {
   boolean needNewProduct = false;
   if (!productDefined()) {
     needNewProduct = true;
     MessageDialog mdiag =
         new MessageDialog(
             PDEPlugin.getActiveWorkbenchShell(),
             PDEUIMessages.IntroSection_undefinedProductId,
             null,
             PDEUIMessages.IntroSection_undefinedProductIdMessage,
             MessageDialog.QUESTION,
             new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
             0);
     if (mdiag.open() != Window.OK) return;
   }
   ProductIntroWizard wizard = new ProductIntroWizard(getProduct(), needNewProduct);
   WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
   dialog.create();
   if (dialog.open() == Window.OK) {
     String id = wizard.getIntroId();
     fIntroCombo.add(id, 0);
     fIntroCombo.setText(id);
     getIntroInfo().setId(id);
     addDependenciesAndPlugins();
   }
 }
  private void createUIListenersFieldTemplateCombo() {
    // Selection listener
    fFieldTemplateCombo.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            handleTemplateComboWidgetSelected();
          }
        });
    // Focus listener
    fFieldTemplateCombo
        .getControl()
        .addFocusListener(
            new FocusAdapter() {
              @Override
              public void focusGained(FocusEvent e) {
                double currentTarget = TargetPlatformHelper.getTargetVersion();
                if (currentTarget <= 3.2) {
                  fControlDecoration.show();
                }
              }

              @Override
              public void focusLost(FocusEvent e) {
                fControlDecoration.hide();
              }
            });
  }
 private void handleSelection() {
   if (!productDefined()) {
     fIntroCombo.setText(""); // $NON-NLS-1$
     return;
   }
   getIntroInfo().setId(fIntroCombo.getSelection());
   addDependenciesAndPlugins();
 }
 public void refresh() {
   String introId = getIntroInfo().getId();
   if (introId == null) {
     fIntroCombo.setText(""); // $NON-NLS-1$
   } else {
     fIntroCombo.setText(introId);
   }
   super.refresh();
 }
 protected ComboPart createComboPart(
     Composite parent, FormToolkit toolkit, String[] items, int colspan, int style) {
   ComboPart cp = new ComboPart();
   cp.createControl(parent, toolkit, SWT.READ_ONLY);
   GridData gd = new GridData(style);
   gd.horizontalSpan = colspan;
   gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
   cp.getControl().setLayoutData(gd);
   cp.setItems(items);
   cp.getControl().setEnabled(isEditable());
   return cp;
 }
 private void updateFieldTemplateEnablement() {
   // Get the splash info if any
   ISplashInfo info = getSplashInfo();
   // Enable section under the following conditions:
   // (1) Product ID is defined
   // (2) Progress geometry is NOT defined
   // (3) Progress geometry is defined and splash handler type is defined
   if ((PDETextHelper.isDefined(getProduct().getProductId()) == false)
       || ((info.isDefinedGeometry() == true) && (info.isDefinedSplashHandlerType() == false))) {
     fFieldTemplateCombo.setEnabled(false);
   } else {
     fFieldTemplateCombo.setEnabled(true);
   }
 }
 private void createUIFieldTemplateCombo(Composite parent) {
   int style = SWT.READ_ONLY | SWT.BORDER;
   fFieldTemplateCombo = new ComboPart();
   fFieldTemplateCombo.createControl(parent, fToolkit, style);
   GridData data = new GridData(GridData.FILL_HORIZONTAL);
   data.horizontalSpan = F_NUM_COLUMNS - 1;
   fFieldTemplateCombo.getControl().setLayoutData(data);
   // Add "none" element
   fFieldTemplateCombo.add(PDEUIMessages.SplashConfigurationSection_none, 0);
   // Add all splash screen types in exact order found
   for (int i = 0; i < ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES.length; i++) {
     int position = i + 1;
     fFieldTemplateCombo.add(ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES[i][1], position);
   }
 }
 /* (non-Javadoc)
  * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
  */
 public void setEnabled(boolean enabled) {
   fTree.getControl().setEnabled(enabled);
   if (enabled) {
     updateButtons();
   } else {
     fSelectButton.setEnabled(false);
     fSelectAllButton.setEnabled(false);
     fDeselectButton.setEnabled(false);
     fDeselectAllButton.setEnabled(false);
     fSelectRequiredButton.setEnabled(false);
     fCountLabel.setText(""); // $NON-NLS-1$
   }
   fModeLabel.setEnabled(enabled);
   fPluginModeButton.setEnabled(enabled);
   fFeaureModeButton.setEnabled(enabled);
   fShowLabel.setEnabled(enabled);
   fShowPluginsButton.setEnabled(enabled);
   fShowSourceButton.setEnabled(enabled);
   boolean isPluginMode = !fFeaureModeButton.getSelection();
   fGroupLabel.setEnabled(enabled && isPluginMode);
   if (fGroupCombo != null) {
     fGroupCombo.setEnabled(enabled && isPluginMode);
   } else {
     fGroupComboPart.setEnabled(enabled && isPluginMode);
   }
 }
 /** @return the associated key of the item selected in the combo box */
 private String getSelectedTemplate() {
   int index = fFieldTemplateCombo.getSelectionIndex();
   int position = index - 1;
   if ((index <= 0) || (index > ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES.length)) {
     return null;
   }
   return ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES[position][0];
 }
 private void updateUIFieldTemplateCombo() {
   // Update this sections enablement
   updateFieldEnablement();
   // Get the splash info if any
   ISplashInfo info = getSplashInfo();
   if (info.isDefinedSplashHandlerType() == false) {
     // No splash handler type defined, set "none" in combo box
     fFieldTemplateCombo.setText(PDEUIMessages.SplashConfigurationSection_none);
     return;
   }
   String splashHandlerType = info.getFieldSplashHandlerType();
   // Update the splash handler type in the combo box
   for (String[] typeChoice : ISplashHandlerConstants.F_SPLASH_SCREEN_TYPE_CHOICES) {
     String key = typeChoice[0];
     if (splashHandlerType.equals(key)) {
       String displayName = typeChoice[1];
       fFieldTemplateCombo.setText(displayName);
     }
   }
 }
  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 handleGroupChange() {
   int index;
   if (fGroupCombo != null) {
     index = fGroupCombo.getSelectionIndex();
   } else {
     index = fGroupComboPart.getSelectionIndex();
   }
   if (index != fGrouping) {
     // Refresh tree
     fGrouping = index;
     fTree.getControl().setRedraw(false);
     fTree.refresh(false);
     fTree.expandAll();
     updateCheckState();
     updateButtons();
     fTree.getControl().setRedraw(true);
   }
 }
 private void createUIFieldDecorationTemplate() {
   // Decorate the combo with the info image
   int bits = SWT.TOP | SWT.LEFT;
   fControlDecoration = new ControlDecoration(fFieldTemplateCombo.getControl(), bits);
   // Configure decoration
   // No margin
   fControlDecoration.setMarginWidth(0);
   // Custom hover tip text
   fControlDecoration.setDescriptionText(
       PDEUIMessages.SplashConfigurationSection_msgDecorationTemplateSupport);
   // Custom hover properties
   fControlDecoration.setShowHover(true);
   // Hover image to use
   FieldDecoration contentProposalImage =
       FieldDecorationRegistry.getDefault()
           .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
   fControlDecoration.setImage(contentProposalImage.getImage());
   // Hide the decoration initially
   fControlDecoration.hide();
 }
  /**
   * Creates the buttons in this group inside a new composite
   *
   * @param parent parent composite
   * @param toolkit toolkit to give form style or <code>null</code> for dialog style
   */
  private void createButtons(Composite parent, FormToolkit toolkit) {
    if (toolkit != null) {
      Composite buttonComp = toolkit.createComposite(parent);
      GridLayout layout = new GridLayout();
      layout.marginWidth = layout.marginHeight = 0;
      buttonComp.setLayout(layout);
      buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));

      fSelectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_0, SWT.PUSH);
      fSelectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      fDeselectButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_1, SWT.PUSH);
      fDeselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Label emptySpace = new Label(buttonComp, SWT.NONE);
      GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectAllButton = toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_2, SWT.PUSH);
      fSelectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      fDeselectAllButton =
          toolkit.createButton(buttonComp, Messages.IncludedBundlesTree_3, SWT.PUSH);
      fDeselectAllButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      emptySpace = new Label(buttonComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectRequiredButton =
          toolkit.createButton(buttonComp, Messages.TargetContentsGroup_4, SWT.PUSH);
      fSelectRequiredButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Composite filterComp = toolkit.createComposite(buttonComp);
      layout = new GridLayout();
      layout.marginWidth = layout.marginHeight = 0;
      filterComp.setLayout(layout);
      filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));

      fModeLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing);

      fPluginModeButton =
          toolkit.createButton(filterComp, Messages.TargetContentsGroup_PluginMode, SWT.RADIO);
      fPluginModeButton.setSelection(true);
      fFeaureModeButton =
          toolkit.createButton(filterComp, Messages.TargetContentsGroup_FeatureMode, SWT.RADIO);
      fFeaureModeButton.setSelection(true);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9);

      fShowPluginsButton =
          toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK);
      fShowPluginsButton.setSelection(true);
      fShowSourceButton =
          toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK);
      fShowSourceButton.setSelection(true);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fGroupLabel = toolkit.createLabel(filterComp, Messages.TargetContentsGroup_0);

      fGroupComboPart = new ComboPart();
      fGroupComboPart.createControl(filterComp, toolkit, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY);
      gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalIndent = 10;
      fGroupComboPart.getControl().setLayoutData(gd);
      fGroupComboPart.setItems(
          new String[] {
            Messages.TargetContentsGroup_1,
            Messages.TargetContentsGroup_2,
            Messages.TargetContentsGroup_3
          });
      fGroupComboPart.setVisibleItemCount(30);
      fGroupComboPart.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleGroupChange();
            }
          });
      fGroupComboPart.select(0);

    } else {
      Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
      fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
      fDeselectButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);

      Label emptySpace = new Label(buttonComp, SWT.NONE);
      GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectAllButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
      fDeselectAllButton =
          SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);

      emptySpace = new Label(buttonComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fSelectRequiredButton =
          SWTFactory.createPushButton(buttonComp, Messages.TargetContentsGroup_4, null);

      Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
      filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));

      fModeLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_ManageUsing, 1);

      fPluginModeButton =
          SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_PluginMode);
      fFeaureModeButton =
          SWTFactory.createRadioButton(filterComp, Messages.TargetContentsGroup_FeatureMode);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);

      fShowPluginsButton =
          SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
      fShowSourceButton =
          SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);

      emptySpace = new Label(filterComp, SWT.NONE);
      gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
      gd.widthHint = gd.heightHint = 5;
      emptySpace.setLayoutData(gd);

      fGroupLabel = SWTFactory.createLabel(filterComp, Messages.TargetContentsGroup_0, 1);
      fGroupCombo =
          SWTFactory.createCombo(
              filterComp,
              SWT.READ_ONLY,
              1,
              new String[] {
                Messages.TargetContentsGroup_1,
                Messages.TargetContentsGroup_2,
                Messages.TargetContentsGroup_3
              });
      gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.horizontalIndent = 10;
      fGroupCombo.setLayoutData(gd);
      fGroupCombo.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
              handleGroupChange();
            }
          });
      fGroupCombo.select(0);
    }

    fSelectButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fTree.getSelection().isEmpty()) {
              Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
              for (int i = 0; i < selected.length; i++) {
                fTree.setChecked(selected[i], true);
              }
              saveIncludedBundleState();
              contentChanged();
              updateButtons();
              fTree.update(
                  fTargetDefinition.getBundleContainers(),
                  new String[] {IBasicPropertyConstants.P_TEXT});
            }
          }
        });

    fDeselectButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fTree.getSelection().isEmpty()) {
              Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
              for (int i = 0; i < selected.length; i++) {
                fTree.setChecked(selected[i], false);
              }
              saveIncludedBundleState();
              contentChanged();
              updateButtons();
              fTree.update(
                  fTargetDefinition.getBundleContainers(),
                  new String[] {IBasicPropertyConstants.P_TEXT});
            }
          }
        });

    fSelectAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            fTree.setAllChecked(true);
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fDeselectAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            fTree.setAllChecked(false);
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fSelectRequiredButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Object[] allChecked = fTree.getCheckedLeafElements();
            Object[] required = null;
            if (fFeaureModeButton.getSelection()) {
              required = getRequiredFeatures(fTargetDefinition.getAllFeatures(), allChecked);
            } else {
              required = getRequiredPlugins(fAllBundles, allChecked);
            }
            for (int i = 0; i < required.length; i++) {
              fTree.setChecked(required[i], true);
            }
            saveIncludedBundleState();
            contentChanged();
            updateButtons();
            fTree.update(
                fTargetDefinition.getBundleContainers(),
                new String[] {IBasicPropertyConstants.P_TEXT});
          }
        });

    fPluginModeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Moving from feature based filtering to plug-in based, need to update storage
            ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_PLUGIN);
            contentChanged();
            fTargetDefinition.setIncluded(null);

            fGroupLabel.setEnabled(true);
            if (fGroupCombo != null) {
              fGroupCombo.setEnabled(true);
            } else {
              fGroupComboPart.getControl().setEnabled(true);
            }

            fTree.getControl().setRedraw(false);
            fTree.refresh(false);
            fTree.expandAll();
            updateCheckState();
            updateButtons();
            fTree.getControl().setRedraw(true);
          }
        });
    fPluginModeButton.setSelection(true);
    GridData gd = new GridData();
    gd.horizontalIndent = 10;
    fPluginModeButton.setLayoutData(gd);

    fFeaureModeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Moving from plug-in based filtering to feature based, need to update storage
            ((TargetDefinition) fTargetDefinition).setUIMode(TargetDefinition.MODE_FEATURE);
            contentChanged();
            fTargetDefinition.setIncluded(null);

            fGroupLabel.setEnabled(false);
            if (fGroupCombo != null) {
              fGroupCombo.setEnabled(false);
            } else {
              fGroupComboPart.getControl().setEnabled(false);
            }

            fTree.getControl().setRedraw(false);
            fTree.refresh(false);
            fTree.expandAll();
            updateCheckState();
            updateButtons();
            fTree.getControl().setRedraw(true);
          }
        });
    fFeaureModeButton.setSelection(false);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fFeaureModeButton.setLayoutData(gd);

    fShowPluginsButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fShowPluginsButton.getSelection()) {
              fTree.addFilter(fPluginFilter);
            } else {
              fTree.removeFilter(fPluginFilter);
              fTree.expandAll();
              updateCheckState();
            }
            updateButtons();
          }
        });
    fShowPluginsButton.setSelection(true);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fShowPluginsButton.setLayoutData(gd);

    fShowSourceButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fShowSourceButton.getSelection()) {
              fTree.addFilter(fSourceFilter);
            } else {
              fTree.removeFilter(fSourceFilter);
              fTree.expandAll();
              updateCheckState();
            }
            updateButtons();
          }
        });
    fShowSourceButton.setSelection(true);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fShowSourceButton.setLayoutData(gd);
  }