protected void addToWar(IVirtualComponent warComp, IVirtualComponent j2eeComp, String moduleURI) {
    final IDataModel dataModel =
        DataModelFactory.createDataModel(
            new AddWebFragmentComponentToWebApplicationDataModelProvider());
    Map map =
        (Map)
            dataModel.getProperty(
                IAddWebFragmentComponentToWebApplicationDataModelProperties
                    .TARGET_COMPONENTS_TO_URI_MAP);
    map.put(j2eeComp, moduleURI);

    dataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, warComp);

    List modList =
        (List)
            dataModel.getProperty(
                ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
    modList.add(j2eeComp);
    dataModel.setProperty(
        ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modList);
    dataModel.setProperty(
        ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
        "/WEB-INF/lib"); //$NON-NLS-1$
    try {
      dataModel.getDefaultOperation().execute(null, null);
    } catch (ExecutionException e) {
      J2EEPlugin.logError(e);
    }
  }
  public void setupNewProject(IDataModel dataModel, IFacetedProjectWorkingCopy facetedProject) {
    ProjectUtil.setGenerateDD(dataModel, true);

    FacetDataModelMap map = (FacetDataModelMap) dataModel.getProperty(FACET_DM_MAP);
    IDataModel webFacetModel = map.getFacetDataModel(IJ2EEFacetConstants.DYNAMIC_WEB_FACET.getId());

    webFacetModel.setStringProperty(
        IWebFacetInstallDataModelProperties.CONFIG_FOLDER,
        IPluginFacetConstants.PORTLET_PLUGIN_SDK_CONFIG_FOLDER);
    webFacetModel.setStringProperty(
        IWebFacetInstallDataModelProperties.SOURCE_FOLDER,
        IPluginFacetConstants.PORTLET_PLUGIN_SDK_SOURCE_FOLDER);
    IDataModel javaFacetModel = map.getFacetDataModel(JavaFacet.FACET.getId());
    javaFacetModel.setStringProperty(
        IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME,
        IPluginFacetConstants.PORTLET_PLUGIN_SDK_SOURCE_FOLDER);
    javaFacetModel.setStringProperty(
        IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME,
        IPluginFacetConstants.PORTLET_PLUGIN_SDK_DEFAULT_OUTPUT_FOLDER);

    if (dataModel.isNestedModel(PLUGIN_FRAGMENT_DM)) {
      dataModel.removeNestedModel(PLUGIN_FRAGMENT_DM);
    }

    // need to allow portlet framework to do any additional configuration

    IPortletFramework portletFramework =
        (IPortletFramework) dataModel.getProperty(PORTLET_FRAMEWORK);

    portletFramework.configureNewProject(dataModel, facetedProject);
  }
  public void execute(
      IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor)
      throws CoreException {
    if (monitor != null) {
      monitor.beginTask("", 1); // $NON-NLS-1$
    }

    try {
      IDataModel model = (IDataModel) config;

      // Associate with an EAR, if necessary.

      final String earProjectName =
          (String) model.getProperty(IJ2EEModuleFacetInstallDataModelProperties.EAR_PROJECT_NAME);
      if (model.getBooleanProperty(IJ2EEModuleFacetInstallDataModelProperties.ADD_TO_EAR)) {
        if (earProjectName != null && !earProjectName.equals("")) { // $NON-NLS-1$

          String ver = fv.getVersionString();
          String j2eeVersionText =
              J2EEVersionUtil.convertVersionIntToString(
                  J2EEVersionUtil.convertConnectorVersionStringToJ2EEVersionID(ver));

          final String moduleURI =
              model.getStringProperty(IJ2EEModuleFacetInstallDataModelProperties.MODULE_URI);

          final IFacetedProjectWorkingCopy fpjwc =
              (IFacetedProjectWorkingCopy) model.getProperty(FACETED_PROJECT_WORKING_COPY);

          installAndAddModuletoEAR(
              j2eeVersionText,
              earProjectName,
              fpjwc.getPrimaryRuntime(),
              project,
              moduleURI,
              monitor);
        }
      }

      if (monitor != null) {
        monitor.worked(1);
      }
    } finally {
      if (monitor != null) {
        monitor.done();
      }
    }
  }
  @Override
  public void execute(
      IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor)
      throws CoreException {

    super.execute(project, fv, config, monitor);

    IDataModel model = (IDataModel) config;

    IDataModel masterModel =
        (IDataModel) model.getProperty(FacetInstallDataModelProvider.MASTER_PROJECT_DM);

    if (masterModel != null && masterModel.getBooleanProperty(CREATE_PROJECT_OPERATION)) {
      SDK sdk = getSDK();

      String hookName = this.masterModel.getStringProperty(HOOK_NAME);

      // FIX IDE-450
      if (hookName.endsWith(ISDKConstants.HOOK_PLUGIN_PROJECT_SUFFIX)) {
        hookName =
            hookName.substring(0, hookName.indexOf(ISDKConstants.HOOK_PLUGIN_PROJECT_SUFFIX));
      }
      // END FIX IDE-450

      String displayName = this.masterModel.getStringProperty(DISPLAY_NAME);

      IPath installPath = sdk.createNewHookProject(hookName, displayName);

      IPath tempInstallPath =
          installPath.append(hookName + ISDKConstants.HOOK_PLUGIN_PROJECT_SUFFIX);

      processNewFiles(tempInstallPath, false);

      // cleanup hook files
      FileUtil.deleteDir(tempInstallPath.toFile(), true);

      this.project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    } else {
      setupDefaultOutputLocation();
    }

    // IDE-491 don't add this in the webxml by default
    // ProjectUtil.addLiferayPortletTldToWebXML( this.project );
  }
 /*
  * 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]));
 }
 /** @see IValidator#validate(Object, Object) */
 public Map<String, IStatus> validate(Object value, Object context) {
   final String deploymentType = value.toString();
   if (!ISeamFacetDataModelProperties.DEPLOY_AS_WAR.equals(deploymentType)) {
     Object runtimeName =
         model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
     if (runtimeName != null) {
       IRuntime rt = RuntimeManager.getRuntime(runtimeName.toString());
       if (!rt.supports(EJB_30) || !rt.supports(EAR_50)) {
         return SeamValidatorFactory.createErrormessage(
             propertyName,
             new Status(
                 IStatus.ERROR,
                 SeamCorePlugin.PLUGIN_ID,
                 NLS.bind(
                     SeamCoreMessages.SEAM_INSTALL_WIZARD_PAGE_CANNOT_USE_SELECTED_DEPLOYMENT6,
                     new String[] {deploymentType.toUpperCase(), runtimeName.toString()})));
       }
     }
   }
   return SeamValidatorFactory.NO_ERRORS;
 }
  /** 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);
    }
  }
  public void execute(
      final IProject project,
      final IProjectFacetVersion fv,
      final Object cfg,
      final IProgressMonitor monitor)
      throws CoreException {
    if (monitor != null) {
      monitor.beginTask("", 1); // $NON-NLS-1$
    }

    try {
      IDataModel model = (IDataModel) cfg;

      if (monitor != null) {
        monitor.worked(1);
      }
      // Add WTP natures.

      WtpUtils.addNaturestoEAR(project);

      final IVirtualComponent c = ComponentCore.createComponent(project, false);
      c.create(0, null);

      final IVirtualFolder earroot = c.getRootFolder();
      Path contentDirPath =
          new Path(model.getStringProperty(IEarFacetInstallDataModelProperties.CONTENT_DIR));
      earroot.createLink(contentDirPath, 0, null);
      J2EEModuleVirtualComponent.setDefaultDeploymentDescriptorFolder(
          earroot, contentDirPath, null);

      try {
        ((IDataModelOperation) model.getProperty(FacetDataModelProvider.NOTIFICATION_OPERATION))
            .execute(monitor, null);
      } catch (ExecutionException e) {
        J2EEPlugin.logError(e);
      }

      if (fv == IJ2EEFacetConstants.ENTERPRISE_APPLICATION_70
          || fv == IJ2EEFacetConstants.ENTERPRISE_APPLICATION_60
          || fv == IJ2EEFacetConstants.ENTERPRISE_APPLICATION_50) {
        if (model.getBooleanProperty(IJ2EEFacetInstallDataModelProperties.GENERATE_DD)) {
          // Create the deployment descriptor (application.xml) if one doesn't exist
          IFile appXmlFile =
              earroot.getUnderlyingFolder().getFile(new Path(J2EEConstants.APPLICATION_DD_URI));
          if (!appXmlFile.exists()) {
            try {
              if (!appXmlFile.getParent().exists()
                  && (appXmlFile.getParent().getType() == IResource.FOLDER)) {
                ((IFolder) appXmlFile.getParent()).create(true, true, monitor);
              }
              String appXmlContents = null;
              if (fv == IJ2EEFacetConstants.ENTERPRISE_APPLICATION_70) {
                appXmlContents =
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<application id=\"Application_ID\" version=\"7\" xmlns=\"http://xmlns.jcp.org/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd\">\n <display-name>"
                        + XMLWriter.getEscaped(project.getName())
                        + "</display-name> \n </application> "; //$NON-NLS-1$ //$NON-NLS-2$
              } else if (fv == IJ2EEFacetConstants.ENTERPRISE_APPLICATION_60) {
                appXmlContents =
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<application id=\"Application_ID\" version=\"6\" xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd\">\n <display-name>"
                        + XMLWriter.getEscaped(project.getName())
                        + "</display-name> \n </application> "; //$NON-NLS-1$ //$NON-NLS-2$
              } else {
                appXmlContents =
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<application id=\"Application_ID\" version=\"5\" xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd\">\n <display-name>"
                        + XMLWriter.getEscaped(project.getName())
                        + "</display-name> \n </application> "; //$NON-NLS-1$ //$NON-NLS-2$
              }
              appXmlFile.create(
                  new ByteArrayInputStream(appXmlContents.getBytes("UTF-8")),
                  true,
                  monitor); //$NON-NLS-1$
            } catch (UnsupportedEncodingException e) {
              J2EEPlugin.logError(e);
            }
          }
        }
      } else {
        if (!earroot.getFile(J2EEConstants.APPLICATION_DD_URI).exists()) {
          String ver = model.getStringProperty(IFacetDataModelProperties.FACET_VERSION_STR);
          int nVer = J2EEVersionUtil.convertVersionStringToInt(ver);
          EARArtifactEdit.createDeploymentDescriptor(project, nVer);
        }
      }
    } finally {
      if (monitor != null) {
        monitor.done();
      }
    }
  }