/**
   * Creates the checkbox tree and list for selecting resources.
   *
   * @param parent the parent control
   */
  protected final void createResourcesGroup(final Composite parent) {
    final Table table = new Table(parent, SWT.BORDER | SWT.CHECK);
    final CheckboxTableViewer viewer = new CheckboxTableViewer(table);
    viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new WorkbenchLabelProvider());
    viewer.setComparator(new ViewerComparator());

    viewer.setInput(m_data.getWspmProjects());

    final IViewerObservableSet target =
        ViewersObservables.observeCheckedElements(viewer, IProject.class);
    final WritableSet model = m_data.getSelectedProjectList();
    final DataSetBinder binder = new DataSetBinder(target, model);
    m_binding.bindValue(binder);
  }
  private void createImportModelControl(final Composite parent) {
    final Label label = new Label(parent, SWT.NONE);
    label.setText(Messages.getString("ImportAttachmentsPreviewPage.7")); // $NON-NLS-1$

    final ComboViewer viewer = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider());
    viewer.setInput(ImportMode.values());

    final IViewerObservableValue target = ViewersObservables.observeSinglePostSelection(viewer);
    final IObservableValue model =
        BeansObservables.observeValue(m_data, DocumentsAttachmentsData.PROPERTY_IMPORT_MODE);
    m_binding.bindValue(target, model);

    // TRICKY: we need to refresh the table when the import mode changes, in order
    // to show the gray state correctly
    model.addValueChangeListener(
        new IValueChangeListener() {
          @Override
          public void handleValueChange(final ValueChangeEvent event) {
            handleImportModeChanged();
          }
        });
  }
  private void createDocumentsTable(final Composite parent) {
    final Table table = new Table(parent, SWT.CHECK | SWT.FULL_SELECTION | SWT.BORDER);
    table.setHeaderVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    m_viewer = new CheckboxTableViewer(table);
    m_viewer.setContentProvider(new ArrayContentProvider());
    m_checkStateHandler = new DocumentsCheckstateHandler(m_viewer, m_data);
    m_viewer.setCheckStateProvider(m_checkStateHandler);

    /* Name. */
    final TableViewerColumn nameColumn = new TableViewerColumn(m_viewer, SWT.LEFT);
    nameColumn.setLabelProvider(new DocumentsNameProvider());
    nameColumn
        .getColumn()
        .setText(Messages.getString("ImportAttachmentsPreviewPage.4")); // $NON-NLS-1$
    nameColumn.getColumn().setResizable(false);
    ColumnViewerSorter.registerSorter(nameColumn, new DocumentsNameComparator());
    ColumnsResizeControlListener.setMinimumPackWidth(nameColumn.getColumn());

    /* Mime type. */
    final TableViewerColumn typeColumn = new TableViewerColumn(m_viewer, SWT.LEFT);
    typeColumn.setLabelProvider(new DocumentsTypeProvider());
    typeColumn
        .getColumn()
        .setText(Messages.getString("ImportAttachmentsPreviewPage.5")); // $NON-NLS-1$
    typeColumn.getColumn().setResizable(false);
    ColumnViewerSorter.registerSorter(typeColumn, new DocumentsTypeComparator());
    ColumnsResizeControlListener.setMinimumPackWidth(typeColumn.getColumn());

    /* Status. */
    final TableViewerColumn statusColumn = new TableViewerColumn(m_viewer, SWT.LEFT);
    statusColumn.setLabelProvider(new DocumentsStatusProvider(m_documentData));
    statusColumn
        .getColumn()
        .setText(Messages.getString("ImportAttachmentsPreviewPage.2")); // $NON-NLS-1$
    statusColumn.getColumn().setResizable(false);
    ColumnViewerSorter.registerSorter(statusColumn, new DocumentsStatusComparator(m_documentData));
    ColumnsResizeControlListener.setMinimumPackWidth(statusColumn.getColumn());

    table.addControlListener(new ColumnsResizeControlListener());

    ColumnSortListener.setSortState(nameColumn, Boolean.TRUE);

    /* Double-click shows status */
    m_viewer.addOpenListener(
        new IOpenListener() {
          @Override
          public void open(final OpenEvent event) {
            handleShowDocumentStatus((IStructuredSelection) event.getSelection());
          }
        });

    m_viewer.addCheckStateListener(m_checkStateHandler);

    final IObservableValue target = new WritableValue();
    final IObservableValue model =
        BeansObservables.observeValue(m_data, DocumentsAttachmentsData.PROPERTY_SELECTION_COUNT);

    final DataBinder countBinder = new DataBinder(target, model);
    countBinder.addModelAfterGetValidator(
        new NumberNotExactValidator(
            Integer.valueOf(0),
            IStatus.ERROR,
            Messages.getString("ImportAttachmentsPreviewPage.6"))); // $NON-NLS-1$
    m_binding.bindValue(countBinder);
  }