/**
  * @param seamPath
  * @return
  */
 private static boolean seamExists(String seamPath) {
   SeamRuntime[] seamRuntimes = SeamRuntimeManager.getInstance().getRuntimes();
   for (SeamRuntime sr : seamRuntimes) {
     if (seamPath != null && seamPath.equals(sr.getHomeDir())) {
       return true;
     }
   }
   return false;
 }
 public List<String> getRuntimeNames(String version) {
   SeamRuntime[] rts =
       SeamRuntimeManager.getInstance().getRuntimes(SeamVersion.parseFromString(version));
   List<String> result = new ArrayList<String>();
   for (SeamRuntime seamRuntime : rts) {
     result.add(seamRuntime.getName());
   }
   return result;
 }
 private boolean canTestProjectBeCreated() {
   if (isSeamProjectWizard()) {
     String seamRuntimeName = jBossSeamHomeEditor.getValueAsString();
     SeamRuntime seamRuntime = SeamRuntimeManager.getInstance().findRuntimeByName(seamRuntimeName);
     if (seamRuntime != null) {
       // bootstrap folder was removed in Seam 2.3.0.Beta1 from WFK 2.0 ER4
       // See https://issues.jboss.org/browse/JBIDE-11611
       File bootstrap = new File(seamRuntime.getHomeDir(), "bootstrap");
       return bootstrap.exists();
     }
   }
   return false;
 }
 private static void addSeam(
     Map<String, SeamRuntime> map, String seamPath, SeamVersion seamVersion, String name) {
   if (!seamExists(seamPath)) {
     File seamFolder = new File(seamPath);
     if (seamFolder.exists() && seamFolder.isDirectory()) {
       SeamRuntime rt = new SeamRuntime();
       rt.setHomeDir(seamPath);
       rt.setName(name);
       rt.setDefault(true);
       rt.setVersion(seamVersion);
       SeamRuntimeManager.getInstance().addRuntime(rt);
     }
   }
 }
        public java.util.Map<String, IStatus> validate(Object value, Object context) {
          Map<String, IStatus> errors = NO_ERRORS;

          if (value == null || "".equals(value)) { // $NON-NLS-1$
            errors =
                createErrormessage(
                    new Status(
                        IStatus.ERROR,
                        SeamCorePlugin.PLUGIN_ID,
                        SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RT_NOT_CONFIGURED));
          } else {
            SeamRuntime rt = SeamRuntimeManager.getInstance().findRuntimeByName(value.toString());
            if (rt == null) {
              errors =
                  createErrormessage(
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RT_CANNOT_BE_FOUND, value)));
            } else if (!new File(rt.getHomeDir()).exists()) {
              errors =
                  createErrormessage(
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RT_HOME_DIR_DOES_NOT_EXIST,
                              value)));
            } else if (!new File(rt.getSeamGenDir()).exists()) {
              errors =
                  createErrormessage(
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages
                                  .VALIDATOR_FACTORY_SEAM_RT_TEMPLATES_DIR_DOES_NOT_EXIST,
                              value)));
            } else if (!new File(rt.getSrcTemplatesDir()).exists()) {
              errors =
                  createErrormessage(
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages
                                  .VALIDATOR_FACTORY_SEAM_RT_SOURCE_TEMPLATES_DIR_DOES_NOT_EXIST,
                              value)));
            } else if (!new File(rt.getViewTemplatesDir()).exists()) {
              errors =
                  createErrormessage(
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages
                                  .VALIDATOR_FACTORY_SEAM_RT_VIE_TEMPLATE_DIR_DOES_NOT_EXIST,
                              value)));
              // } else if(!new
              // File(rt.getResourceTemplatesDir()).exists()) {
              // errors = createErrormessage(NLS.bind(
              // "Seam Runtime '{0)' resource templates directory doesn't exist for selected Seam
              // Web Project"
              // ,value));
            }
          }
          return errors;
        }
        public Map<String, IStatus> validate(Object value, Object context) {

          Map<String, IStatus> errors = NO_ERRORS;
          if (value == null || "".equals(value.toString().trim())) { // $NON-NLS-1$
            errors =
                createErrormessage(
                    ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
                    new Status(
                        IStatus.ERROR,
                        SeamCorePlugin.PLUGIN_ID,
                        SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RUNTIME_IS_NOT_SELECTED));
          } else {
            SeamRuntime rt = SeamRuntimeManager.getInstance().findRuntimeByName(value.toString());
            if (rt == null) {
              errors =
                  createErrormessage(
                      ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages.VALIDATOR_FACTORY_CANNOT_FIND_SEAM_RUNTIME, value)));
            } else if (!new File(rt.getHomeDir()).exists()) {
              errors =
                  createErrormessage(
                      ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RT_HOME_DIR_IS_MISSING,
                              value)));
            } else if (!new File(rt.getSeamGenDir()).exists()) {
              errors =
                  createErrormessage(
                      ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RT_TEMPLATES_DIR_IS_MISSING,
                              value)));
            } else if (!new File(rt.getSrcTemplatesDir()).exists()) {
              errors =
                  createErrormessage(
                      ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RT_SRC_DIR_IS_MISSING,
                              value)));
            } else if (!new File(rt.getViewTemplatesDir()).exists()) {
              errors =
                  createErrormessage(
                      ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RT_VIEW_DIR_IS_MISSING,
                              value)));
            } else if (!new File(rt.getResourceTemplatesDir()).exists()) {
              errors =
                  createErrormessage(
                      ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
                      new Status(
                          IStatus.ERROR,
                          SeamCorePlugin.PLUGIN_ID,
                          NLS.bind(
                              SeamCoreMessages.VALIDATOR_FACTORY_SEAM_RT_RESOURCES_DIR_IS_MISSING,
                              value)));
            }
          }
          return errors;
        }