protected void enableMinMax(boolean enable) {
   fMinOccurSpinner.setEnabled(enable);
   fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && enable);
   fUnboundSelect.setEnabled(enable);
   fMinLabel.setEnabled(enable);
   fMaxLabel.setEnabled(enable);
 }
  protected Composite createMaxOccurComp(Composite parent, FormToolkit toolkit) {
    fMaxLabel = toolkit.createLabel(parent, PDEUIMessages.AbstractSchemaDetails_maxOccurLabel);
    fMaxLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
    Composite comp = toolkit.createComposite(parent);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    GridLayout layout = new GridLayout(3, false);
    layout.marginHeight = layout.marginWidth = 0;
    comp.setLayout(layout);
    comp.setLayoutData(gd);

    fMaxOccurSpinner = new Spinner(comp, SWT.BORDER);
    fMaxOccurSpinner.setMinimum(1);
    fMaxOccurSpinner.setMaximum(999);
    fMaxOccurSpinner.setIncrement(1);

    fUnboundSelect =
        toolkit.createButton(comp, PDEUIMessages.AbstractSchemaDetails_unboundedButton, SWT.CHECK);
    gd = new GridData();
    gd.horizontalIndent = 10;
    fUnboundSelect.setLayoutData(gd);
    fUnboundSelect.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (blockListeners()) return;
            fMaxOccurSpinner.setEnabled(!fUnboundSelect.getSelection() && isEditableElement());
          }
        });

    return comp;
  }
  private void createDescription(Composite container, FormToolkit toolkit) {

    Label label =
        toolkit.createLabel(container, PDEUIMessages.AbstractSchemaDetails_descriptionLabel);
    GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    gd.horizontalSpan = 3;
    label.setLayoutData(gd);
    label.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));

    fDescriptionViewer = new PDESourceViewer(getPage());
    gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 75;
    gd.widthHint = 60;
    gd.horizontalSpan = 3;
    gd.horizontalIndent = 1;
    /*
     * Needed to align vertically with form entry field and allow space
     * for a possible field decoration
     * commented out for now since fields are already grossly misaligned (see bug 196879)
     * commenting out temporarily makes the alignment better on Element details and Attribute details
     * but worse on RootElement details
     */
    // gd.horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
    fDescriptionViewer.createUI(container, gd);
    fDescriptionViewer
        .getDocument()
        .addDocumentListener(
            new IDocumentListener() {
              @Override
              public void documentChanged(DocumentEvent event) {
                if (blockListeners()) return;
                if (fSchemaObject != null) {
                  // Get the text from the event
                  IDocument document = event.getDocument();
                  if (document == null) {
                    return;
                  }
                  // Get the text from the event
                  String text = document.get().trim();
                  updateObjectDescription(text);
                }
              }

              @Override
              public void documentAboutToBeChanged(DocumentEvent event) {}
            });
  }
 protected Composite createMinOccurComp(Composite parent, FormToolkit toolkit) {
   fMinLabel = toolkit.createLabel(parent, PDEUIMessages.AbstractSchemaDetails_minOccurLabel);
   fMinLabel.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
   Composite comp = toolkit.createComposite(parent);
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalSpan = 2;
   GridLayout layout = new GridLayout();
   layout.marginHeight = layout.marginWidth = 0;
   comp.setLayout(layout);
   comp.setLayoutData(gd);
   fMinOccurSpinner = new Spinner(comp, SWT.BORDER);
   fMinOccurSpinner.setMinimum(0);
   fMinOccurSpinner.setMaximum(999);
   return comp;
 }
  public void createClient(Section section, FormToolkit toolkit) {

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

    Composite container = toolkit.createComposite(section);
    container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 2));

    fNameText =
        new FormEntry(
            container,
            toolkit,
            MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_featureLabel,
            null,
            false);
    fNameText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            if (fInput != null)
              try {
                fInput.setName(text.getValue());
              } catch (CoreException e) {
                MDEPlugin.logException(e);
              }
          }
        });
    fNameText.setEditable(isEditable());

    fVersionText =
        new FormEntry(
            container, toolkit, MDEUIMessages.FeatureEditor_SpecSection_version, null, false);
    fVersionText.setFormEntryListener(
        new FormEntryAdapter(this) {
          public void textValueChanged(FormEntry text) {
            if (fInput != null)
              try {
                fInput.setVersion(text.getValue());
              } catch (CoreException e) {
                MDEPlugin.logException(e);
              }
          }
        });
    fVersionText.setEditable(isEditable());

    fOptionalButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_optional, SWT.CHECK);

    TableWrapData gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    fOptionalButton.setLayoutData(gd);
    fOptionalButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                fInput.setOptional(fOptionalButton.getSelection());
              } catch (CoreException ce) {
              }
            }
          }
        });
    Label fSearchLocationDescLabel =
        toolkit.createLabel(
            container,
            MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_searchLocation,
            SWT.WRAP);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    fSearchLocationDescLabel.setLayoutData(gd);

    fSearchRootButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_root, SWT.RADIO);
    fSearchRootButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchRootButton.setLayoutData(gd);
    fSearchRootButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchRootButton.getSelection()) fInput.setSearchLocation(IFeatureChild.ROOT);
              } catch (CoreException ce) {
              }
            }
          }
        });

    fSearchSelfButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_self, SWT.RADIO);
    fSearchSelfButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchSelfButton.setLayoutData(gd);
    fSearchSelfButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchSelfButton.getSelection()) fInput.setSearchLocation(IFeatureChild.SELF);
              } catch (CoreException ce) {
              }
            }
          }
        });

    fSearchBothButton =
        toolkit.createButton(
            container, MDEUIMessages.SiteEditor_IncludedFeaturesDetailsSection_both, SWT.RADIO);
    fSearchBothButton.setSelection(true);
    gd = new TableWrapData(TableWrapData.FILL);
    gd.colspan = 2;
    gd.indent = 5;
    fSearchBothButton.setLayoutData(gd);
    fSearchBothButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            if (!fBlockNotification) {
              try {
                if (fSearchBothButton.getSelection()) fInput.setSearchLocation(IFeatureChild.BOTH);
              } catch (CoreException ce) {
              }
            }
          }
        });

    toolkit.paintBordersFor(container);
    section.setClient(container);
  }