public void updateDescriptionViewer(ISchemaObject obj) {
   if (obj != null) {
     String text = obj.getDescription();
     fDescriptionViewer.getDocument().set(text == null ? "" : text); // $NON-NLS-1$
     fDescriptionViewer.getViewer().setEditable(obj.getSchema().isEditable());
   }
 }
 @Override
 public boolean doGlobalAction(String actionId) {
   if (fShowDescription
       && fDescriptionViewer != null
       && fDescriptionViewer.getViewer().getTextWidget().isFocusControl())
     return fDescriptionViewer.doGlobalAction(actionId);
   return super.doGlobalAction(actionId);
 }
 @Override
 public boolean canPaste(Clipboard clipboard) {
   if (fShowDescription
       && fDescriptionViewer != null
       && fDescriptionViewer.getViewer().getTextWidget().isFocusControl())
     return fDescriptionViewer.canPaste();
   return super.canPaste(clipboard);
 }
  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) {}
            });
  }
 @Override
 public void dispose() {
   // Set the context menu to null to prevent the editor context menu
   // from being disposed along with the source viewer
   if (fDescriptionViewer != null) {
     fDescriptionViewer.unsetMenu();
     fDescriptionViewer = null;
   }
   super.dispose();
 }
  @Override
  public final void createContents(Composite parent) {
    // This is a hacked fix to ensure that the label columns on every details
    // page have the same width. SchemaDetails_translatable plus 11 pixels
    // represents the longest label on any field on any details page. This
    // occurs on SchemaStringAttributeDetails and 11 is the size of the
    // horizontal indent that contributes to the label's width.
    GC gc = new GC(parent);
    minLabelWeight = gc.textExtent(PDEUIMessages.SchemaDetails_translatable).x + 11;
    gc.dispose();
    gc = null;

    parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1));
    FormToolkit toolkit = getManagedForm().getToolkit();
    fSection = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    fSection.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
    fSection.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));

    GridData gd;
    if (fShowDescription) gd = new GridData(GridData.FILL_BOTH);
    else gd = new GridData(GridData.FILL_HORIZONTAL);
    fSection.setLayoutData(gd);

    // Align the master and details section headers (misalignment caused
    // by section toolbar icons)
    getPage().alignSectionHeaders(fElementSection.getSection(), fSection);

    Composite client = toolkit.createComposite(fSection);
    client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 3));

    createDetails(client);

    if (fShowDescription) createDescription(client, toolkit);

    // If the DTD Approximation section was requested, instantiate it and create it's contents
    // on the same parent Composite
    if (fShowDTD) {
      fDtdSection = new SchemaDtdDetailsSection();
      fDtdSection.initialize(getManagedForm());
      fDtdSection.createContents(parent);
    }

    toolkit.paintBordersFor(client);
    fSection.setClient(client);
    markDetailsPart(fSection);

    if (fShowDescription) fDescriptionViewer.createUIListeners();
    hookListeners();
  }