/**
  * Configure Shell. Set a title to it.
  *
  * @param newShell The new shell.
  * @see org.eclipse.jface.dialogs.Dialog#configureShell(org.eclipse.swt.widgets.Shell)
  */
 @Override
 protected void configureShell(Shell newShell) {
   newShell.setText(
       authorResourceBundle.getMessage(
           showChoiceTable ? ExtensionTags.INSERT_CHOICE_TABLE : ExtensionTags.INSERT_TABLE));
   super.configureShell(newShell);
 }
  /**
   * Create Dialog area.
   *
   * @param parent The parent composite.
   * @return The dialog control.
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(2, false));

    int tableModel = innerCalsTable ? TableInfo.TABLE_MODEL_CALS : TableInfo.TABLE_MODEL_CUSTOM;
    if (showModelChooser) {
      tableModel = TableInfo.TABLE_MODEL_CALS;
      // Allow the user to choose between HTML and CALS
      Group modelChooser = new Group(composite, SWT.SINGLE);
      modelChooser.setText(authorResourceBundle.getMessage(ExtensionTags.MODEL));
      modelChooser.setLayout(new GridLayout(2, true));
      GridData data = new GridData(SWT.FILL, SWT.NONE, true, false);
      data.horizontalSpan = 2;
      modelChooser.setLayoutData(data);

      // Radio button for choosing CALS table model
      calsModelRadio = new Button(modelChooser, SWT.RADIO | SWT.LEFT);
      calsModelRadio.setText("CALS");
      calsModelRadio.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              makeCalsTable = calsModelRadio.getSelection();
              // Set column widths input
              tableModelChanged(TableInfo.TABLE_MODEL_CALS);
            }
          });

      if (!showChoiceTable) {
        if (simpleTableModel) {
          // Radio button for choosing simple table model
          otherModelRadio = new Button(modelChooser, SWT.RADIO | SWT.LEFT);
          otherModelRadio.setText(authorResourceBundle.getMessage(ExtensionTags.SIMPLE));
          otherModelRadio.addSelectionListener(
              new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                  makeCalsTable = calsModelRadio.getSelection();
                  // Set column widths input
                  tableModelChanged(TableInfo.TABLE_MODEL_DITA_SIMPLE);
                }
              });

          // Set some default values.
          makeCalsTable = true;
          calsModelRadio.setSelection(makeCalsTable);
          otherModelRadio.setSelection(!makeCalsTable);
        } else {
          // Radio button for choosing HTML table model
          otherModelRadio = new Button(modelChooser, SWT.RADIO | SWT.LEFT);
          otherModelRadio.setText("HTML");
          otherModelRadio.addSelectionListener(
              new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                  makeCalsTable = calsModelRadio.getSelection();
                  // Set column widths inputs
                  tableModelChanged(TableInfo.TABLE_MODEL_HTML);
                }
              });

          // Set some default values.
          makeCalsTable = true;
          calsModelRadio.setSelection(makeCalsTable);
          otherModelRadio.setSelection(!makeCalsTable);
        }
      }
    } else {
      tableModel = TableInfo.TABLE_MODEL_DITA_CHOICE;
    }

    if (!innerCalsTable && !showChoiceTable) {
      // Title check box.
      titleCheckbox = createTitleCheckbox(composite);
      titleCheckbox.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              titleTextField.setEditable(titleCheckbox.getSelection());
              createTitle = titleCheckbox.getSelection();
              if (titleCheckbox.getSelection()) {
                // Request focus in text field
                titleTextField.setFocus();
              }
            }
          });
      // Set some default values.
      createTitle = true;
      titleCheckbox.setSelection(createTitle);

      // Title text field
      titleTextField = new Text(composite, SWT.SINGLE | SWT.BORDER);
      titleTextField.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              title = titleTextField.getText();
            }
          });
      GridData data = new GridData(SWT.FILL, SWT.NONE, true, false);
      titleTextField.setLayoutData(data);
    }
    // Set some default values.
    title = "";

    GridData data = new GridData(SWT.FILL, SWT.NONE, true, false);
    if (predefinedRowsCount <= 0 || predefinedColumnsCount <= 0) {
      // Give the number of rows and cols for the new table.
      Group sizeGroup = new Group(composite, SWT.SINGLE);
      sizeGroup.setText(authorResourceBundle.getMessage(ExtensionTags.TABLE_SIZE));
      sizeGroup.setLayout(new GridLayout(4, false));
      data.horizontalSpan = 2;
      sizeGroup.setLayoutData(data);

      // 'Rows' label.
      Label label = new Label(sizeGroup, SWT.LEFT);
      label.setText(authorResourceBundle.getMessage(ExtensionTags.ROWS));
      rowsSpinner = new Spinner(sizeGroup, SWT.BORDER);
      rowsSpinner.setMinimum(0);
      rowsSpinner.setMaximum(100);
      rowsSpinner.setSelection(3);
      rowsSpinner.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              rows = rowsSpinner.getSelection();
            }
          });
      rowsSpinner.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
      // Set some default values.
      rows = TableInfo.DEFAULT_ROWS_COUNT;

      // 'Columns' label
      label = new Label(sizeGroup, SWT.LEFT);
      label.setText(authorResourceBundle.getMessage(ExtensionTags.COLUMNS));
      columnsSpinner = new Spinner(sizeGroup, SWT.BORDER);
      columnsSpinner.setMinimum(0);
      columnsSpinner.setMaximum(100);
      columnsSpinner.setSelection(2);
      columnsSpinner.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
              columns = columnsSpinner.getSelection();
            }
          });
      columnsSpinner.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
      // Set some default values.
      columns = TableInfo.DEFAULT_COLUMNS_COUNT;

      if (showChoiceTable) {
        columnsSpinner.setEnabled(false);
      }
    }

    // Allow header and/or footer generation.
    Composite headerAndFooterComposite = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(2, true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    headerAndFooterComposite.setLayout(layout);
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.horizontalSpan = 2;
    headerAndFooterComposite.setLayoutData(data);

    // 'Header' check box
    headerCheckbox = new Button(headerAndFooterComposite, SWT.CHECK | SWT.LEFT);
    headerCheckbox.setText(authorResourceBundle.getMessage(ExtensionTags.GENERATE_TABLE_HEADER));
    headerCheckbox.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            createHeader = headerCheckbox.getSelection();
          }
        });
    // Set some default values.
    headerCheckbox.setSelection(true);
    createHeader = true;

    if (hasFooter) {
      // 'Footer' check box
      footerCheckbox = new Button(headerAndFooterComposite, SWT.CHECK | SWT.LEFT);
      footerCheckbox.setText(authorResourceBundle.getMessage(ExtensionTags.GENERATE_TABLE_FOOTER));
      footerCheckbox.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              createFooter = footerCheckbox.getSelection();
            }
          });
      // Set some default values.
      footerCheckbox.setSelection(false);
      createFooter = false;
    }

    final List<ColumnWidthsType> columnsWidths = getColumnWidthsSpecifications(tableModel);
    if (columnsWidths != null) {
      // Cols label
      Label colsLabel = new Label(composite, SWT.LEFT);
      colsLabel.setText(authorResourceBundle.getMessage(ExtensionTags.COLUMN_WIDTHS) + ": ");

      // Cols combo box
      colWidthsCombobox = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
      colWidthsCombobox.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
      ILabelProvider labelProvider =
          new LabelProvider() {
            /** Get descr for element. */
            @Override
            public String getText(Object element) {
              String render = String.valueOf(element);
              if (element instanceof ColumnWidthsType) {
                if (ColumnWidthsType.DYNAMIC_COL_WIDTHS == element) {
                  render = COLS_DYNAMIC;
                } else if (ColumnWidthsType.PROPORTIONAL_COL_WIDTHS == element) {
                  render = COLS_PROPORTIONAL;
                }
                if (ColumnWidthsType.FIXED_COL_WIDTHS == element) {
                  render = COLS_FIXED;
                }
              }
              return render;
            }
          };
      // Cols label provider
      colWidthsCombobox.setLabelProvider(labelProvider);
      colWidthsCombobox.addSelectionChangedListener(
          new ISelectionChangedListener() {
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              selectedColWidthsType =
                  ((ColumnWidthsType)
                      ((StructuredSelection) event.getSelection()).getFirstElement());
            }
          });
      // Cols content provider
      colWidthsCombobox.setContentProvider(new ListContentProvider());
      setColWidthsComboInput(columnsWidths);
    }

    if (hasFrameAttribute) {
      // 'Frame' label.
      Label frameLabel = new Label(composite, SWT.LEFT);
      frameLabel.setText(authorResourceBundle.getMessage(ExtensionTags.FRAME) + ": ");

      // Frame combo box
      framesCombo = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
      framesCombo.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
      framesCombo.addSelectionChangedListener(
          new ISelectionChangedListener() {
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              selectedFrame =
                  (String) ((StructuredSelection) event.getSelection()).getFirstElement();
            }
          });
      framesCombo.setContentProvider(new ListContentProvider());
      setFrameComboInput(getFrameValues(getTableModel()));
    }

    // EXM-29536 Add rowsep and colsep
    if (hasRowSep) {
      // 'Row sep' label.
      Label rowsepLabel = new Label(composite, SWT.LEFT);
      rowsepLabel.setText(authorResourceBundle.getMessage(ExtensionTags.ROW_SEPARATOR) + ": ");

      // Row sep combo box
      rowsepCombo = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
      rowsepCombo.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
      rowsepCombo.addSelectionChangedListener(
          new ISelectionChangedListener() {
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              selectedRowsep =
                  (String) ((StructuredSelection) event.getSelection()).getFirstElement();
            }
          });
      rowsepCombo.setContentProvider(new ListContentProvider());
      setRowsepComboInput(getRowsepValues(getTableModel()));
    }

    // EXM-29536 Add rowsep and colsep attribute when inserting a table
    if (hasColsep) {
      // 'Colsep' label.
      Label colsepLabel = new Label(composite, SWT.LEFT);
      colsepLabel.setText(authorResourceBundle.getMessage(ExtensionTags.COLUMN_SEPARATOR) + ": ");

      // Col sep combo box
      colsepCombo = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
      colsepCombo.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
      colsepCombo.addSelectionChangedListener(
          new ISelectionChangedListener() {
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              selectedColsep =
                  (String) ((StructuredSelection) event.getSelection()).getFirstElement();
            }
          });
      colsepCombo.setContentProvider(new ListContentProvider());
      setColsepComboInput(getColsepValues(getTableModel()));
    }

    // EXM-29536 Add align attribute when inserting a table
    if (hasAlign) {
      // 'Align' label.
      Label alignLabel = new Label(composite, SWT.LEFT);
      alignLabel.setText(authorResourceBundle.getMessage(ExtensionTags.ALIGNMENT) + ": ");

      // Align combo box
      alignCombo = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
      alignCombo.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
      alignCombo.addSelectionChangedListener(
          new ISelectionChangedListener() {
            @Override
            public void selectionChanged(SelectionChangedEvent event) {
              selectedAlign =
                  (String) ((StructuredSelection) event.getSelection()).getFirstElement();
            }
          });
      alignCombo.setContentProvider(new ListContentProvider());
      setAlignComboInput(getAlignValues(getTableModel()));
    }

    initialize();
    return composite;
  }
 /**
  * @see
  *     org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
  */
 @Override
 protected void createButtonsForButtonBar(Composite parent) {
   super.createButtonsForButtonBar(parent);
   getButton(OK).setText(authorResourceBundle.getMessage(ExtensionTags.INSERT));
 }