/*
  * Sets seam runtime field in default value.
  */
 private void setDefaultSeamRuntime() {
   ITaggedFieldEditor runtimesField =
       (ITaggedFieldEditor) ((CompositeEditor) jBossSeamHomeEditor).getEditors().get(1);
   Object oldValue = runtimesField.getValue();
   Object newValue = ""; // $NON-NLS-1$
   List<String> runtimes =
       getRuntimeNames(model.getProperty(IFacetDataModelProperties.FACET_VERSION_STR).toString());
   if (oldValue == null || !runtimes.contains(oldValue)) {
     Object defaultRnt = SeamFacetInstallDataModelProvider.getSeamRuntimeDefaultValue(model);
     if (defaultRnt != null && runtimes.contains(defaultRnt)) {
       newValue = defaultRnt;
     } else if (!runtimes.isEmpty()) {
       newValue = runtimes.get(0);
     }
   } else {
     newValue = oldValue;
   }
   runtimesField.setValue(newValue);
   runtimesField.setTags(runtimes.toArray(new String[0]));
 }
  /** Creates Seam Facet Wizard Page contents */
  public void createControl(Composite parent) {
    sync = new DataModelSynchronizer(model);
    jBossSeamHomeEditor =
        SeamWizardFactory.createSeamRuntimeSelectionFieldEditor(
            new SeamVersion[0],
            SeamFacetInstallDataModelProvider.getSeamRuntimeDefaultValue(model),
            new NewSeamRuntimeAction());

    initializeDialogUnits(parent);

    Composite root = new Composite(parent, SWT.NONE);
    GridData gd = new GridData();

    gd.horizontalSpan = 1;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = false;

    GridLayout gridLayout = new GridLayout(1, false);
    root.setLayout(gridLayout);
    Group generalGroup = new Group(root, SWT.NONE);
    generalGroup.setLayoutData(gd);
    generalGroup.setText(SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_GENERAL);
    gridLayout = new GridLayout(3, false);

    generalGroup.setLayout(gridLayout);
    registerEditor(jBossSeamHomeEditor, generalGroup, 3);
    jBossSeamHomeEditor.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent arg0) {
            Boolean testProject = canTestProjectBeCreated();
            createTestProjectCheckboxeditor.setValue(testProject);
            createTestProjectCheckboxeditor.setEnabled(testProject);
          }
        });

    Object deployAs = getDeployAsDefaultValue();
    jBossAsDeployAsEditor.setValue(deployAs);

    registerEditor(jBossAsDeployAsEditor, generalGroup, 3);
    registerEditor(ejbProjectNameditor, generalGroup, 3);
    ejbProjectNameditor.setEnabled(deployAs.equals(ISeamFacetDataModelProperties.DEPLOY_AS_EAR));
    registerEditor(earProjectNameditor, generalGroup, 3);
    earProjectNameditor.setEnabled(deployAs.equals(ISeamFacetDataModelProperties.DEPLOY_AS_EAR));

    List<String> providers = new ArrayList<String>();
    providers.add(SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_COPY_LIBRARIES);
    providers.add(SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_CONFIGURE_LATER);

    libraryListEditor =
        IFieldEditorFactory.INSTANCE.createComboEditor(
            ISeamFacetDataModelProperties.SEAM_LIBRARY_PROVIDER,
            SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_LIBRARIES,
            providers,
            providers.get(0));

    registerEditor(libraryListEditor, generalGroup, 3);

    jBossAsDeployAsEditor.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent arg0) {
            Boolean value =
                jBossAsDeployAsEditor.getValue() == ISeamFacetDataModelProperties.DEPLOY_AS_EAR;
            if (!isWebProjectWizard()) {
              ejbProjectNameditor.setEnabled(value.booleanValue());
              earProjectNameditor.setEnabled(value.booleanValue());
            }
          }
        });

    gd = new GridData();
    gd.horizontalSpan = 1;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = false;

    databaseGroup = new Group(root, SWT.NONE);
    databaseGroup.setLayoutData(gd);
    databaseGroup.setText(SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE);
    gridLayout = new GridLayout(4, false);
    databaseGroup.setLayout(gridLayout);

    jBossHibernateDbTypeEditor =
        IFieldEditorFactory.INSTANCE.createComboEditor(
            ISeamFacetDataModelProperties.DB_TYPE,
            SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_DATABASE_TYPE,
            Arrays.asList(HIBERNATE_HELPER.getDialectNames()),
            getDefaultDbType(),
            false);
    registerEditor(jBossHibernateDbTypeEditor, databaseGroup, 4);

    createDatabaseGoupControl();

    Group generationGroup = new Group(root, SWT.NONE);
    gd = new GridData();
    gd.horizontalSpan = 1;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = false;

    generationGroup.setLayoutData(gd);
    generationGroup.setText(SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_CODE_GENERATION);
    gridLayout = new GridLayout(3, false);
    generationGroup.setLayout(gridLayout);
    registerEditor(sessionBeanPkgNameditor, generationGroup, 3);
    registerEditor(entityBeanPkgNameditor, generationGroup, 3);

    registerEditor(createTestProjectCheckboxeditor, generationGroup, 3);
    createTestProjectCheckboxeditor.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent arg0) {
            Boolean value = (Boolean) createTestProjectCheckboxeditor.getValue();
            testsPkgNameditor.setEnabled(value.booleanValue());
            testProjectNameditor.setEnabled(value.booleanValue());
          }
        });

    registerEditor(testProjectNameditor, generationGroup, 3);
    registerEditor(testsPkgNameditor, generationGroup, 3);

    if (!isSeamProjectWizard()) {
      createTestProjectCheckboxeditor.setValue(false);
      createTestProjectCheckboxeditor.setEnabled(false);
      testProjectNameditor.setEnabled(false);
      testsPkgNameditor.setEnabled(false);
      if (!isWebProjectWizard()) {
        libraryListEditor.setValue(providers.get(1));
        libraryListEditor.setEnabled(false);
      }
    }
    if (isWebProjectWizard()) {
      ejbProjectNameditor.setValue("");
      ejbProjectNameditor.setEnabled(false);
      earProjectNameditor.setValue("");
      earProjectNameditor.setEnabled(false);
    }

    setControl(root);

    if (validatorDelegate == null) {
      validatorDelegate = new DataModelValidatorDelegate(this.model, this);
      validatorDelegate.addValidatorForProperty(
          jBossSeamHomeEditor.getName(), SeamValidatorFactory.SEAM_RUNTIME_NAME_VALIDATOR);
      validatorDelegate.addValidatorForProperty(
          connProfileSelEditor.getName(), SeamValidatorFactory.CONNECTION_PROFILE_VALIDATOR);
      validatorDelegate.addValidatorForProperty(
          testsPkgNameditor.getName(),
          new PackageNameValidator(testsPkgNameditor.getName(), "tests")); // $NON-NLS-1$
      validatorDelegate.addValidatorForProperty(
          entityBeanPkgNameditor.getName(),
          new PackageNameValidator(
              entityBeanPkgNameditor.getName(), "entity beans")); // $NON-NLS-1$
      validatorDelegate.addValidatorForProperty(
          sessionBeanPkgNameditor.getName(),
          new PackageNameValidator(
              sessionBeanPkgNameditor.getName(), "session beans")); // $NON-NLS-1$
      if (isSeamProjectWizard()) {
        validatorDelegate.addValidatorForProperty(
            IFacetDataModelProperties.FACET_PROJECT_NAME,
            new ProjectNamesDuplicationValidator(IFacetDataModelProperties.FACET_PROJECT_NAME));
      }
      validatorDelegate.addValidatorForProperty(
          ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
          getDeploymentTypeValidator(getWizard()));

      validatorDelegate.addValidatorForProperty(
          ISeamFacetDataModelProperties.SEAM_EAR_PROJECT,
          new ProjectNamesDuplicationValidator(ISeamFacetDataModelProperties.SEAM_EAR_PROJECT));
      validatorDelegate.addValidatorForProperty(
          ISeamFacetDataModelProperties.SEAM_EJB_PROJECT,
          new ProjectNamesDuplicationValidator(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT));
      validatorDelegate.addValidatorForProperty(
          ISeamFacetDataModelProperties.SEAM_TEST_PROJECT,
          new ProjectNamesDuplicationValidator(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT));
    }

    Dialog.applyDialogFont(parent);
    initDefaultWizardProperties();
    Object parentDm = model.getProperty(FacetInstallDataModelProvider.MASTER_PROJECT_DM);
    if (parentDm != null) {
      ((IDataModel) parentDm).addListener(this);
    }
  }